mirror of https://github.com/OpenTTD/OpenTTD
(svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
-Codechange: IsRailWaypoint should take 'tile', not 'm5'release/0.4.5
parent
b739674307
commit
c1b012171d
|
@ -25,7 +25,7 @@ static void DisasterClearSquare(TileIndex tile)
|
||||||
|
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
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;
|
break;
|
||||||
|
|
||||||
case MP_HOUSE: {
|
case MP_HOUSE: {
|
||||||
|
|
|
@ -246,7 +246,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||||
if (IsTileType(tile, MP_RAILWAY) &&
|
if (IsTileType(tile, MP_RAILWAY) &&
|
||||||
v->type == VEH_Train &&
|
v->type == VEH_Train &&
|
||||||
IsTileOwner(tile, _local_player) &&
|
IsTileOwner(tile, _local_player) &&
|
||||||
(_m[tile].m5 & 0xFE) == 0xC4) {
|
IsRailWaypoint(tile)) {
|
||||||
order.type = OT_GOTO_WAYPOINT;
|
order.type = OT_GOTO_WAYPOINT;
|
||||||
order.flags = 0;
|
order.flags = 0;
|
||||||
order.station = GetWaypointByTile(tile)->index;
|
order.station = GetWaypointByTile(tile)->index;
|
||||||
|
|
9
pbs.c
9
pbs.c
|
@ -10,6 +10,7 @@
|
||||||
#include "npf.h"
|
#include "npf.h"
|
||||||
#include "pathfind.h"
|
#include "pathfind.h"
|
||||||
#include "depot.h"
|
#include "depot.h"
|
||||||
|
#include "waypoint.h"
|
||||||
|
|
||||||
/** @file pbs.c Path-Based-Signalling implementation file
|
/** @file pbs.c Path-Based-Signalling implementation file
|
||||||
* @see pbs.h */
|
* @see pbs.h */
|
||||||
|
@ -52,7 +53,7 @@ void PBSReserveTrack(TileIndex tile, Track track) {
|
||||||
assert(track <= 5);
|
assert(track <= 5);
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if ((_m[tile].m5 & ~1) == 0xC4) {
|
if (IsRailWaypoint(tile)) {
|
||||||
// waypoint
|
// waypoint
|
||||||
SETBIT(_m[tile].m3, 6);
|
SETBIT(_m[tile].m3, 6);
|
||||||
} else {
|
} else {
|
||||||
|
@ -90,7 +91,7 @@ byte PBSTileReserved(TileIndex tile) {
|
||||||
assert(IsValidTile(tile));
|
assert(IsValidTile(tile));
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if ((_m[tile].m5 & ~1) == 0xC4) {
|
if (IsRailWaypoint(tile)) {
|
||||||
// waypoint
|
// waypoint
|
||||||
// check if its reserved
|
// check if its reserved
|
||||||
if (!HASBIT(_m[tile].m3, 6)) return 0;
|
if (!HASBIT(_m[tile].m3, 6)) return 0;
|
||||||
|
@ -125,7 +126,7 @@ uint16 PBSTileUnavail(TileIndex tile) {
|
||||||
assert(IsValidTile(tile));
|
assert(IsValidTile(tile));
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if ((_m[tile].m5 & ~1) == 0xC4) {
|
if (IsRailWaypoint(tile)) {
|
||||||
// waypoint
|
// waypoint
|
||||||
return HASBIT(_m[tile].m3, 6) ? TRACKDIR_BIT_MASK : 0;
|
return HASBIT(_m[tile].m3, 6) ? TRACKDIR_BIT_MASK : 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,7 +154,7 @@ void PBSClearTrack(TileIndex tile, Track track) {
|
||||||
assert(track <= 5);
|
assert(track <= 5);
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if ((_m[tile].m5 & ~1) == 0xC4) {
|
if (IsRailWaypoint(tile)) {
|
||||||
// waypoint
|
// waypoint
|
||||||
CLRBIT(_m[tile].m3, 6);
|
CLRBIT(_m[tile].m3, 6);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1491,7 +1491,7 @@ static void DrawTile_Track(TileInfo *ti)
|
||||||
|
|
||||||
if (ti->tileh != 0) DrawFoundation(ti, ti->tileh);
|
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
|
// look for customization
|
||||||
const StationSpec *stat = GetCustomStation(STAT_CLASS_WAYP, _m[ti->tile].m4 + 1);
|
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)) {
|
if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
|
||||||
ShowTrainDepotWindow(tile);
|
ShowTrainDepotWindow(tile);
|
||||||
} else if (IsRailWaypoint(_m[tile].m5)) {
|
} else if (IsRailWaypoint(tile)) {
|
||||||
ShowRenameWaypointWindow(GetWaypointByTile(tile));
|
ShowRenameWaypointWindow(GetWaypointByTile(tile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
|
|
||||||
/* Make sure it's a waypoint */
|
/* 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;
|
return CMD_ERROR;
|
||||||
|
|
||||||
if (!CheckTileOwnership(tile) && !(_current_player == OWNER_WATER))
|
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_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)
|
#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);
|
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
|
||||||
|
|
Loading…
Reference in New Issue