diff options
-rw-r--r-- | src/clear_cmd.cpp | 10 | ||||
-rw-r--r-- | src/landscape.cpp | 4 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 6 | ||||
-rw-r--r-- | src/slope_func.h | 12 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 2 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 2 | ||||
-rw-r--r-- | src/variables.h | 3 | ||||
-rw-r--r-- | src/viewport.cpp | 2 |
8 files changed, 25 insertions, 16 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 2f91f2fd0..e417c5053 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -50,13 +50,13 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags) void DrawClearLandTile(const TileInfo *ti, byte set) { - DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19, PAL_NONE); + DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE); } void DrawHillyLandTile(const TileInfo *ti) { if (ti->tileh != SLOPE_FLAT) { - DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh], PAL_NONE); + DrawGroundSprite(SPR_FLAT_ROUGH_LAND + SlopeToSpriteOffset(ti->tileh), PAL_NONE); } else { DrawGroundSprite(_landscape_clear_sprites_rough[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE); } @@ -92,16 +92,16 @@ static void DrawTile_Clear(TileInfo *ti) break; case CLEAR_ROCKS: - DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh], PAL_NONE); + DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break; case CLEAR_FIELDS: - DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); + DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break; case CLEAR_SNOW: case CLEAR_DESERT: - DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); + DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break; } diff --git a/src/landscape.cpp b/src/landscape.cpp index 25b41d130..5352a6467 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -63,8 +63,8 @@ const TileTypeProcs * const _tile_type_procs[16] = { &_tile_type_unmovable_procs, ///< Callback functions for MP_UNMOVABLE tiles }; -/* landscape slope => sprite */ -const byte _tileh_to_sprite[32] = { +/** landscape slope => sprite */ +extern const byte _slope_to_sprite_offset[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 17, 0, 15, 18, 0, }; diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index ab3444cbd..70a5a4325 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1876,7 +1876,7 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailtypeIn default: image = SPR_FLAT_GRASS_TILE; break; } - image += _tileh_to_sprite[ti->tileh]; + image += SlopeToSpriteOffset(ti->tileh); DrawGroundSprite(image, PAL_NONE); } @@ -1966,7 +1966,7 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailtypeIn default: image = SPR_FLAT_GRASS_TILE; break; } - image += _tileh_to_sprite[fake_slope]; + image += SlopeToSpriteOffset(fake_slope); DrawGroundSprite(image, PAL_NONE, &(_halftile_sub_sprite[halftile_corner])); @@ -2038,7 +2038,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track) case RAIL_GROUND_ICE_DESERT: image = SPR_FLAT_SNOW_DESERT_TILE; break; default: image = SPR_FLAT_GRASS_TILE; break; } - image += _tileh_to_sprite[ti->tileh]; + image += SlopeToSpriteOffset(ti->tileh); } } else { if (ti->tileh != SLOPE_FLAT) { diff --git a/src/slope_func.h b/src/slope_func.h index b6a0a6e9d..c05df5656 100644 --- a/src/slope_func.h +++ b/src/slope_func.h @@ -397,4 +397,16 @@ static inline Foundation SpecialRailFoundation(Corner corner) return (Foundation)(FOUNDATION_RAIL_W + corner); } +/** + * Returns the #Sprite offset for a given #Slope. + * + * @param s The #Slope to get the offset for. + * @return The sprite offset for this #Slope. + */ +static inline uint SlopeToSpriteOffset(Slope s) +{ + extern const byte _slope_to_sprite_offset[32]; + return _slope_to_sprite_offset[s]; +} + #endif /* SLOPE_FUNC_H */ diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 78c771b0b..baed9ab56 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -457,7 +457,7 @@ static void DrawTile_Trees(TileInfo *ti) case TREE_GROUND_SHORE: DrawShoreTile(ti->tileh); break; case TREE_GROUND_GRASS: DrawClearLandTile(ti, GetTreeDensity(ti->tile)); break; case TREE_GROUND_ROUGH: DrawHillyLandTile(ti); break; - default: DrawGroundSprite(_clear_land_sprites_snow_desert[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break; + default: DrawGroundSprite(_clear_land_sprites_snow_desert[GetTreeDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break; } DrawClearLandFence(ti); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index e706b27af..893238e1b 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -1060,7 +1060,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti) if (!ice) { DrawClearLandTile(ti, 3); } else { - DrawGroundSprite(SPR_FLAT_SNOW_DESERT_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE); + DrawGroundSprite(SPR_FLAT_SNOW_DESERT_TILE + SlopeToSpriteOffset(ti->tileh), PAL_NONE); } /* draw ramp */ diff --git a/src/variables.h b/src/variables.h index 9c7a0712c..1cd6b14a1 100644 --- a/src/variables.h +++ b/src/variables.h @@ -28,7 +28,4 @@ VARDEF char *_config_file; VARDEF char *_highscore_file; VARDEF char *_log_file; -/* landscape.cpp */ -extern const byte _tileh_to_sprite[32]; - #endif /* VARIABLES_H */ diff --git a/src/viewport.cpp b/src/viewport.cpp index 5852881f3..b55c4a414 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -851,7 +851,7 @@ static void DrawTileSelectionRect(const TileInfo *ti, PaletteID pal) } sel += opposite_corner; } else { - sel = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh]; + sel = SPR_SELECT_TILE + SlopeToSpriteOffset(ti->tileh); } DrawSelectionSprite(sel, pal, ti, 7, FOUNDATION_PART_NORMAL); } |