# waypoint.h

Go to the documentation of this file.

    00001 /* $Id: waypoint.h 15434 2009-02-09 21:20:05Z rubidium $ */
    00002
    00005 #ifndef WAYPOINT_H
    00006 #define WAYPOINT_H
    00007
    00008 #include "waypoint_type.h"
    00009 #include "oldpool.h"
    00010 #include "rail_map.h"
    00011 #include "command_type.h"
    00012 #include "station_type.h"
    00013 #include "town_type.h"
    00014 #include "viewport_type.h"
    00015 #include "date_type.h"
    00016
    00017 DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000)
    00018
    00019 struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> {
    00020   TileIndex xy;
    00021
    00022   TownID town_index;
    00023   uint16 town_cn;
    00024   StringID string;
    00025   char *name;
    00026
    00027   ViewportSign sign;
    00028   Date build_date;
    00029   OwnerByte owner;
    00030
    00031   byte stat_id;
    00032   uint32 grfid;
    00033   byte localidx;
    00034
    00035   byte deleted;
    00036
    00037   Waypoint(TileIndex tile = INVALID_TILE);
    00038   ~Waypoint();
    00039
    00040   inline bool IsValid() const { return this->xy != INVALID_TILE; }
    00041 };
    00042
    00043 static inline bool IsValidWaypointID(WaypointID index)
    00044 {
    00045   return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid();
    00046 }
    00047
    00048 #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())
    00049 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
    00050
    00051
    00057 static inline Waypoint *GetWaypointByTile(TileIndex tile)
    00058 {
    00059   assert(IsRailWaypointTile(tile));
    00060   return GetWaypoint(GetWaypointIndex(tile));
    00061 }
    00062
    00063 CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove);
    00064 Station *ComposeWaypointStation(TileIndex tile);
    00065 void ShowWaypointWindow(const Waypoint *wp);
    00066 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);
    00067 void UpdateAllWaypointSigns();
    00068
    00069 #endif /* WAYPOINT_H */