(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.

- Waypoints: Until now stat_id was saved but never assigned to. Instead we now save the GRFID/local index of the custom graphics so that GRF file changes can leave graphics intact.
This commit is contained in:
2005-11-16 22:20:15 +00:00
parent 5cb9de35d1
commit 754d26407e
6 changed files with 121 additions and 40 deletions

View File

@@ -6,18 +6,21 @@
#include "pool.h"
struct Waypoint {
TileIndex xy;
uint16 index;
TileIndex xy; ///< Tile of waypoint
uint16 index; ///< Index of waypoint
uint16 town_index;
byte town_cn; // The Nth waypoint for this town (consecutive number)
StringID string; // If this is zero, town + town_cn is used for naming
uint16 town_index; ///< Town associated with the waypoint
byte town_cn; ///< The Nth waypoint for this town (consecutive number)
StringID string; ///< If this is zero (i.e. no custom name), town + town_cn is used for naming
ViewportSign sign;
uint16 build_date;
byte stat_id;
uint32 grfid;
byte deleted; // this is a delete counter. when it reaches 0, the waypoint struct is deleted.
ViewportSign sign; ///< Dimensions of sign (not saved)
uint16 build_date; ///< Date of construction
byte stat_id; ///< ID of waypoint within the waypoint class (not saved)
uint32 grfid; ///< ID of GRF file
byte localidx; ///< Index of station within GRF file
byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
};
enum {
@@ -56,13 +59,24 @@ static inline bool IsRailWaypoint(TileIndex tile)
return (_m[tile].m5 & 0xFC) == 0xC4;
}
/**
* Fetch a waypoint by tile
* @param tile Tile of waypoint
* @return Waypoint
*/
static inline Waypoint *GetWaypointByTile(TileIndex tile)
{
assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
return GetWaypoint(_m[tile].m2);
}
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
Station *ComposeWaypointStation(TileIndex tile);
Waypoint *GetWaypointByTile(TileIndex tile);
void ShowRenameWaypointWindow(const Waypoint *cp);
void DrawWaypointSprite(int x, int y, int image, RailType railtype);
void UpdateWaypointSign(Waypoint *cp);
void FixOldWaypoints(void);
void UpdateAllWaypointSigns(void);
void UpdateAllWaypointCustomGraphics(void);
#endif /* WAYPOINT_H */