mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
-Codechange: IsRailWaypoint should take 'tile', not 'm5'
This commit is contained in:
parent
b739674307
commit
c1b012171d
|
@ -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: {
|
||||
|
|
|
@ -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;
|
||||
|
|
9
pbs.c
9
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 {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue