1
0
Fork 0

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

release/0.5
celestar 2006-04-04 11:35:52 +00:00
parent cc0ffe6582
commit 8b151d8faa
5 changed files with 23 additions and 22 deletions

2
npf.c
View File

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

4
rail.c
View File

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

View File

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

View File

@ -198,20 +198,6 @@ uint GetNumRoadStops(const Station* st, RoadStopType type);
RoadStop * AllocateRoadStop( void ); RoadStop * AllocateRoadStop( void );
void ClearSlot(Vehicle *v); 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. * 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... */ 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 */ #endif /* STATION_H */

View File

@ -71,6 +71,20 @@ static inline bool IsRailwayStation(TileIndex t)
return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE; 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) static inline bool IsHangar(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION)); 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; 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) static inline bool IsHangarTile(TileIndex t)
{ {