(svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency

pull/155/head
celestar 18 years ago
parent bb8bdcb5d9
commit 2ab5b8e666

@ -617,7 +617,7 @@ static void AiNew_State_FindStation(Player *p)
if (AiNew_CheckVehicleStation(p, st)) {
// We did found a station that was good enough!
new_tile = st->xy;
direction = GetRoadStationDir(st->xy);
direction = GetRoadStopDir(st->xy);
break;
}
}

14
npf.c

@ -459,7 +459,7 @@ static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enter
if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */
IsTrainStationTile(tile) || /* Rail station tile */
IsTileDepotType(tile, TRANSPORT_ROAD) || /* Road depot tile */
IsRoadStationTile(tile) || /* Road station tile */
IsRoadStopTile(tile) || /* Road station tile */
IsTileDepotType(tile, TRANSPORT_WATER)) { /* Water depot tile */
return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
}
@ -533,15 +533,15 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
* otherwise we wouldn't have got here. It is also facing us,
* so we should skip it's body */
dst_tile = GetOtherTunnelEnd(src_tile);
} else if (type != TRANSPORT_WATER && (IsRoadStationTile(src_tile) || IsTileDepotType(src_tile, type))) {
} else if (type != TRANSPORT_WATER && (IsRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) {
/* This is a road station or a train or road depot. We can enter and exit
* those from one side only. Trackdirs don't support that (yet), so we'll
* do this here. */
DiagDirection exitdir;
/* Find out the exit direction first */
if (IsRoadStationTile(src_tile)) {
exitdir = GetRoadStationDir(src_tile);
if (IsRoadStopTile(src_tile)) {
exitdir = GetRoadStopDir(src_tile);
} else { /* Train or road depot */
exitdir = GetDepotDirection(src_tile, type);
}
@ -597,11 +597,11 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
}
/* Determine available tracks */
if (type != TRANSPORT_WATER && (IsRoadStationTile(dst_tile) || IsTileDepotType(dst_tile, type))){
if (type != TRANSPORT_WATER && (IsRoadStopTile(dst_tile) || IsTileDepotType(dst_tile, type))){
/* Road stations and road and train depots return 0 on GTTS, so we have to do this by hand... */
DiagDirection exitdir;
if (IsRoadStationTile(dst_tile)) {
exitdir = GetRoadStationDir(dst_tile);
if (IsRoadStopTile(dst_tile)) {
exitdir = GetRoadStopDir(dst_tile);
} else { /* Road or train depot */
exitdir = GetDepotDirection(dst_tile, type);
}

@ -7,6 +7,7 @@
#include "road_map.h"
#include "station.h"
#include "tunnel_map.h"
#include "station_map.h"
RoadBits GetAnyRoadBits(TileIndex tile)
@ -21,8 +22,8 @@ RoadBits GetAnyRoadBits(TileIndex tile)
}
case MP_STATION:
if (!IsRoadStationTile(tile)) return 0;
return DiagDirToRoadBits(GetRoadStationDir(tile));
if (!IsRoadStopTile(tile)) return 0;
return DiagDirToRoadBits(GetRoadStopDir(tile));
case MP_TUNNELBRIDGE:
if (IsBridge(tile)) {

@ -1012,7 +1012,7 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
/* Road depot */
bitmask |= _road_veh_fp_ax_or[GetRoadDepotDirection(tile)];
}
} else if (IsTileType(tile, MP_STATION) && IsRoadStationTile(tile)) {
} else if (IsTileType(tile, MP_STATION) && IsRoadStopTile(tile)) {
if (IsTileOwner(tile, v->owner)) {
/* Our station */
RoadStopType rstype = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK;
@ -1021,7 +1021,7 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
const RoadStop *rs = GetRoadStopByTile(tile, rstype);
if (rs != NULL && (_patches.roadveh_queue || GB(rs->status, 0, 2) != 0)) {
bitmask |= _road_veh_fp_ax_or[GetRoadStationDir(tile)];
bitmask |= _road_veh_fp_ax_or[GetRoadStopDir(tile)];
}
}
}
@ -1089,7 +1089,7 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
}
} else if (IsTileType(desttile, MP_STATION)) {
if (IsRoadStop(desttile)) {
dir = GetRoadStationDir(desttile);
dir = GetRoadStopDir(desttile);
do_it:;
/* When we are heading for a depot or station, we just
* pretend we are heading for the tile in front, we'll

@ -213,10 +213,6 @@ static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref)
GB(_m[tile].m5, 0, 1) == GB(_m[ref].m5, 0, 1); // same direction?
}
static inline bool IsRoadStationTile(TileIndex tile) {
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0x43, 0x4B);
}
/**
* Check if a station really exists.
*/
@ -235,13 +231,4 @@ static inline bool IsBuoyTile(TileIndex tile)
return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52;
}
/**
* Get's the direction the road stop entrance points towards.
*/
static inline DiagDirection GetRoadStationDir(TileIndex tile)
{
assert(IsRoadStationTile(tile));
return (_m[tile].m5 - 0x43) & 3;
}
#endif /* STATION_H */

@ -105,6 +105,20 @@ static inline bool IsRoadStop(TileIndex t)
return IsTruckStop(t) || IsBusStop(t);
}
static inline bool IsRoadStopTile(TileIndex t)
{
return IsTileType(t, MP_STATION) && IsRoadStop(t);
}
/**
* Gets the direction the road stop entrance points towards.
*/
static inline DiagDirection GetRoadStopDir(TileIndex tile)
{
assert(IsRoadStopTile(tile));
return (_m[tile].m5 - TRUCK_BASE) & 3;
}
static inline bool IsOilRig(TileIndex t)
{
assert(IsTileType(t, MP_STATION));

@ -23,6 +23,7 @@
#include "station.h"
#include "rail.h"
#include "train.h"
#include "station_map.h"
#define INVALID_COORD (-0x8000)
#define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
@ -1988,8 +1989,8 @@ Trackdir GetVehicleTrackdir(const Vehicle* v)
if (v->u.road.state == 254) /* We'll assume the road vehicle is facing outwards */
return DiagdirToDiagTrackdir(GetRoadDepotDirection(v->tile));
if (IsRoadStationTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
return DiagdirToDiagTrackdir(GetRoadStationDir(v->tile)); /* Road vehicle in a station */
if (IsRoadStopTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); /* Road vehicle in a station */
return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));

Loading…
Cancel
Save