# HG changeset patch # User truelight # Date 1132152061 0 # Node ID 54d9f9d4dca382f5be65c39a75901ac096be0f55 # Parent 78b3c154afa4076c763161c1e7732349a8e5d2e1 (svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers) -Codechange: IsRailWaypoint should take 'tile', not 'm5' diff -r 78b3c154afa4 -r 54d9f9d4dca3 disaster_cmd.c --- a/disaster_cmd.c Wed Nov 16 14:30:24 2005 +0000 +++ b/disaster_cmd.c Wed Nov 16 14:41:01 2005 +0000 @@ -25,7 +25,7 @@ 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 -r 78b3c154afa4 -r 54d9f9d4dca3 order_gui.c --- a/order_gui.c Wed Nov 16 14:30:24 2005 +0000 +++ b/order_gui.c Wed Nov 16 14:41:01 2005 +0000 @@ -246,7 +246,7 @@ 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 -r 78b3c154afa4 -r 54d9f9d4dca3 pbs.c --- a/pbs.c Wed Nov 16 14:30:24 2005 +0000 +++ b/pbs.c Wed Nov 16 14:41:01 2005 +0000 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 -r 78b3c154afa4 -r 54d9f9d4dca3 rail_cmd.c --- a/rail_cmd.c Wed Nov 16 14:30:24 2005 +0000 +++ b/rail_cmd.c Wed Nov 16 14:41:01 2005 +0000 @@ -1491,7 +1491,7 @@ 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 @@ { if (IsTileDepotType(tile, TRANSPORT_RAIL)) { ShowTrainDepotWindow(tile); - } else if (IsRailWaypoint(_m[tile].m5)) { + } else if (IsRailWaypoint(tile)) { ShowRenameWaypointWindow(GetWaypointByTile(tile)); } } diff -r 78b3c154afa4 -r 54d9f9d4dca3 waypoint.c --- a/waypoint.c Wed Nov 16 14:30:24 2005 +0000 +++ b/waypoint.c Wed Nov 16 14:41:01 2005 +0000 @@ -261,7 +261,7 @@ 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 -r 78b3c154afa4 -r 54d9f9d4dca3 waypoint.h --- a/waypoint.h Wed Nov 16 14:30:24 2005 +0000 +++ b/waypoint.h Wed Nov 16 14:41:01 2005 +0000 @@ -51,9 +51,9 @@ #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);