# waypoint.h

Go to the documentation of this file.

    00001 /* $Id: waypoint.h 14266 2008-09-07 21:26:26Z rubidium $ */
    00002
    00005 #ifndef WAYPOINT_H
    00006 #define WAYPOINT_H
    00007
    00008 #include "oldpool.h"
    00009 #include "rail_map.h"
    00010 #include "command_type.h"
    00011
    00012 struct Waypoint;
    00013 DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000)
    00014
    00015 struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> {
    00016   TileIndex xy;
    00017
    00018   TownID town_index;
    00019   uint16 town_cn;
    00020   StringID string;
    00021   char *name;
    00022
    00023   ViewportSign sign;
    00024   Date build_date;
    00025
    00026   byte stat_id;
    00027   uint32 grfid;
    00028   byte localidx;
    00029
    00030   byte deleted;
    00031
    00032   Waypoint(TileIndex tile = 0);
    00033   ~Waypoint();
    00034
    00035   inline bool IsValid() const { return this->xy != 0; }
    00036 };
    00037
    00038 static inline bool IsValidWaypointID(WaypointID index)
    00039 {
    00040   return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid();
    00041 }
    00042
    00043 #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (wp->IsValid())
    00044 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
    00045
    00046
    00052 static inline Waypoint *GetWaypointByTile(TileIndex tile)
    00053 {
    00054   assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
    00055   return GetWaypoint(GetWaypointIndex(tile));
    00056 }
    00057
    00058 CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
    00059 Station *ComposeWaypointStation(TileIndex tile);
    00060 void ShowRenameWaypointWindow(const Waypoint *cp);
    00061 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);
    00062 void FixOldWaypoints();
    00063 void UpdateAllWaypointSigns();
    00064 void AfterLoadWaypoints();
    00065
    00066 #endif /* WAYPOINT_H */