(svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
--- a/npf.c Tue Apr 04 06:25:05 2006 +0000
+++ b/npf.c Tue Apr 04 11:35:52 2006 +0000
@@ -457,7 +457,7 @@
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 */
--- a/rail.c Tue Apr 04 06:25:05 2006 +0000
+++ b/rail.c Tue Apr 04 11:35:52 2006 +0000
@@ -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 @@
break;
case MP_STATION:
- if (IsTrainStationTile(tile)) return GetRailType(tile);
+ if (IsRailwayStationTile(tile)) return GetRailType(tile);
break;
case MP_TUNNELBRIDGE:
--- a/ship_cmd.c Tue Apr 04 06:25:05 2006 +0000
+++ b/ship_cmd.c Tue Apr 04 11:35:52 2006 +0000
@@ -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"
--- a/station.h Tue Apr 04 06:25:05 2006 +0000
+++ b/station.h Tue Apr 04 11:35:52 2006 +0000
@@ -198,20 +198,6 @@
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 @@
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 */
--- a/station_map.h Tue Apr 04 06:25:05 2006 +0000
+++ b/station_map.h Tue Apr 04 11:35:52 2006 +0000
@@ -71,6 +71,20 @@
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 @@
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)
{