diff options
author | frosch <frosch@openttd.org> | 2011-02-19 14:51:46 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-02-19 14:51:46 +0000 |
commit | 9e59436c611d52ebe6dfb37daea31d8e770a0503 (patch) | |
tree | f55e047a1a463e1a291f2e63ef231f72d68c918d /src | |
parent | 1dd6d037bacf3bbdf26a53e50fb4f441b2e99a05 (diff) | |
download | openttd-9e59436c611d52ebe6dfb37daea31d8e770a0503.tar.xz |
(svn r22108) -Codechange: Replace some magic with some other magic though less easy to break.
Diffstat (limited to 'src')
-rw-r--r-- | src/table/water_land.h | 38 | ||||
-rw-r--r-- | src/water_cmd.cpp | 6 |
2 files changed, 24 insertions, 20 deletions
diff --git a/src/table/water_land.h b/src/table/water_land.h index 97cee2e3e..24c24ffa8 100644 --- a/src/table/water_land.h +++ b/src/table/water_land.h @@ -20,32 +20,34 @@ struct WaterDrawTileStruct { }; #define BEGIN(image) { 0, 0, 0, 0, 0, 0, image } -#define END(y) { 0x80, y, 0, 0, 0, 0, 0 } + +/** Constructor macro for a terminating WaterDrawTileStruct entry in an array */ +#define TILE_SEQ_END() { 0x80, 0, 0, 0, 0, 0, 0 } static const WaterDrawTileStruct _shipdepot_display_seq_1[] = { BEGIN(0xFDD), { 0, 15, 0, 16, 1, 0x14, 0xFE8 | (1 << PALETTE_MODIFIER_COLOUR) }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _shipdepot_display_seq_2[] = { BEGIN(0xFDD), { 0, 0, 0, 16, 1, 0x14, 0xFEA }, { 0, 15, 0, 16, 1, 0x14, 0xFE6 | (1 << PALETTE_MODIFIER_COLOUR) }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _shipdepot_display_seq_3[] = { BEGIN(0xFDD), { 15, 0, 0, 1, 0x10, 0x14, 0xFE9 | (1 << PALETTE_MODIFIER_COLOUR) }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _shipdepot_display_seq_4[] = { BEGIN(0xFDD), { 0, 0, 0, 1, 16, 0x14, 0xFEB }, { 15, 0, 0, 1, 16, 0x14, 0xFE7 | (1 << PALETTE_MODIFIER_COLOUR) }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct * const _shipdepot_display_seq[] = { @@ -59,84 +61,84 @@ static const WaterDrawTileStruct _lock_display_seq_0[] = { BEGIN(1), { 0, 0, 0, 0x10, 1, 0x14, 0 + 1 }, { 0, 0xF, 0, 0x10, 1, 0x14, 4 + 1 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_1[] = { BEGIN(0), { 0, 0, 0, 1, 0x10, 0x14, 0 }, { 0xF, 0, 0, 1, 0x10, 0x14, 4 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_2[] = { BEGIN(2), { 0, 0, 0, 0x10, 1, 0x14, 0 + 2 }, { 0, 0xF, 0, 0x10, 1, 0x14, 4 + 2 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_3[] = { BEGIN(3), { 0, 0, 0, 1, 0x10, 0x14, 0 + 3 }, { 0xF, 0, 0, 1, 0x10, 0x14, 4 + 3 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_0b[] = { BEGIN(0xFDD), { 0, 0, 0, 0x10, 1, 0x14, 8 + 1 }, { 0, 0xF, 0, 0x10, 1, 0x14, 12 + 1 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_1b[] = { BEGIN(0xFDD), { 0, 0, 0, 0x1, 0x10, 0x14, 8 }, { 0xF, 0, 0, 0x1, 0x10, 0x14, 12 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_2b[] = { BEGIN(0xFDD), { 0, 0, 0, 0x10, 1, 0x14, 8 + 2 }, { 0, 0xF, 0, 0x10, 1, 0x14, 12 + 2 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_3b[] = { BEGIN(0xFDD), { 0, 0, 0, 1, 0x10, 0x14, 8 + 3 }, { 0xF, 0, 0, 1, 0x10, 0x14, 12 + 3 }, - END(0) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_0t[] = { BEGIN(0xFDD), { 0, 0, 0, 0x10, 1, 0x14, 16 + 1 }, { 0, 0xF, 0, 0x10, 1, 0x14, 20 + 1 }, - END(8) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_1t[] = { BEGIN(0xFDD), { 0, 0, 0, 0x1, 0x10, 0x14, 16 }, { 0xF, 0, 0, 0x1, 0x10, 0x14, 20 }, - END(8) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_2t[] = { BEGIN(0xFDD), { 0, 0, 0, 0x10, 1, 0x14, 16 + 2 }, { 0, 0xF, 0, 0x10, 1, 0x14, 20 + 2 }, - END(8) + TILE_SEQ_END() }; static const WaterDrawTileStruct _lock_display_seq_3t[] = { BEGIN(0xFDD), { 0, 0, 0, 1, 0x10, 0x14, 16 + 3 }, { 0xF, 0, 0, 1, 0x10, 0x14, 20 + 3 }, - END(8) + TILE_SEQ_END() }; static const WaterDrawTileStruct * const _lock_display_seq[] = { @@ -157,4 +159,4 @@ static const WaterDrawTileStruct * const _lock_display_seq[] = { }; #undef BEGIN -#undef END +#undef TILE_SEQ_END diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 335846e6f..4f8b25eac 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -641,7 +641,8 @@ static void DrawWaterTileStruct(const TileInfo *ti, const WaterDrawTileStruct *w /** Draw a lock tile. */ static void DrawWaterLock(const TileInfo *ti) { - const WaterDrawTileStruct *wdts = _lock_display_seq[GetSection(ti->tile)]; + int section = GetSection(ti->tile); + const WaterDrawTileStruct *wdts = _lock_display_seq[section]; /* Draw ground sprite. */ SpriteID image = wdts++->image; @@ -669,7 +670,8 @@ static void DrawWaterLock(const TileInfo *ti) if (base == 0) { /* If no custom graphics, use defaults. */ base = SPR_LOCK_BASE; - zoffs = ti->z > wdts[3].delta_y ? 24 : 0; + uint8 z_threshold = section >= 8 ? 8 : 0; + zoffs = ti->z > z_threshold ? 24 : 0; } DrawWaterTileStruct(ti, wdts, base, zoffs, PAL_NONE, CF_LOCKS); |