summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_station.cpp2
-rw-r--r--src/oldloader.cpp11
-rw-r--r--src/openttd.cpp63
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/rail_gui.cpp4
-rw-r--r--src/road_gui.cpp18
-rw-r--r--src/saveload.cpp2
-rw-r--r--src/station.h14
-rw-r--r--src/station_cmd.cpp37
-rw-r--r--src/station_map.cpp26
-rw-r--r--src/station_map.h153
-rw-r--r--src/table/station_land.h62
12 files changed, 208 insertions, 186 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index e54bbeb64..7e2e40c9b 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -757,7 +757,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
}
if (statspec->renderdata == NULL) {
- sprites = GetStationTileLayout(tile + axis);
+ sprites = GetStationTileLayout(STATION_RAIL, tile + axis);
} else {
sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis];
}
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 7cadd82d5..09d949300 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1578,12 +1578,11 @@ static bool LoadOldMain(LoadgameState *ls)
_m[i].m4 = 0; // We do not understand this TTDP station mapping (yet)
switch (_m[i].m5) {
/* We have drive through stops at a totally different place */
- case 0x53: case 0x54: _m[i].m5 += GFX_BUS_BASE_EXT - 0x53; break;
- case 0x57: case 0x58: _m[i].m5 += GFX_TRUCK_BASE_EXT - 0x57; break;
- case 0x55: case 0x56: // Bus tram stop
- case 0x59: case 0x5A: // Truck tram stop
- DEBUG(oldloader, 0, "Loading failed - we don't support trams (yet)");
- return false;
+ case 0x53: case 0x54: _m[i].m5 += 170 - 0x53; break; // Bus drive through
+ case 0x57: case 0x58: _m[i].m5 += 168 - 0x57; break; // Truck drive through
+ case 0x55: case 0x56: _m[i].m5 += 170 - 0x55; break; // Bus tram stop
+ case 0x59: case 0x5A: _m[i].m5 += 168 - 0x59; break; // Truck tram stop
+ default: break;
}
break;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index b57357ac8..53547997c 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1358,6 +1358,59 @@ bool AfterLoadGame()
DoZoomInOutWindow(ZOOM_NONE, w); // update button status
MarkWholeScreenDirty();
+ if (CheckSavegameVersion(72)) {
+ /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */
+ for (TileIndex t = 0; t < MapSize(); t++) {
+ switch (GetTileType(t)) {
+ default: break;
+
+ case MP_WATER:
+ if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
+ break;
+
+ case MP_STATION: {
+ if (HASBIT(_m[t].m6, 3)) SETBIT(_m[t].m6, 2);
+ StationGfx gfx = GetStationGfx(t);
+ StationType st;
+ if ( IS_INT_INSIDE(gfx, 0, 8)) { // Railway station
+ st = STATION_RAIL;
+ SetStationGfx(t, gfx - 0);
+ } else if (IS_INT_INSIDE(gfx, 8, 67)) { // Airport
+ st = STATION_AIRPORT;
+ SetStationGfx(t, gfx - 8);
+ } else if (IS_INT_INSIDE(gfx, 67, 71)) { // Truck
+ st = STATION_TRUCK;
+ SetStationGfx(t, gfx - 67);
+ } else if (IS_INT_INSIDE(gfx, 71, 75)) { // Bus
+ st = STATION_BUS;
+ SetStationGfx(t, gfx - 71);
+ } else if (gfx == 75) { // Oil rig
+ st = STATION_OILRIG;
+ SetStationGfx(t, gfx - 75);
+ } else if (IS_INT_INSIDE(gfx, 76, 82)) { // Dock
+ st = STATION_DOCK;
+ SetStationGfx(t, gfx - 76);
+ } else if (gfx == 82) { // Buoy
+ st = STATION_BUOY;
+ SetStationGfx(t, gfx - 82);
+ } else if (IS_INT_INSIDE(gfx, 83, 168)) { // Extended airport
+ st = STATION_AIRPORT;
+ SetStationGfx(t, gfx - 83 + 67 - 8);
+ } else if (IS_INT_INSIDE(gfx, 168, 170)) { // Drive through truck
+ st = STATION_TRUCK;
+ SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
+ } else if (IS_INT_INSIDE(gfx, 170, 172)) { // Drive through bus
+ st = STATION_BUS;
+ SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
+ } else {
+ return false;
+ }
+ SB(_m[t].m6, 3, 3, st);
+ } break;
+ }
+ }
+ }
+
for (TileIndex t = 0; t < map_size; t++) {
switch (GetTileType(t)) {
case MP_STATION: {
@@ -2086,16 +2139,6 @@ bool AfterLoadGame()
FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE;
}
- if (CheckSavegameVersion(72)) {
- /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */
- for (TileIndex t = 0; t < MapSize(); t++) {
- if (IsTileType(t, MP_WATER) && GetWaterTileType(t) == WATER_TILE_LOCK &&
- GetTileOwner(t) == OWNER_WATER) {
- SetTileOwner(t, OWNER_NONE);
- }
- }
- }
-
/* Recalculate */
Group *g;
FOR_ALL_GROUPS(g) {
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 61c6cea01..b0cecc0fc 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1469,7 +1469,7 @@ static void DrawTile_Track(TileInfo *ti)
}
if (statspec->renderdata == NULL) {
- dts = GetStationTileLayout(gfx);
+ dts = GetStationTileLayout(STATION_RAIL, gfx);
} else {
dts = &statspec->renderdata[(gfx < statspec->tiles ? gfx : 0) + GetWaypointAxis(ti->tile)];
}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 705768705..d5bc70fa1 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -759,7 +759,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
- StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 2);
+ StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
}
_cur_dpi = old_dpi;
}
@@ -769,7 +769,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
- StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 3);
+ StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
}
_cur_dpi = old_dpi;
}
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 69c54dfeb..1300f45d4 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -554,8 +554,6 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
break;
case WE_PAINT: {
- int image;
-
if (WP(w, def_d).close) return;
DrawWindowWidgets(w);
@@ -567,17 +565,15 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
SetTileSelectSize(1, 1);
}
- image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE;
-
- StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image);
- StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 1);
- StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 2);
- StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 3);
+ StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
- image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT;
+ StationPickerDrawSprite(103, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 0);
+ StationPickerDrawSprite(103, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 1);
+ StationPickerDrawSprite( 35, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 2);
+ StationPickerDrawSprite( 35, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 3);
- StationPickerDrawSprite(171, 35, RAILTYPE_BEGIN, _cur_roadtype, image);
- StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, _cur_roadtype, image + 1);
+ StationPickerDrawSprite(171, 35, st, RAILTYPE_BEGIN, _cur_roadtype, 4);
+ StationPickerDrawSprite(171, 85, st, RAILTYPE_BEGIN, _cur_roadtype, 5);
DrawStationCoverageAreaText(2, 146,
(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
diff --git a/src/saveload.cpp b/src/saveload.cpp
index e5567bf97..01518f061 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -30,7 +30,7 @@
#include <setjmp.h>
#include <list>
-extern const uint16 SAVEGAME_VERSION = 71;
+extern const uint16 SAVEGAME_VERSION = 72;
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
diff --git a/src/station.h b/src/station.h
index 25f77e7d2..c447f2ab7 100644
--- a/src/station.h
+++ b/src/station.h
@@ -185,6 +185,16 @@ protected:
static Station *AllocateRaw();
};
+enum StationType {
+ STATION_RAIL,
+ STATION_AIRPORT,
+ STATION_TRUCK,
+ STATION_BUS,
+ STATION_OILRIG,
+ STATION_DOCK,
+ STATION_BUOY
+};
+
enum {
FACIL_TRAIN = 0x01,
FACIL_TRUCK_STOP = 0x02,
@@ -263,8 +273,8 @@ void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
-const DrawTileSprites *GetStationTileLayout(byte gfx);
-void StationPickerDrawSprite(int x, int y, RailType railtype, RoadType roadtype, int image);
+const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
+void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type);
uint GetNumRoadStops(const Station* st, RoadStop::Type type);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 2f0602e8f..379bac43e 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1658,7 +1658,8 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
const byte *b = _airport_sections[p1];
BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
- MakeAirport(tile_cur, st->owner, st->index, *b++);
+ MakeAirport(tile_cur, st->owner, st->index, *b - ((*b < 67) ? 8 : 24));
+ b++;
} END_TILE_LOOP(tile_cur, w, h, tile)
}
@@ -1966,9 +1967,9 @@ static CommandCost RemoveDock(Station *st, uint32 flags)
#include "table/station_land.h"
-const DrawTileSprites *GetStationTileLayout(byte gfx)
+const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx)
{
- return &_station_display_datas[gfx];
+ return &_station_display_datas[st][gfx];
}
/* For drawing canal edges on buoys */
@@ -2028,7 +2029,7 @@ static void DrawTile_Station(TileInfo *ti)
}
}
- if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
+ if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)];
SpriteID image = t->ground_sprite;
if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) {
@@ -2084,11 +2085,11 @@ static void DrawTile_Station(TileInfo *ti)
}
}
-void StationPickerDrawSprite(int x, int y, RailType railtype, RoadType roadtype, int image)
+void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
{
const RailtypeInfo *rti = GetRailTypeInfo(railtype);
SpriteID pal = PLAYER_SPRITE_COLOR(_local_player);
- const DrawTileSprites *t = &_station_display_datas[image];
+ const DrawTileSprites *t = &_station_display_datas[st][image];
SpriteID img = t->ground_sprite;
DrawSprite(img + rti->total_offset, HASBIT(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y);
@@ -2180,18 +2181,22 @@ static void TileLoop_Station(TileIndex tile)
{
// FIXME -- GetTileTrackStatus_Station -> animated stationtiles
// hardcoded.....not good
- switch (GetStationGfx(tile)) {
- case GFX_RADAR_LARGE_FIRST:
- case GFX_WINDSACK_FIRST : // for small airport
- case GFX_RADAR_INTERNATIONAL_FIRST:
- case GFX_RADAR_METROPOLITAN_FIRST:
- case GFX_RADAR_DISTRICTWE_FIRST: // radar district W-E airport
- case GFX_WINDSACK_INTERCON_FIRST : // for intercontinental airport
- AddAnimatedTile(tile);
+ switch (GetStationType(tile)) {
+ case STATION_AIRPORT:
+ switch (GetStationGfx(tile)) {
+ case GFX_RADAR_LARGE_FIRST:
+ case GFX_WINDSACK_FIRST : // for small airport
+ case GFX_RADAR_INTERNATIONAL_FIRST:
+ case GFX_RADAR_METROPOLITAN_FIRST:
+ case GFX_RADAR_DISTRICTWE_FIRST: // radar district W-E airport
+ case GFX_WINDSACK_INTERCON_FIRST : // for intercontinental airport
+ AddAnimatedTile(tile);
+ break;
+ }
break;
- case GFX_OILRIG_BASE: //(station part)
- case GFX_BUOY_BASE:
+ case STATION_OILRIG: //(station part)
+ case STATION_BUOY:
TileLoop_Water(tile);
break;
diff --git a/src/station_map.cpp b/src/station_map.cpp
deleted file mode 100644
index d1552a082..000000000
--- a/src/station_map.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/* $Id$ */
-
-/** @file station_map.cpp */
-
-#include "stdafx.h"
-#include "openttd.h"
-#include "station_map.h"
-
-/**
- * Get the station type (rail, airport, truck etc) for the given tile.
- * @param t the tile to get the station type of.
- * @pre IsTileType(t, MP_STATION)
- * @return the station type of the given tile.
- */
-StationType GetStationType(TileIndex t)
-{
- assert(IsTileType(t, MP_STATION));
- if (IsRailwayStation(t)) return STATION_RAIL;
- if (IsAirport(t)) return STATION_AIRPORT;
- if (IsTruckStop(t)) return STATION_TRUCK;
- if (IsBusStop(t)) return STATION_BUS;
- if (IsOilRig(t)) return STATION_OILRIG;
- if (IsDock(t)) return STATION_DOCK;
- assert(IsBuoy(t));
- return STATION_BUOY;
-}
diff --git a/src/station_map.h b/src/station_map.h
index e35b5d8b5..38a0a58d7 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -24,63 +24,37 @@ static inline Station* GetStationByTile(TileIndex t)
enum {
- GFX_RAILWAY_BASE = 0,
- GFX_AIRPORT_BASE = 8,
- GFX_RADAR_LARGE_FIRST = 39,
- GFX_RADAR_LARGE_LAST = 50,
- GFX_WINDSACK_FIRST = 58,
- GFX_WINDSACK_LAST = 61,
- GFX_TRUCK_BASE = 67,
- GFX_BUS_BASE = 71,
- GFX_OILRIG_BASE = 75,
- GFX_DOCK_BASE = 76,
- GFX_DOCK_BASE_WATER_PART = 80,
- GFX_BUOY_BASE = 82,
- GFX_AIRPORT_BASE_EXTENDED = 83,
- GFX_RADAR_INTERNATIONAL_FIRST = 90,
- GFX_RADAR_INTERNATIONAL_LAST = 101,
- GFX_RADAR_METROPOLITAN_FIRST = 102,
- GFX_RADAR_METROPOLITAN_LAST = 113,
- GFX_RADAR_DISTRICTWE_FIRST = 145,
- GFX_RADAR_DISTRICTWE_LAST = 156,
- GFX_WINDSACK_INTERCON_FIRST = 164,
- GFX_WINDSACK_INTERCON_LAST = 167,
- GFX_TRUCK_BASE_EXT = 168,
- GFX_BUS_BASE_EXT = 170,
- GFX_BASE_END = 172
-};
-
-enum {
- RAILWAY_SIZE = GFX_AIRPORT_BASE - GFX_RAILWAY_BASE,
- AIRPORT_SIZE = GFX_TRUCK_BASE - GFX_AIRPORT_BASE,
- TRUCK_SIZE = GFX_BUS_BASE - GFX_TRUCK_BASE,
- BUS_SIZE = GFX_OILRIG_BASE - GFX_BUS_BASE,
- DOCK_SIZE_TOTAL = GFX_BUOY_BASE - GFX_DOCK_BASE,
- AIRPORT_SIZE_EXTENDED = GFX_TRUCK_BASE_EXT - GFX_AIRPORT_BASE_EXTENDED,
- TRUCK_SIZE_EXT = GFX_BUS_BASE_EXT - GFX_TRUCK_BASE_EXT,
- BUS_SIZE_EXT = GFX_BASE_END - GFX_BUS_BASE_EXT,
+ GFX_RADAR_LARGE_FIRST = 31,
+ GFX_RADAR_LARGE_LAST = 42,
+ GFX_WINDSACK_FIRST = 50,
+ GFX_WINDSACK_LAST = 53,
+
+ GFX_DOCK_BASE_WATER_PART = 4,
+ GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4,
+
+ GFX_RADAR_INTERNATIONAL_FIRST = 66,
+ GFX_RADAR_INTERNATIONAL_LAST = 77,
+ GFX_RADAR_METROPOLITAN_FIRST = 78,
+ GFX_RADAR_METROPOLITAN_LAST = 89,
+ GFX_RADAR_DISTRICTWE_FIRST = 121,
+ GFX_RADAR_DISTRICTWE_LAST = 132,
+ GFX_WINDSACK_INTERCON_FIRST = 140,
+ GFX_WINDSACK_INTERCON_LAST = 143,
};
enum HangarTile {
- HANGAR_TILE_0 = 32,
- HANGAR_TILE_1 = 65,
- HANGAR_TILE_2 = 86,
- HANGAR_TILE_3 = 129, // added for west facing hangar
- HANGAR_TILE_4 = 130, // added for north facing hangar
- HANGAR_TILE_5 = 131 // added for east facing hangar
-};
-
-enum StationType {
- STATION_RAIL,
- STATION_AIRPORT,
- STATION_TRUCK,
- STATION_BUS,
- STATION_OILRIG,
- STATION_DOCK,
- STATION_BUOY
+ HANGAR_TILE_0 = 24,
+ HANGAR_TILE_1 = 57,
+ HANGAR_TILE_2 = 62,
+ HANGAR_TILE_3 = 105, // added for west facing hangar
+ HANGAR_TILE_4 = 106, // added for north facing hangar
+ HANGAR_TILE_5 = 107 // added for east facing hangar
};
-StationType GetStationType(TileIndex);
+static inline StationType GetStationType(TileIndex t)
+{
+ return (StationType)GB(_m[t].m6, 3, 3);
+}
static inline RoadStop::Type GetRoadStopType(TileIndex t)
{
@@ -102,7 +76,7 @@ static inline void SetStationGfx(TileIndex t, StationGfx gfx)
static inline bool IsRailwayStation(TileIndex t)
{
- return GetStationGfx(t) < GFX_RAILWAY_BASE + RAILWAY_SIZE;
+ return GetStationType(t) == STATION_RAIL;
}
static inline bool IsRailwayStationTile(TileIndex t)
@@ -110,40 +84,36 @@ static inline bool IsRailwayStationTile(TileIndex t)
return IsTileType(t, MP_STATION) && IsRailwayStation(t);
}
+static inline bool IsAirport(TileIndex t)
+{
+ return GetStationType(t) == STATION_AIRPORT;
+}
+
static inline bool IsHangar(TileIndex t)
{
StationGfx gfx = GetStationGfx(t);
- return
+ return IsAirport(t) && (
gfx == HANGAR_TILE_0 ||
gfx == HANGAR_TILE_1 ||
gfx == HANGAR_TILE_2 ||
gfx == HANGAR_TILE_3 ||
gfx == HANGAR_TILE_4 ||
- gfx == HANGAR_TILE_5;
-}
-
-static inline bool IsAirport(TileIndex t)
-{
- StationGfx gfx = GetStationGfx(t);
- return
- (IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE, GFX_AIRPORT_BASE + AIRPORT_SIZE)) ||
- (IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE_EXTENDED, GFX_AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED));
+ gfx == HANGAR_TILE_5);
}
static inline bool IsTruckStop(TileIndex t)
{
- return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE)) ||
- (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT));
+ return GetStationType(t) == STATION_TRUCK;
}
static inline bool IsBusStop(TileIndex t)
{
- return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE)) ||
- (IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
+ return GetStationType(t) == STATION_BUS;
}
static inline bool IsRoadStop(TileIndex t)
{
+ assert(IsTileType(t, MP_STATION));
return IsTruckStop(t) || IsBusStop(t);
}
@@ -154,22 +124,18 @@ static inline bool IsRoadStopTile(TileIndex t)
static inline bool IsStandardRoadStopTile(TileIndex t)
{
- return IsTileType(t, MP_STATION) &&
- (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE) ||
- IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE));
+ return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
}
static inline bool IsDriveThroughStopTile(TileIndex t)
{
- return IsTileType(t, MP_STATION) &&
- (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT) ||
- IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
+ return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
}
static inline bool GetStopBuiltOnTownRoad(TileIndex t)
{
assert(IsDriveThroughStopTile(t));
- return HASBIT(_m[t].m6, 3);
+ return HASBIT(_m[t].m6, 2);
}
@@ -180,26 +146,26 @@ static inline DiagDirection GetRoadStopDir(TileIndex t)
{
StationGfx gfx = GetStationGfx(t);
assert(IsRoadStopTile(t));
- if (gfx < GFX_TRUCK_BASE_EXT) {
- return (DiagDirection)((gfx - GFX_TRUCK_BASE) & 3);
+ if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
+ return (DiagDirection)(gfx);
} else {
- return (DiagDirection)((gfx - GFX_TRUCK_BASE_EXT) & 1);
+ return (DiagDirection)(gfx - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
}
}
static inline bool IsOilRig(TileIndex t)
{
- return GetStationGfx(t) == GFX_OILRIG_BASE;
+ return GetStationType(t) == STATION_OILRIG;
}
static inline bool IsDock(TileIndex t)
{
- return IS_BYTE_INSIDE(GetStationGfx(t), GFX_DOCK_BASE, GFX_DOCK_BASE + DOCK_SIZE_TOTAL);
+ return GetStationType(t) == STATION_DOCK;
}
static inline bool IsBuoy(TileIndex t)
{
- return GetStationGfx(t) == GFX_BUOY_BASE;
+ return GetStationType(t) == STATION_BUOY;
}
static inline bool IsBuoyTile(TileIndex t)
@@ -240,8 +206,8 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
static inline DiagDirection GetDockDirection(TileIndex t)
{
StationGfx gfx = GetStationGfx(t);
- assert(gfx < GFX_DOCK_BASE_WATER_PART);
- return (DiagDirection)(gfx - GFX_DOCK_BASE);
+ assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
+ return (DiagDirection)(gfx);
}
static inline TileIndexDiffC GetDockOffset(TileIndex t)
@@ -294,38 +260,39 @@ static inline byte GetStationTileRandomBits(TileIndex t)
return GB(_m[t].m3, 4, 4);
}
-static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
+static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section)
{
SetTileType(t, MP_STATION);
SetTileOwner(t, o);
_m[t].m2 = sid;
_m[t].m3 = 0;
_m[t].m4 = 0;
- _m[t].m5 = m5;
+ _m[t].m5 = section;
+ SB(_m[t].m6, 3, 3, st);
}
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
{
- MakeStation(t, o, sid, section + a);
+ MakeStation(t, o, sid, STATION_RAIL, section + a);
SetRailType(t, rt);
}
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, DiagDirection d)
{
- MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
+ MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), d);
SetRoadTypes(t, rt);
}
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, Axis a, bool on_town_road)
{
- MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + a);
- SB(_m[t].m6, 3, 1, on_town_road);
+ MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
+ SB(_m[t].m6, 2, 1, on_town_road);
SetRoadTypes(t, rt);
}
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
{
- MakeStation(t, o, sid, section);
+ MakeStation(t, o, sid, STATION_AIRPORT, section);
}
static inline void MakeBuoy(TileIndex t, StationID sid)
@@ -333,18 +300,18 @@ static inline void MakeBuoy(TileIndex t, StationID sid)
/* Make the owner of the buoy tile the same as the current owner of the
* water tile. In this way, we can reset the owner of the water to its
* original state when the buoy gets removed. */
- MakeStation(t, GetTileOwner(t), sid, GFX_BUOY_BASE);
+ MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0);
}
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d)
{
- MakeStation(t, o, sid, GFX_DOCK_BASE + d);
- MakeStation(t + TileOffsByDiagDir(d), o, sid, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
+ MakeStation(t, o, sid, STATION_DOCK, d);
+ MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
}
static inline void MakeOilrig(TileIndex t, StationID sid)
{
- MakeStation(t, OWNER_NONE, sid, GFX_OILRIG_BASE);
+ MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
}
#endif /* STATION_MAP_H */
diff --git a/src/table/station_land.h b/src/table/station_land.h
index 2d66e48e4..6f955daf3 100644
--- a/src/table/station_land.h
+++ b/src/table/station_land.h
@@ -987,7 +987,7 @@ static const DrawTileSeqStruct _station_display_datas_0171[] = {
TILE_SEQ_END()
};
-static const DrawTileSprites _station_display_datas[] = {
+static const DrawTileSprites _station_display_datas_rail[] = {
{ SPR_RAIL_TRACK_X, PAL_NONE, _station_display_datas_0 },
{ SPR_RAIL_TRACK_Y, PAL_NONE, _station_display_datas_1 },
{ SPR_RAIL_TRACK_X, PAL_NONE, _station_display_datas_2 },
@@ -996,6 +996,9 @@ static const DrawTileSprites _station_display_datas[] = {
{ SPR_RAIL_TRACK_Y, PAL_NONE, _station_display_datas_5 },
{ SPR_RAIL_TRACK_X, PAL_NONE, _station_display_datas_6 },
{ SPR_RAIL_TRACK_Y, PAL_NONE, _station_display_datas_7 },
+};
+
+static const DrawTileSprites _station_display_datas_airport[] = {
{ SPR_AIRPORT_APRON, PAL_NONE, _station_display_nothing },
{ SPR_AIRPORT_APRON, PAL_NONE, _station_display_datas_9 },
{ SPR_AIRPORT_APRON, PAL_NONE, _station_display_datas_10 },
@@ -1055,22 +1058,6 @@ static const DrawTileSprites _station_display_datas[] = {
{ SPR_AIRFIELD_RUNWAY_FAR_END, PAL_NONE, _station_display_datas_64 },
{ SPR_AIRPORT_APRON, PAL_NONE, _station_display_datas_65 },
{ SPR_FLAT_GRASS_TILE, PAL_NONE, _station_display_datas_66 },
- { SPR_TRUCK_STOP_NE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_67 },
- { SPR_TRUCK_STOP_SE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_68 },
- { SPR_TRUCK_STOP_SW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_69 },
- { SPR_TRUCK_STOP_NW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_70 },
- { SPR_BUS_STOP_NE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_71 },
- { SPR_BUS_STOP_SE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_72 },
- { SPR_BUS_STOP_SW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_73 },
- { SPR_BUS_STOP_NW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_74 },
- { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_nothing },
- { SPR_SHORE_TILEH_3, PAL_NONE, _station_display_datas_76 },
- { SPR_SHORE_TILEH_9, PAL_NONE, _station_display_datas_77 },
- { SPR_SHORE_TILEH_12, PAL_NONE, _station_display_datas_78 },
- { SPR_SHORE_TILEH_6, PAL_NONE, _station_display_datas_79 },
- { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_datas_80 },
- { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_datas_81 },
- { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_datas_82 },
{ SPR_AIRPORT_RUNWAY_END, PAL_NONE, _station_display_nothing },
{ SPR_AIRPORT_RUNWAY_EXIT_B, PAL_NONE, _station_display_nothing },
{ SPR_AIRPORT_APRON, PAL_NONE, _station_display_datas_085 },
@@ -1156,8 +1143,49 @@ static const DrawTileSprites _station_display_datas[] = {
{ SPR_FLAT_GRASS_TILE, PAL_NONE, _station_display_datas_59 },
{ SPR_FLAT_GRASS_TILE, PAL_NONE, _station_display_datas_60 },
{ SPR_FLAT_GRASS_TILE, PAL_NONE, _station_display_datas_61 },
+};
+
+static const DrawTileSprites _station_display_datas_truck[] = {
+ { SPR_TRUCK_STOP_NE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_67 },
+ { SPR_TRUCK_STOP_SE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_68 },
+ { SPR_TRUCK_STOP_SW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_69 },
+ { SPR_TRUCK_STOP_NW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_70 },
{ SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, _station_display_datas_0168 },
{ SPR_ROAD_PAVED_STRAIGHT_Y, PAL_NONE, _station_display_datas_0169 },
+};
+
+static const DrawTileSprites _station_display_datas_bus[] = {
+ { SPR_BUS_STOP_NE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_71 },
+ { SPR_BUS_STOP_SE_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_72 },
+ { SPR_BUS_STOP_SW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_73 },
+ { SPR_BUS_STOP_NW_GROUND | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, _station_display_datas_74 },
{ SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, _station_display_datas_0170 },
{ SPR_ROAD_PAVED_STRAIGHT_Y, PAL_NONE, _station_display_datas_0171 }
};
+
+static const DrawTileSprites _station_display_datas_oilrig[] = {
+ { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_nothing },
+};
+
+static const DrawTileSprites _station_display_datas_dock[] = {
+ { SPR_SHORE_TILEH_3, PAL_NONE, _station_display_datas_76 },
+ { SPR_SHORE_TILEH_9, PAL_NONE, _station_display_datas_77 },
+ { SPR_SHORE_TILEH_12, PAL_NONE, _station_display_datas_78 },
+ { SPR_SHORE_TILEH_6, PAL_NONE, _station_display_datas_79 },
+ { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_datas_80 },
+ { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_datas_81 },
+};
+
+static const DrawTileSprites _station_display_datas_buoy[] = {
+ { SPR_FLAT_WATER_TILE, PAL_NONE, _station_display_datas_82 },
+};
+
+static const DrawTileSprites *_station_display_datas[] = {
+ _station_display_datas_rail,
+ _station_display_datas_airport,
+ _station_display_datas_truck,
+ _station_display_datas_bus,
+ _station_display_datas_oilrig,
+ _station_display_datas_dock,
+ _station_display_datas_buoy,
+};