summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-04-12 20:01:52 +0000
committerbelugas <belugas@openttd.org>2006-04-12 20:01:52 +0000
commitb505564ee7ceb253bf5ff53d52ce38bb952a70c3 (patch)
treec21755754658acd47d65351b220f3769bae863e3
parentc26601eabd3fdec8d6a32c4b8d3f0c1c6b26223e (diff)
downloadopenttd-b505564ee7ceb253bf5ff53d52ce38bb952a70c3.tar.xz
(svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
-rw-r--r--station_cmd.c30
-rw-r--r--station_map.h67
2 files changed, 47 insertions, 50 deletions
diff --git a/station_cmd.c b/station_cmd.c
index 7e60b7d4c..4ae6e5533 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2066,7 +2066,7 @@ static void TileLoop_Station(TileIndex tile)
{
// FIXME -- GetTileTrackStatus_Station -> animated stationtiles
// hardcoded.....not good
- switch (_m[tile].m5) {
+ switch (GetStationGfx(tile)) {
case 0x27: // large big airport
case 0x3A: // flag small airport
case 0x5A: // radar international airport
@@ -2086,41 +2086,41 @@ static void TileLoop_Station(TileIndex tile)
static void AnimateTile_Station(TileIndex tile)
{
- byte m5 = _m[tile].m5;
+ byte gfx = GetStationGfx(tile);
//FIXME -- AnimateTile_Station -> not nice code, lots of things double
// again hardcoded...was a quick hack
// turning radar / windsack on airport
- if (m5 >= 39 && m5 <= 50) { // turning radar (39 - 50)
+ if (gfx >= 39 && gfx <= 50) { // turning radar (39 - 50)
if (_tick_counter & 3)
return;
- if (++m5 == 50+1)
- m5 = 39;
+ if (++gfx == 50+1)
+ gfx = 39;
- _m[tile].m5 = m5;
+ SetStationGfx(tile, gfx);
MarkTileDirtyByTile(tile);
//added - begin
- } else if (m5 >= 90 && m5 <= 113) { // turning radar with ground under it (different fences) (90 - 101 | 102 - 113)
+ } else if (gfx >= 90 && gfx <= 113) { // turning radar with ground under it (different fences) (90 - 101 | 102 - 113)
if (_tick_counter & 3)
return;
- m5++;
+ gfx++;
- if (m5 == 101+1) {m5 = 90;} // radar with fences in south
- else if (m5 == 113+1) {m5 = 102;} // radar with fences in north
+ if (gfx == 101+1) {gfx = 90;} // radar with fences in south
+ else if (gfx == 113+1) {gfx = 102;} // radar with fences in north
- _m[tile].m5 = m5;
+ SetStationGfx(tile, gfx);
MarkTileDirtyByTile(tile);
//added - end
- } else if (m5 >= 0x3A && m5 <= 0x3D) { // windsack (58 - 61)
+ } else if (gfx >= 0x3A && gfx <= 0x3D) { // windsack (58 - 61)
if (_tick_counter & 1)
return;
- if (++m5 == 0x3D+1)
- m5 = 0x3A;
+ if (++gfx == 0x3D+1)
+ gfx = 0x3A;
- _m[tile].m5 = m5;
+ SetStationGfx(tile, gfx);
MarkTileDirtyByTile(tile);
}
}
diff --git a/station_map.h b/station_map.h
index 56cd8d7b0..fe9d5a805 100644
--- a/station_map.h
+++ b/station_map.h
@@ -65,10 +65,21 @@ static inline RoadStopType GetRoadStopType(TileIndex t)
return GetStationType(t) == STATION_TRUCK ? RS_TRUCK : RS_BUS;
}
-static inline bool IsRailwayStation(TileIndex t)
+static inline byte GetStationGfx(TileIndex t)
+{
+ assert(IsTileType(t, MP_STATION));
+ return _m[t].m5;
+}
+
+static inline void SetStationGfx(TileIndex t, byte gfx)
{
assert(IsTileType(t, MP_STATION));
- return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE;
+ _m[t].m5 = gfx;
+}
+
+static inline bool IsRailwayStation(TileIndex t)
+{
+ return GetStationGfx(t) < RAILWAY_BASE + RAILWAY_SIZE;
}
static inline bool IsRailwayStationTile(TileIndex t)
@@ -78,31 +89,29 @@ static inline bool IsRailwayStationTile(TileIndex t)
static inline bool IsHangar(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
+ byte gfx = GetStationGfx(t);
return
- _m[t].m5 == HANGAR_TILE_0 ||
- _m[t].m5 == HANGAR_TILE_1 ||
- _m[t].m5 == HANGAR_TILE_2;
+ gfx == HANGAR_TILE_0 ||
+ gfx == HANGAR_TILE_1 ||
+ gfx == HANGAR_TILE_2;
}
static inline bool IsAirport(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
+ byte gfx = GetStationGfx(t);
return
- IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE, AIRPORT_BASE + AIRPORT_SIZE) ||
- IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE_EXTENDED, AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED);
+ IS_INT_INSIDE(gfx, AIRPORT_BASE, AIRPORT_BASE + AIRPORT_SIZE) ||
+ IS_INT_INSIDE(gfx, AIRPORT_BASE_EXTENDED, AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED);
}
static inline bool IsTruckStop(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
- return IS_INT_INSIDE(_m[t].m5, TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE);
+ return IS_INT_INSIDE(GetStationGfx(t), TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE);
}
static inline bool IsBusStop(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
- return IS_INT_INSIDE(_m[t].m5, BUS_BASE, BUS_BASE + BUS_SIZE);
+ return IS_INT_INSIDE(GetStationGfx(t), BUS_BASE, BUS_BASE + BUS_SIZE);
}
static inline bool IsRoadStop(TileIndex t)
@@ -118,28 +127,25 @@ static inline bool IsRoadStopTile(TileIndex t)
/**
* Gets the direction the road stop entrance points towards.
*/
-static inline DiagDirection GetRoadStopDir(TileIndex tile)
+static inline DiagDirection GetRoadStopDir(TileIndex t)
{
- assert(IsRoadStopTile(tile));
- return (_m[tile].m5 - TRUCK_BASE) & 3;
+ assert(IsRoadStopTile(t));
+ return (GetStationGfx(t) - TRUCK_BASE) & 3;
}
static inline bool IsOilRig(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
- return _m[t].m5 == OILRIG_BASE;
+ return GetStationGfx(t) == OILRIG_BASE;
}
static inline bool IsDock(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
- return IS_INT_INSIDE(_m[t].m5, DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL);
+ return IS_INT_INSIDE(GetStationGfx(t), DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL);
}
static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
{
- assert(IsTileType(t, MP_STATION));
- return _m[t].m5 == BUOY_BASE;
+ return GetStationGfx(t) == BUOY_BASE;
}
static inline bool IsBuoyTile(TileIndex t)
@@ -156,8 +162,7 @@ static inline bool IsHangarTile(TileIndex t)
static inline Axis GetRailStationAxis(TileIndex t)
{
- assert(IsRailwayStation(t));
- return HASBIT(_m[t].m5, 0) ? AXIS_Y : AXIS_X;
+ return HASBIT(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
}
@@ -178,10 +183,9 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
static inline DiagDirection GetDockDirection(TileIndex t)
{
- assert(IsTileType(t, MP_STATION));
- assert(_m[t].m5 < DOCK_BASE_WATER_PART);
-
- return (DiagDirection)(_m[t].m5 - DOCK_BASE);
+ byte gfx = GetStationGfx(t);
+ assert(gfx < DOCK_BASE_WATER_PART);
+ return (DiagDirection)(gfx - DOCK_BASE);
}
static inline TileIndexDiffC GetDockOffset(TileIndex t)
@@ -223,13 +227,6 @@ static inline uint GetCustomStationSprite(TileIndex t)
return _m[t].m4;
}
-static inline byte GetStationGfx(TileIndex t)
-{
- assert(IsTileType(t, MP_STATION));
- return _m[t].m5;
-}
-
-
static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
{
SetTileType(t, MP_STATION);