summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-03 11:35:57 +0000
committerrubidium <rubidium@openttd.org>2010-08-03 11:35:57 +0000
commitfbde46c028bb8c7f35b24d803f0d1bfae5039a67 (patch)
treeea1701c1c90e6209f01f145db61f3178a860925b /src
parent3bfe26c69d10c8395057a0fe168906182b563769 (diff)
downloadopenttd-fbde46c028bb8c7f35b24d803f0d1bfae5039a67.tar.xz
(svn r20338) -Codechange: unify the unmovable tile drawing
Diffstat (limited to 'src')
-rw-r--r--src/table/unmovable_land.h110
-rw-r--r--src/unmovable_cmd.cpp75
2 files changed, 89 insertions, 96 deletions
diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h
index a041fa22b..8896613d0 100644
--- a/src/table/unmovable_land.h
+++ b/src/table/unmovable_land.h
@@ -9,59 +9,82 @@
/** @file unmovable_land.h Sprites to use and how to display them for unmovable tiles. */
-static const DrawTileSeqStruct _draw_tile_transmitterlighthouse_data[] = {
+#define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} },
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
+
+static const DrawTileSeqStruct _unmovable_nothing[] = {
+ TILE_SEQ_END()
+};
+
+static const DrawTileSeqStruct _unmovable_transmitter_seq[] = {
{ 7, 7, 0, 2, 2, 70, {SPR_UNMOVABLE_TRANSMITTER, PAL_NONE}},
+ TILE_SEQ_END()
+};
+
+static const DrawTileSeqStruct _unmovable_lighthouse_seq[] = {
{ 4, 4, 0, 7, 7, 61, {SPR_UNMOVABLE_LIGHTHOUSE, PAL_NONE}},
+ TILE_SEQ_END()
};
-#define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} },
-#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
+static const DrawTileSeqStruct _unmovable_statue_seq[] = {
+ { 0, 0, 0, 16, 16, 25, {SPR_STATUE_COMPANY | (1 << PALETTE_MODIFIER_COLOUR), PAL_NONE}},
+ TILE_SEQ_END()
+};
-static const DrawTileSeqStruct _unmovable_display_nothing[] = {
+static const DrawTileSeqStruct _unmovable_owned_land_seq[] = {
+ { 8, 8, 0, 1, 1, 6, {SPR_BOUGHT_LAND | (1 << PALETTE_MODIFIER_COLOUR), PAL_NONE}},
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_8[] = {
+static const DrawTileSprites _unmovables[] = {
+ { { SPR_FLAT_2_THIRD_GRASS_TILE, PAL_NONE }, _unmovable_transmitter_seq },
+ { { SPR_FLAT_2_THIRD_GRASS_TILE, PAL_NONE }, _unmovable_lighthouse_seq },
+ { { SPR_CONCRETE_GROUND, PAL_NONE }, _unmovable_statue_seq },
+ { { SPR_FLAT_BARE_LAND, PAL_NONE }, _unmovable_owned_land_seq },
+};
+
+
+static const DrawTileSeqStruct _unmovable_hq_medium_north[] = {
TILE_SEQ_LINE(20, SPR_MEDIUMHQ_NORTH_WALL | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_9[] = {
+static const DrawTileSeqStruct _unmovable_hq_medium_east[] = {
TILE_SEQ_LINE(20, SPR_MEDIUMHQ_EAST_WALL | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_10[] = {
+static const DrawTileSeqStruct _unmovable_hq_medium_west[] = {
TILE_SEQ_LINE(20, SPR_MEDIUMHQ_WEST_WALL | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_12[] = {
+static const DrawTileSeqStruct _unmovable_hq_large_north[] = {
TILE_SEQ_LINE(50, SPR_LARGEHQ_NORTH_BUILD | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_13[] = {
+static const DrawTileSeqStruct _unmovable_hq_large_east[] = {
TILE_SEQ_LINE(50, SPR_LARGEHQ_EAST_BUILD | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_14[] = {
+static const DrawTileSeqStruct _unmovable_hq_large_west[] = {
TILE_SEQ_LINE(50, SPR_LARGEHQ_WEST_BUILD | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_16[] = {
+static const DrawTileSeqStruct _unmovable_hq_huge_north[] = {
TILE_SEQ_LINE(60, SPR_HUGEHQ_NORTH_BUILD | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_17[] = {
+static const DrawTileSeqStruct _unmovable_hq_huge_east[] = {
TILE_SEQ_LINE(60, SPR_HUGEHQ_EAST_BUILD | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
-static const DrawTileSeqStruct _unmovable_display_datas_18[] = {
+static const DrawTileSeqStruct _unmovable_hq_huge_west[] = {
TILE_SEQ_LINE(60, SPR_HUGEHQ_WEST_BUILD | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_END()
};
@@ -71,39 +94,40 @@ static const DrawTileSeqStruct _unmovable_display_datas_18[] = {
#define TILE_SPRITE_LINE(img, dtss) { {img | (1 << PALETTE_MODIFIER_COLOUR), PAL_NONE}, dtss },
-static const DrawTileSprites _unmovable_display_datas[] = {
- TILE_SPRITE_LINE(SPR_TINYHQ_NORTH, _unmovable_display_nothing)
- TILE_SPRITE_LINE(SPR_TINYHQ_EAST, _unmovable_display_nothing)
- TILE_SPRITE_LINE(SPR_TINYHQ_WEST, _unmovable_display_nothing)
- TILE_SPRITE_LINE(SPR_TINYHQ_SOUTH, _unmovable_display_nothing)
-
- TILE_SPRITE_LINE(SPR_SMALLHQ_NORTH, _unmovable_display_nothing)
- TILE_SPRITE_LINE(SPR_SMALLHQ_EAST, _unmovable_display_nothing)
- TILE_SPRITE_LINE(SPR_SMALLHQ_WEST, _unmovable_display_nothing)
- TILE_SPRITE_LINE(SPR_SMALLHQ_SOUTH, _unmovable_display_nothing)
-
- TILE_SPRITE_LINE(SPR_MEDIUMHQ_NORTH, _unmovable_display_datas_8)
- TILE_SPRITE_LINE(SPR_MEDIUMHQ_EAST, _unmovable_display_datas_9)
- TILE_SPRITE_LINE(SPR_MEDIUMHQ_WEST, _unmovable_display_datas_10)
- TILE_SPRITE_LINE(SPR_MEDIUMHQ_SOUTH, _unmovable_display_nothing)
-
- TILE_SPRITE_LINE(SPR_LARGEHQ_NORTH_GROUND, _unmovable_display_datas_12)
- TILE_SPRITE_LINE(SPR_LARGEHQ_EAST_GROUND, _unmovable_display_datas_13)
- TILE_SPRITE_LINE(SPR_LARGEHQ_WEST_GROUND, _unmovable_display_datas_14)
- TILE_SPRITE_LINE(SPR_LARGEHQ_SOUTH, _unmovable_display_nothing)
-
- TILE_SPRITE_LINE(SPR_HUGEHQ_NORTH_GROUND, _unmovable_display_datas_16)
- TILE_SPRITE_LINE(SPR_HUGEHQ_EAST_GROUND, _unmovable_display_datas_17)
- TILE_SPRITE_LINE(SPR_HUGEHQ_WEST_GROUND, _unmovable_display_datas_18)
- TILE_SPRITE_LINE(SPR_HUGEHQ_SOUTH, _unmovable_display_nothing)
+static const DrawTileSprites _unmovable_hq[] = {
+ TILE_SPRITE_LINE(SPR_TINYHQ_NORTH, _unmovable_nothing)
+ TILE_SPRITE_LINE(SPR_TINYHQ_EAST, _unmovable_nothing)
+ TILE_SPRITE_LINE(SPR_TINYHQ_WEST, _unmovable_nothing)
+ TILE_SPRITE_LINE(SPR_TINYHQ_SOUTH, _unmovable_nothing)
+
+ TILE_SPRITE_LINE(SPR_SMALLHQ_NORTH, _unmovable_nothing)
+ TILE_SPRITE_LINE(SPR_SMALLHQ_EAST, _unmovable_nothing)
+ TILE_SPRITE_LINE(SPR_SMALLHQ_WEST, _unmovable_nothing)
+ TILE_SPRITE_LINE(SPR_SMALLHQ_SOUTH, _unmovable_nothing)
+
+ TILE_SPRITE_LINE(SPR_MEDIUMHQ_NORTH, _unmovable_hq_medium_north)
+ TILE_SPRITE_LINE(SPR_MEDIUMHQ_EAST, _unmovable_hq_medium_east)
+ TILE_SPRITE_LINE(SPR_MEDIUMHQ_WEST, _unmovable_hq_medium_west)
+ TILE_SPRITE_LINE(SPR_MEDIUMHQ_SOUTH, _unmovable_nothing)
+
+ TILE_SPRITE_LINE(SPR_LARGEHQ_NORTH_GROUND, _unmovable_hq_large_north)
+ TILE_SPRITE_LINE(SPR_LARGEHQ_EAST_GROUND, _unmovable_hq_large_east)
+ TILE_SPRITE_LINE(SPR_LARGEHQ_WEST_GROUND, _unmovable_hq_large_west)
+ TILE_SPRITE_LINE(SPR_LARGEHQ_SOUTH, _unmovable_nothing)
+
+ TILE_SPRITE_LINE(SPR_HUGEHQ_NORTH_GROUND, _unmovable_hq_huge_north)
+ TILE_SPRITE_LINE(SPR_HUGEHQ_EAST_GROUND, _unmovable_hq_huge_east)
+ TILE_SPRITE_LINE(SPR_HUGEHQ_WEST_GROUND, _unmovable_hq_huge_west)
+ TILE_SPRITE_LINE(SPR_HUGEHQ_SOUTH, _unmovable_nothing)
};
#undef TILE_SPRITE_LINE
+/** Specification of the original unmovable structures. */
static const UnmovableSpec _original_unmovable[] = {
- {STR_LAI_UNMOVABLE_DESCRIPTION_TRANSMITTER, 0x11, 1, 1},
- {STR_LAI_UNMOVABLE_DESCRIPTION_LIGHTHOUSE, 0x11, 1, 1},
- {STR_TOWN_BUILDING_NAME_STATUE_1, 0x11, 1, 1},
- {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_OWNED_LAND, 0x11, 10, 2},
- {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_HEADQUARTERS, 0x22, 1, 1},
+ { STR_LAI_UNMOVABLE_DESCRIPTION_TRANSMITTER, 0x11, 1, 1 },
+ { STR_LAI_UNMOVABLE_DESCRIPTION_LIGHTHOUSE, 0x11, 1, 1 },
+ { STR_TOWN_BUILDING_NAME_STATUE_1, 0x11, 1, 1 },
+ { STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_OWNED_LAND, 0x11, 10, 2 },
+ { STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_HEADQUARTERS, 0x22, 1, 1 },
};
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 31af9738e..f5083fa1f 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -244,67 +244,36 @@ static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
static void DrawTile_Unmovable(TileInfo *ti)
{
- DrawFoundation(ti, GetFoundation_Unmovable(ti->tile, ti->tileh));
- switch (GetUnmovableType(ti->tile)) {
- default: NOT_REACHED();
- case UNMOVABLE_TRANSMITTER:
- case UNMOVABLE_LIGHTHOUSE: {
- const DrawTileSeqStruct *dtu = &_draw_tile_transmitterlighthouse_data[GetUnmovableType(ti->tile)];
-
- DrawClearLandTile(ti, 2);
+ UnmovableType type = GetUnmovableType(ti->tile);
+ if (type != UNMOVABLE_OWNED_LAND) DrawFoundation(ti, GetFoundation_Unmovable(ti->tile, ti->tileh));
- if (IsInvisibilitySet(TO_STRUCTURES)) break;
+ const DrawTileSprites *dts = NULL;
+ Owner to = GetTileOwner(ti->tile);
+ PaletteID palette = to == OWNER_NONE ? PAL_NONE : COMPANY_SPRITE_COLOUR(to);
- AddSortableSpriteToDraw(
- dtu->image.sprite, PAL_NONE, ti->x | dtu->delta_x, ti->y | dtu->delta_y,
- dtu->size_x, dtu->size_y, dtu->size_z, ti->z,
- IsTransparencySet(TO_STRUCTURES)
- );
- break;
- }
-
- case UNMOVABLE_STATUE:
- DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
-
- if (IsInvisibilitySet(TO_STRUCTURES)) break;
-
- AddSortableSpriteToDraw(SPR_STATUE_COMPANY, COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES));
- break;
+ if (type == UNMOVABLE_HQ) {
+ uint8 offset = GetUnmovableOffset(ti->tile);
+ dts = &_unmovable_hq[GetCompanyHQSize(ti->tile) << 2 | GB(offset, 4, 1) | GB(offset, 0, 1) << 1];
+ } else {
+ dts = &_unmovables[type];
+ }
- case UNMOVABLE_OWNED_LAND:
- DrawClearLandTile(ti, 0);
+ DrawGroundSprite(dts->ground.sprite, palette);
+ if (!IsInvisibilitySet(TO_STRUCTURES)) {
+ const DrawTileSeqStruct *dtss;
+ foreach_draw_tile_seq(dtss, dts->seq) {
AddSortableSpriteToDraw(
- SPR_BOUGHT_LAND, COMPANY_SPRITE_COLOUR(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)
+ dtss->image.sprite, palette,
+ ti->x + dtss->delta_x, ti->y + dtss->delta_y,
+ dtss->size_x, dtss->size_y,
+ dtss->size_z, ti->z + dtss->delta_z,
+ IsTransparencySet(TO_STRUCTURES)
);
- DrawBridgeMiddle(ti);
- break;
-
- case UNMOVABLE_HQ: {
- assert(IsCompanyHQ(ti->tile));
-
- PaletteID palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile));
-
- uint8 offset = GetUnmovableOffset(ti->tile);
- const DrawTileSprites *t = &_unmovable_display_datas[GetCompanyHQSize(ti->tile) << 2 | GB(offset, 4, 1) | GB(offset, 0, 1) << 1];
- DrawGroundSprite(t->ground.sprite, palette);
-
- if (IsInvisibilitySet(TO_STRUCTURES)) break;
-
- const DrawTileSeqStruct *dtss;
- foreach_draw_tile_seq(dtss, t->seq) {
- AddSortableSpriteToDraw(
- dtss->image.sprite, palette,
- ti->x + dtss->delta_x, ti->y + dtss->delta_y,
- dtss->size_x, dtss->size_y,
- dtss->size_z, ti->z + dtss->delta_z,
- IsTransparencySet(TO_STRUCTURES)
- );
- }
- break;
}
}
+
+ if (type == UNMOVABLE_OWNED_LAND) DrawBridgeMiddle(ti);
}
static uint GetSlopeZ_Unmovable(TileIndex tile, uint x, uint y)