mirror of https://github.com/OpenTTD/OpenTTD
(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
parent
c26601eabd
commit
b505564ee7
|
@ -2066,7 +2066,7 @@ static void TileLoop_Station(TileIndex tile)
|
||||||
{
|
{
|
||||||
// FIXME -- GetTileTrackStatus_Station -> animated stationtiles
|
// FIXME -- GetTileTrackStatus_Station -> animated stationtiles
|
||||||
// hardcoded.....not good
|
// hardcoded.....not good
|
||||||
switch (_m[tile].m5) {
|
switch (GetStationGfx(tile)) {
|
||||||
case 0x27: // large big airport
|
case 0x27: // large big airport
|
||||||
case 0x3A: // flag small airport
|
case 0x3A: // flag small airport
|
||||||
case 0x5A: // radar international airport
|
case 0x5A: // radar international airport
|
||||||
|
@ -2086,41 +2086,41 @@ static void TileLoop_Station(TileIndex tile)
|
||||||
|
|
||||||
static void AnimateTile_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
|
//FIXME -- AnimateTile_Station -> not nice code, lots of things double
|
||||||
// again hardcoded...was a quick hack
|
// again hardcoded...was a quick hack
|
||||||
|
|
||||||
// turning radar / windsack on airport
|
// 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)
|
if (_tick_counter & 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (++m5 == 50+1)
|
if (++gfx == 50+1)
|
||||||
m5 = 39;
|
gfx = 39;
|
||||||
|
|
||||||
_m[tile].m5 = m5;
|
SetStationGfx(tile, gfx);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
//added - begin
|
//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)
|
if (_tick_counter & 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m5++;
|
gfx++;
|
||||||
|
|
||||||
if (m5 == 101+1) {m5 = 90;} // radar with fences in south
|
if (gfx == 101+1) {gfx = 90;} // radar with fences in south
|
||||||
else if (m5 == 113+1) {m5 = 102;} // radar with fences in north
|
else if (gfx == 113+1) {gfx = 102;} // radar with fences in north
|
||||||
|
|
||||||
_m[tile].m5 = m5;
|
SetStationGfx(tile, gfx);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
//added - end
|
//added - end
|
||||||
} else if (m5 >= 0x3A && m5 <= 0x3D) { // windsack (58 - 61)
|
} else if (gfx >= 0x3A && gfx <= 0x3D) { // windsack (58 - 61)
|
||||||
if (_tick_counter & 1)
|
if (_tick_counter & 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (++m5 == 0x3D+1)
|
if (++gfx == 0x3D+1)
|
||||||
m5 = 0x3A;
|
gfx = 0x3A;
|
||||||
|
|
||||||
_m[tile].m5 = m5;
|
SetStationGfx(tile, gfx);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,21 @@ static inline RoadStopType GetRoadStopType(TileIndex t)
|
||||||
return GetStationType(t) == STATION_TRUCK ? RS_TRUCK : RS_BUS;
|
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));
|
assert(IsTileType(t, MP_STATION));
|
||||||
return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE;
|
return _m[t].m5;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void SetStationGfx(TileIndex t, byte gfx)
|
||||||
|
{
|
||||||
|
assert(IsTileType(t, MP_STATION));
|
||||||
|
_m[t].m5 = gfx;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool IsRailwayStation(TileIndex t)
|
||||||
|
{
|
||||||
|
return GetStationGfx(t) < RAILWAY_BASE + RAILWAY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsRailwayStationTile(TileIndex t)
|
static inline bool IsRailwayStationTile(TileIndex t)
|
||||||
|
@ -78,31 +89,29 @@ static inline bool IsRailwayStationTile(TileIndex t)
|
||||||
|
|
||||||
static inline bool IsHangar(TileIndex t)
|
static inline bool IsHangar(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
byte gfx = GetStationGfx(t);
|
||||||
return
|
return
|
||||||
_m[t].m5 == HANGAR_TILE_0 ||
|
gfx == HANGAR_TILE_0 ||
|
||||||
_m[t].m5 == HANGAR_TILE_1 ||
|
gfx == HANGAR_TILE_1 ||
|
||||||
_m[t].m5 == HANGAR_TILE_2;
|
gfx == HANGAR_TILE_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsAirport(TileIndex t)
|
static inline bool IsAirport(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
byte gfx = GetStationGfx(t);
|
||||||
return
|
return
|
||||||
IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE, AIRPORT_BASE + AIRPORT_SIZE) ||
|
IS_INT_INSIDE(gfx, 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_EXTENDED, AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsTruckStop(TileIndex t)
|
static inline bool IsTruckStop(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
return IS_INT_INSIDE(GetStationGfx(t), TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE);
|
||||||
return IS_INT_INSIDE(_m[t].m5, TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsBusStop(TileIndex t)
|
static inline bool IsBusStop(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
return IS_INT_INSIDE(GetStationGfx(t), BUS_BASE, BUS_BASE + BUS_SIZE);
|
||||||
return IS_INT_INSIDE(_m[t].m5, BUS_BASE, BUS_BASE + BUS_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsRoadStop(TileIndex t)
|
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.
|
* Gets the direction the road stop entrance points towards.
|
||||||
*/
|
*/
|
||||||
static inline DiagDirection GetRoadStopDir(TileIndex tile)
|
static inline DiagDirection GetRoadStopDir(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsRoadStopTile(tile));
|
assert(IsRoadStopTile(t));
|
||||||
return (_m[tile].m5 - TRUCK_BASE) & 3;
|
return (GetStationGfx(t) - TRUCK_BASE) & 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsOilRig(TileIndex t)
|
static inline bool IsOilRig(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
return GetStationGfx(t) == OILRIG_BASE;
|
||||||
return _m[t].m5 == OILRIG_BASE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsDock(TileIndex t)
|
static inline bool IsDock(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
return IS_INT_INSIDE(GetStationGfx(t), DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL);
|
||||||
return IS_INT_INSIDE(_m[t].m5, DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
|
static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
return GetStationGfx(t) == BUOY_BASE;
|
||||||
return _m[t].m5 == BUOY_BASE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsBuoyTile(TileIndex t)
|
static inline bool IsBuoyTile(TileIndex t)
|
||||||
|
@ -156,8 +162,7 @@ static inline bool IsHangarTile(TileIndex t)
|
||||||
|
|
||||||
static inline Axis GetRailStationAxis(TileIndex t)
|
static inline Axis GetRailStationAxis(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsRailwayStation(t));
|
return HASBIT(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
|
||||||
return HASBIT(_m[t].m5, 0) ? AXIS_Y : AXIS_X;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,10 +183,9 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
|
||||||
|
|
||||||
static inline DiagDirection GetDockDirection(TileIndex t)
|
static inline DiagDirection GetDockDirection(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsTileType(t, MP_STATION));
|
byte gfx = GetStationGfx(t);
|
||||||
assert(_m[t].m5 < DOCK_BASE_WATER_PART);
|
assert(gfx < DOCK_BASE_WATER_PART);
|
||||||
|
return (DiagDirection)(gfx - DOCK_BASE);
|
||||||
return (DiagDirection)(_m[t].m5 - DOCK_BASE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TileIndexDiffC GetDockOffset(TileIndex t)
|
static inline TileIndexDiffC GetDockOffset(TileIndex t)
|
||||||
|
@ -223,13 +227,6 @@ static inline uint GetCustomStationSprite(TileIndex t)
|
||||||
return _m[t].m4;
|
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)
|
static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
|
||||||
{
|
{
|
||||||
SetTileType(t, MP_STATION);
|
SetTileType(t, MP_STATION);
|
||||||
|
|
Loading…
Reference in New Issue