From c1b012171d2a0db4702af7f2b1616a2139e98dcd Mon Sep 17 00:00:00 2001 From: truelight Date: Wed, 16 Nov 2005 14:41:01 +0000 Subject: (svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers) -Codechange: IsRailWaypoint should take 'tile', not 'm5' --- disaster_cmd.c | 2 +- order_gui.c | 2 +- pbs.c | 9 +++++---- rail_cmd.c | 4 ++-- waypoint.c | 2 +- waypoint.h | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/disaster_cmd.c b/disaster_cmd.c index c83c03920..6bf0b0d51 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -25,7 +25,7 @@ static void DisasterClearSquare(TileIndex tile) switch (GetTileType(tile)) { case MP_RAILWAY: - if (IS_HUMAN_PLAYER(GetTileOwner(tile)) && !IsRailWaypoint(_m[tile].m5)) DoClearSquare(tile); + if (IS_HUMAN_PLAYER(GetTileOwner(tile)) && !IsRailWaypoint(tile)) DoClearSquare(tile); break; case MP_HOUSE: { diff --git a/order_gui.c b/order_gui.c index 4459c1b46..adf4ab8bc 100644 --- a/order_gui.c +++ b/order_gui.c @@ -246,7 +246,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) if (IsTileType(tile, MP_RAILWAY) && v->type == VEH_Train && IsTileOwner(tile, _local_player) && - (_m[tile].m5 & 0xFE) == 0xC4) { + IsRailWaypoint(tile)) { order.type = OT_GOTO_WAYPOINT; order.flags = 0; order.station = GetWaypointByTile(tile)->index; diff --git a/pbs.c b/pbs.c index 701219529..e18b0acf8 100644 --- a/pbs.c +++ b/pbs.c @@ -10,6 +10,7 @@ #include "npf.h" #include "pathfind.h" #include "depot.h" +#include "waypoint.h" /** @file pbs.c Path-Based-Signalling implementation file * @see pbs.h */ @@ -52,7 +53,7 @@ void PBSReserveTrack(TileIndex tile, Track track) { assert(track <= 5); switch (GetTileType(tile)) { case MP_RAILWAY: - if ((_m[tile].m5 & ~1) == 0xC4) { + if (IsRailWaypoint(tile)) { // waypoint SETBIT(_m[tile].m3, 6); } else { @@ -90,7 +91,7 @@ byte PBSTileReserved(TileIndex tile) { assert(IsValidTile(tile)); switch (GetTileType(tile)) { case MP_RAILWAY: - if ((_m[tile].m5 & ~1) == 0xC4) { + if (IsRailWaypoint(tile)) { // waypoint // check if its reserved if (!HASBIT(_m[tile].m3, 6)) return 0; @@ -125,7 +126,7 @@ uint16 PBSTileUnavail(TileIndex tile) { assert(IsValidTile(tile)); switch (GetTileType(tile)) { case MP_RAILWAY: - if ((_m[tile].m5 & ~1) == 0xC4) { + if (IsRailWaypoint(tile)) { // waypoint return HASBIT(_m[tile].m3, 6) ? TRACKDIR_BIT_MASK : 0; } else { @@ -153,7 +154,7 @@ void PBSClearTrack(TileIndex tile, Track track) { assert(track <= 5); switch (GetTileType(tile)) { case MP_RAILWAY: - if ((_m[tile].m5 & ~1) == 0xC4) { + if (IsRailWaypoint(tile)) { // waypoint CLRBIT(_m[tile].m3, 6); } else { diff --git a/rail_cmd.c b/rail_cmd.c index 21bc73ee5..18e0a7481 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1491,7 +1491,7 @@ static void DrawTile_Track(TileInfo *ti) if (ti->tileh != 0) DrawFoundation(ti, ti->tileh); - if (IsRailWaypoint(m5) && HASBIT(_m[ti->tile].m3, 4)) { + if (IsRailWaypoint(ti->tile) && HASBIT(_m[ti->tile].m3, 4)) { // look for customization const StationSpec *stat = GetCustomStation(STAT_CLASS_WAYP, _m[ti->tile].m4 + 1); @@ -2100,7 +2100,7 @@ static void ClickTile_Track(TileIndex tile) { if (IsTileDepotType(tile, TRANSPORT_RAIL)) { ShowTrainDepotWindow(tile); - } else if (IsRailWaypoint(_m[tile].m5)) { + } else if (IsRailWaypoint(tile)) { ShowRenameWaypointWindow(GetWaypointByTile(tile)); } } diff --git a/waypoint.c b/waypoint.c index fd5c10e75..60b6c8735 100644 --- a/waypoint.c +++ b/waypoint.c @@ -261,7 +261,7 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) Waypoint *wp; /* Make sure it's a waypoint */ - if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(_m[tile].m5)) + if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(tile)) return CMD_ERROR; if (!CheckTileOwnership(tile) && !(_current_player == OWNER_WATER)) diff --git a/waypoint.h b/waypoint.h index a2b1c28bd..a9c3432ea 100644 --- a/waypoint.h +++ b/waypoint.h @@ -51,9 +51,9 @@ static inline bool IsWaypointIndex(uint index) #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : NULL) #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) -static inline bool IsRailWaypoint(byte m5) +static inline bool IsRailWaypoint(TileIndex tile) { - return (m5 & 0xFC) == 0xC4; + return (_m[tile].m5 & 0xFC) == 0xC4; } int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); -- cgit v1.2.3-70-g09d2