mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r4280) -Codechange: Add and make use of map accessors concerning railway waypoints
This commit is contained in:
parent
99a6b9b8f2
commit
8362990f8c
14
rail_map.h
14
rail_map.h
|
@ -124,12 +124,26 @@ static inline DiagDirection GetRailDepotDirection(TileIndex t)
|
|||
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
||||
}
|
||||
|
||||
static inline TrackBits GetRailWaypointTrack(TileIndex t)
|
||||
{
|
||||
return HASBIT(_m[t].m5, 0) ? TRACK_Y : TRACK_X;
|
||||
}
|
||||
|
||||
static inline TrackBits GetRailWaypointBits(TileIndex t)
|
||||
{
|
||||
return _m[t].m5 & 1 ? TRACK_BIT_Y : TRACK_BIT_X;
|
||||
}
|
||||
|
||||
static inline void SetCustomWaypointSprite(TileIndex t)
|
||||
{
|
||||
SETBIT(_m[t].m3, 4);
|
||||
}
|
||||
|
||||
static inline void ClearCustomWaypointSprite(TileIndex t)
|
||||
{
|
||||
CLRBIT(_m[t].m3, 4);
|
||||
}
|
||||
|
||||
|
||||
typedef enum SignalType {
|
||||
SIGTYPE_NORMAL = 0, // normal signal
|
||||
|
|
|
@ -221,13 +221,13 @@ int32 CmdBuildTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||
spec = GetCustomStation(STAT_CLASS_WAYP, GB(p1, 0, 8));
|
||||
|
||||
if (spec != NULL) {
|
||||
SETBIT(_m[tile].m3, 4);
|
||||
SetCustomWaypointSprite(tile);
|
||||
wp->stat_id = GB(p1, 0, 8);
|
||||
wp->grfid = spec->grfid;
|
||||
wp->localidx = spec->localidx;
|
||||
} else {
|
||||
// Specified custom graphics do not exist, so use default.
|
||||
CLRBIT(_m[tile].m3, 4);
|
||||
ClearCustomWaypointSprite(tile);
|
||||
wp->stat_id = 0;
|
||||
wp->grfid = 0;
|
||||
wp->localidx = 0;
|
||||
|
@ -293,8 +293,6 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
|||
return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Axis direction = _m[tile].m5 & RAIL_WAYPOINT_TRACK_MASK;
|
||||
|
||||
wp = GetWaypointByTile(tile);
|
||||
|
||||
wp->deleted = 30; // let it live for this many days before we do the actual deletion.
|
||||
|
@ -305,7 +303,7 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
|||
MarkTileDirtyByTile(tile);
|
||||
} else {
|
||||
DoClearSquare(tile);
|
||||
SetSignalsOnBothDir(tile, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
||||
SetSignalsOnBothDir(tile, GetRailWaypointTrack(tile));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue