(svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
celestar 18 years ago
parent cc0ffe6582
commit 8b151d8faa

@ -457,7 +457,7 @@ static void NPFSaveTargetData(AyStar* as, OpenListNode* current)
static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enterdir)
{
if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */
IsTrainStationTile(tile) || /* Rail station tile */
IsRailwayStationTile(tile) || /* Rail station tile */
IsTileDepotType(tile, TRANSPORT_ROAD) || /* Road depot tile */
IsRoadStopTile(tile) || /* Road station tile */
IsTileDepotType(tile, TRANSPORT_WATER)) { /* Water depot tile */

@ -4,7 +4,7 @@
#include "openttd.h"
#include "bridge_map.h"
#include "rail.h"
#include "station.h"
#include "station_map.h"
#include "tunnel_map.h"
/* XXX: Below 3 tables store duplicate data. Maybe remove some? */
@ -119,7 +119,7 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir)
break;
case MP_STATION:
if (IsTrainStationTile(tile)) return GetRailType(tile);
if (IsRailwayStationTile(tile)) return GetRailType(tile);
break;
case MP_TUNNELBRIDGE:

@ -9,6 +9,7 @@
#include "vehicle.h"
#include "command.h"
#include "pathfind.h"
#include "station_map.h"
#include "station.h"
#include "news.h"
#include "engine.h"

@ -198,20 +198,6 @@ uint GetNumRoadStops(const Station* st, RoadStopType type);
RoadStop * AllocateRoadStop( void );
void ClearSlot(Vehicle *v);
static inline bool IsTrainStationTile(TileIndex tile)
{
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0, 8);
}
static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref)
{
assert(IsTrainStationTile(ref));
return
IsTrainStationTile(tile) &&
GB(_m[tile].m3, 0, 4) == GB(_m[ref].m3, 0, 4) && // same rail type?
GB(_m[tile].m5, 0, 1) == GB(_m[ref].m5, 0, 1); // same direction?
}
/**
* Check if a station really exists.
*/
@ -225,9 +211,4 @@ static inline bool IsBuoy(const Station* st)
return st->had_vehicle_of_type & HVOT_BUOY; /* XXX: We should really ditch this ugly coding and switch to something sane... */
}
static inline bool IsBuoyTile(TileIndex tile)
{
return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52;
}
#endif /* STATION_H */

@ -71,6 +71,20 @@ static inline bool IsRailwayStation(TileIndex t)
return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE;
}
static inline bool IsRailwayStationTile(TileIndex t)
{
return IsTileType(t, MP_STATION) && IsRailwayStation(t);
}
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
{
assert(IsRailwayStationTile(t2));
return
IsRailwayStationTile(t1) &&
GB(_m[t1].m3, 0, 4) == GB(_m[t2].m3, 0, 4) && // same rail type?
GB(_m[t1].m5, 0, 1) == GB(_m[t2].m5, 0, 1); // same direction?
}
static inline bool IsHangar(TileIndex t)
{
assert(IsTileType(t, MP_STATION));
@ -137,6 +151,11 @@ static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
return _m[t].m5 == BUOY_BASE;
}
static inline bool IsBuoyTile(TileIndex t)
{
return IsTileType(t, MP_STATION) && IsBuoy_(t);
}
static inline bool IsHangarTile(TileIndex t)
{

Loading…
Cancel
Save