diff --git a/docs/landscape.html b/docs/landscape.html index 670539d092..804ac1a264 100644 --- a/docs/landscape.html +++ b/docs/landscape.html @@ -744,7 +744,7 @@
  • m3 bits 7..4: persistent random data for newstations
  • m3 bits 3..0: track type for railway stations, must be 0 for all the other stations
  • m4: custom station id; 0 means standard graphics
  • -
  • m5: tile type: +
  • m5: graphics index (range from 0..255 for each station type): @@ -770,145 +770,28 @@ - - - - - - - - - - - - - - - - + + - - + - - - - - - + - - - - - - - -
    00..07 
    08..33  large airport - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    0B  pad 1
    16..19  runway middle
    1A  runway ending
    1C  control tower
    20  hangar
    21  pad 3
    22  pad 2
    27..32  radar (animated)
    33  transmitter
    The initial layout of a large airport is (rows in Y direction, columns in X direction): -
    -1F 1B 1E 33 26 1A
    -09 24 0B 0C 0D 16
    -21 1D 23 0E 0F 17
    -09 22 0D 11 10 18
    -09 08 14 13 12 19
    -20 0A 15 1C 27 1A
    -
    -
    -
    34..41  small airport - - - - - - - - - - - - - - - - - - - - - - - - -
    3A..3D  field with the wind meter (animated)
    3E  runway south ending
    3F  runway middle
    40  runway north ending
    41  hangar
    The initial layout of a small airport is (rows in Y direction, columns in X direction): -
    -36 3A 40
    -35 39 3F
    -34 38 3F
    -41 37 3E
    -
    -
    -
    42 heliport
    43..46  lorry loading area : exit towards: - - - - - - - - - - - - - - - - - -
    43  NE
    44  SE
    45  SW
    46  NW
    -
    00..8Fall airports
    47..4A  bus station : exit towards: + 00..03  lorry loading area/truck station : exit towards: - + - + - + - +
    47  00  NE
    48  01  SE
    49  02  SW
    4A  03  NW
    @@ -916,52 +799,40 @@
    4B oilfield
    4C..51  00..05  ship dock - + - + - + - + - + - +
    4C  00  SW coast part
    4D  01  NW coast part
    4E  02  NE coast part
    4F  03  SE coast part
    50  04  X direction water part
    51  05  Y direction water part
    52 buoy
    53..A7  used by RichK's larger airports
  • -
  • m6 bit 3: 1 when a drive through road stop is built over a town owned road, otherwise 0
  • +
  • m6 bits 3..5: the station type (rail, airport, truck, bus, oilrig, dock, buoy)
  • +
  • m6 bit 2: 1 when a drive through road stop is built over a town owned road, otherwise 0
  • m6 bits 1..0 : Tropic zone definition
  • diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html index 06351e2aaf..9f9e3e3ca4 100644 --- a/docs/landscape_grid.html +++ b/docs/landscape_grid.html @@ -184,7 +184,7 @@ the array so you can quickly see what is used and what is not. XXXX XXXX XXXX XXXX XXXX XXXX - OOOO OXXX + OOXX XXXX OOOO OOOO diff --git a/projects/openttd.vcproj b/projects/openttd.vcproj index 63ef6bc17f..2247579782 100644 --- a/projects/openttd.vcproj +++ b/projects/openttd.vcproj @@ -1139,9 +1139,6 @@ - - diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj index 40dae1ad2a..908880ab14 100644 --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -1735,10 +1735,6 @@ RelativePath=".\..\src\road_map.h" > - - diff --git a/source.list b/source.list index 52d4b0e40c..890e8dcfb1 100644 --- a/source.list +++ b/source.list @@ -355,7 +355,6 @@ industry_map.h rail_map.h road_map.cpp road_map.h -station_map.cpp station_map.h town_map.h tree_map.h diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index e54bbeb640..7e2e40c9b1 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 7cadd82d54..09d949300b 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 b57357ac8d..53547997cd 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 61c6cea011..b0cecc0fc5 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 7057687055..d5bc70fa18 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 69c54dfeb4..1300f45d4a 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 e5567bf975..01518f0619 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -30,7 +30,7 @@ #include #include -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 25f77e7d23..c447f2ab7f 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 2f0602e8f1..379bac43ef 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 d1552a0820..0000000000 --- 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 e35b5d8b51..38a0a58d75 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 2d66e48e48..6f955daf37 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, +};