From d27bb24e7a13af6b2eb1c539718e6a652e131498 Mon Sep 17 00:00:00 2001 From: cirdan Date: Tue, 2 May 2017 18:40:14 +0200 Subject: [PATCH] Merge visible and invisible rail depot sprite arrays Merge the visible and invisible rail depot sprite arrays into a single one and move it to misctile_cmd.cpp. --- src/misctile_cmd.cpp | 25 ++++++++++++++++++------- src/table/track_land.h | 14 -------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/misctile_cmd.cpp b/src/misctile_cmd.cpp index 98c9e2bef..3fa8cb513 100644 --- a/src/misctile_cmd.cpp +++ b/src/misctile_cmd.cpp @@ -192,6 +192,19 @@ static void DrawTunnel(TileInfo *ti) DrawBridgeMiddle(ti); } + +struct TrainDepotSprites { + SpriteID ground[2]; ///< Ground sprites, visible and invisible. + const DrawTileSeqStruct *seq; ///< Array of child sprites. +}; + +static const TrainDepotSprites _depot_gfx_table[DIAGDIR_END] = { + { {SPR_FLAT_GRASS_TILE, SPR_RAIL_TRACK_X}, _depot_gfx_NE }, + { {SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_Y}, _depot_gfx_SE }, + { {SPR_RAIL_TRACK_X, SPR_RAIL_TRACK_X}, _depot_gfx_SW }, + { {SPR_FLAT_GRASS_TILE, SPR_RAIL_TRACK_Y}, _depot_gfx_NW }, +}; + static void DrawTrainDepotGroundSprite (TileInfo *ti, DiagDirection dir, SpriteID image_x, SpriteID image_y, PaletteID pal) { @@ -218,16 +231,14 @@ static void DrawTrainDepot(TileInfo *ti) DiagDirection dir = GetGroundDepotDirection (ti->tile); - const DrawTileSprites *dts = IsInvisibilitySet(TO_BUILDINGS) ? - /* Draw rail instead of depot */ - _depot_invisible_gfx_table : _depot_gfx_table; - dts = &dts[dir]; + const TrainDepotSprites *dts = &_depot_gfx_table[dir]; SpriteID image; if (rti->UsesOverlay()) { image = SPR_FLAT_GRASS_TILE; } else { - image = dts->ground.sprite; + /* Draw rail instead of depot if invisible. */ + image = dts->ground[IsInvisibilitySet(TO_BUILDINGS)]; if (image != SPR_FLAT_GRASS_TILE) image += rti->GetRailtypeSpriteOffset(); } @@ -270,9 +281,9 @@ static void DrawTrainDepot(TileInfo *ti) void DrawTrainDepotSprite (BlitArea *dpi, int x, int y, int dir, RailType railtype) { - const DrawTileSprites *dts = &_depot_gfx_table[dir]; + const TrainDepotSprites *dts = &_depot_gfx_table[dir]; const RailtypeInfo *rti = GetRailTypeInfo(railtype); - SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite; + SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground[0]; uint32 offset = rti->GetRailtypeSpriteOffset(); if (image != SPR_FLAT_GRASS_TILE) image += offset; diff --git a/src/table/track_land.h b/src/table/track_land.h index 1916a54f6..d2020964b 100644 --- a/src/table/track_land.h +++ b/src/table/track_land.h @@ -35,20 +35,6 @@ static const DrawTileSeqStruct _depot_gfx_NW[] = { TILE_SEQ_END() }; -static const DrawTileSprites _depot_gfx_table[] = { - { {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NE }, - { {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE }, - { {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW }, - { {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW } -}; - -static const DrawTileSprites _depot_invisible_gfx_table[] = { - { {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_NE }, - { {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE }, - { {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW }, - { {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_NW } -}; - #undef TILE_SEQ_LINE #undef TILE_SEQ_END -- 2.11.4.GIT