Index: src/table/unmovable_land.h =================================================================== --- src/table/unmovable_land.h (revision 12015) +++ src/table/unmovable_land.h (working copy) @@ -1,23 +1,7 @@ /* $Id$ */ -struct DrawTileUnmovableStruct { - uint16 image; - byte subcoord_x; - byte subcoord_y; - byte width; - byte height; - byte z_size; - byte unused; -}; - #define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 } -static const DrawTileUnmovableStruct _draw_tile_unmovable_data[] = { - {0xA29, 7, 7, 2, 2, 70, 0}, - {0xA2A, 4, 4, 7, 7, 61, 0}, -}; - - static const DrawTileSeqStruct _unmovable_display_nothing[] = { TILE_SEQ_END() }; Index: src/unmovable_cmd.cpp =================================================================== --- src/unmovable_cmd.cpp (revision 12015) +++ src/unmovable_cmd.cpp (working copy) @@ -111,6 +111,29 @@ return cost; } +/** + * Get the ground sprite to draw under the unmovable. + * @param tile the tileindex of the unmovable. + * @return the ground sprite. + */ +static SpriteID GetUnmovableGround(TileIndex tile) +{ + if (HasUnmovableSnowOrDesert(tile)) { + return SPR_FLAT_SNOWY_TILE; + } else { + if (_opt.landscape == LT_ARCTIC && GetTileZ(tile) + 8 >= GetSnowLine()) { + switch(GetTileZ(tile) + 8 - GetSnowLine()) { + case 0: return SPR_FLAT_1_QUART_SNOWY_TILE; break; + case 8: return SPR_FLAT_2_QUART_SNOWY_TILE; break; + case 16: return SPR_FLAT_3_QUART_SNOWY_TILE; break; + default: return SPR_FLAT_SNOWY_TILE; break; + } + } else { + return SPR_FLAT_GRASS_TILE; + } + } +} + /** Purchase a land area. Actually you only purchase one tile, so * the name is a bit confusing ;p * @param tile the tile the player is purchasing @@ -163,43 +186,50 @@ static void DrawTile_Unmovable(TileInfo *ti) { - switch (GetUnmovableType(ti->tile)) { - case UNMOVABLE_TRANSMITTER: - case UNMOVABLE_LIGHTHOUSE: { - const DrawTileUnmovableStruct* dtus; - if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); - DrawClearLandTile(ti, 2); + case UNMOVABLE_TRANSMITTER: { + assert(ti->tileh == SLOPE_FLAT); + DrawGroundSprite(GetUnmovableGround(ti->tile), PAL_NONE); + AddSortableSpriteToDraw( + SPR_UNMOVABLE_TRANSMITTER, PAL_NONE, + ti->x | 7, ti->y | 7, 2, 2, 70, ti->z, IsTransparencySet(TO_STRUCTURES) + ); + break; + } - dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)]; - + case UNMOVABLE_LIGHTHOUSE: { + assert(ti->tileh == SLOPE_FLAT); + DrawGroundSprite(GetUnmovableGround(ti->tile), PAL_NONE); AddSortableSpriteToDraw( - dtus->image, PAL_NONE, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y, - dtus->width, dtus->height, dtus->z_size, ti->z, - IsTransparencySet(TO_STRUCTURES) + SPR_UNMOVABLE_LIGHTHOUSE, PAL_NONE, + ti->x | 4, ti->y | 4, 7, 7, 61, ti->z, IsTransparencySet(TO_STRUCTURES) ); break; } - case UNMOVABLE_STATUE: - /* This should prevent statues from sinking into the ground when on a slope. */ - if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, GetFoundation_Unmovable(ti->tile, ti->tileh)); - + case UNMOVABLE_STATUE: { + if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE); - - AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES)); + AddSortableSpriteToDraw( + SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), + ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES) + ); break; + } - case UNMOVABLE_OWNED_LAND: - DrawClearLandTile(ti, 0); - - AddSortableSpriteToDraw( - SPR_BOUGHT_LAND, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), - ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2) - ); + case UNMOVABLE_OWNED_LAND: { + DrawGroundSprite(GetUnmovableGround(ti->tile) + _tileh_to_sprite[ti->tileh], PAL_NONE); + if (!IsTransparencySet(TO_SIGNS)) { + AddSortableSpriteToDraw( + SPR_BOUGHT_LAND, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), + ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, BB_HEIGHT_UNDER_BRIDGE, + GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2) + ); + } DrawBridgeMiddle(ti); break; + } default: { const DrawTileSeqStruct* dtss; Index: src/unmovable_map.h =================================================================== --- src/unmovable_map.h (revision 12015) +++ src/unmovable_map.h (working copy) @@ -13,6 +13,18 @@ HQ_NUM_SIZE = 5 ///< Number of stages of an HQ }; +/** + * Does the unmovable lie in a snow or desert area? + * @param t The tile to analyze + * @pre IsTileType(t, MP_UNMOVABLE) + * @return true if and only if the tile is in a snowy/desert area + */ +static inline bool HasUnmovableSnowOrDesert(TileIndex t) +{ + assert(IsTileType(t, MP_UNMOVABLE)); + return HasBit(_m[t].m6, 0); +} + /** Types of unmovable structure */ enum UnmovableType { UNMOVABLE_TRANSMITTER = 0, ///< The large antenna