diff options
author | peter1138 <peter1138@openttd.org> | 2008-02-12 20:14:14 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-02-12 20:14:14 +0000 |
commit | 63e306006bb9fbe82c1c7d63dc4e854bba328908 (patch) | |
tree | c5a2604651488b0f08fda19c891a49131c028985 | |
parent | c2bad6d22c9889bfb673055c2e9af424b0d157fe (diff) | |
download | openttd-63e306006bb9fbe82c1c7d63dc4e854bba328908.tar.xz |
(svn r12125) -Codechange: Remove redundant signal lookup table, and document why normal electric signals are handled specially.
-rw-r--r-- | src/rail_cmd.cpp | 23 | ||||
-rw-r--r-- | src/table/sprites.h | 2 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 12910b0a0..b5f674df3 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1433,27 +1433,20 @@ static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint i } }; - static const SpriteID SignalBase[2][2][4] = { - { /* Signals on left side */ - { 0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */ - { 0x1353, 0x1363, 0x1373, 0x1383} /* semaphores */ - }, { /* Signals on right side */ - { 0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */ - { 0x1446, 0x1456, 0x1466, 0x1476} /* semaphores */ - /* | | | | */ - /* normal, entry, exit, combo */ - } - }; - uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x; uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y; SpriteID sprite; - if (GetSignalType(tile, track) == SIGTYPE_NORMAL && GetSignalVariant(tile, track) == SIG_ELECTRIC) { - sprite = SignalBase[side][GetSignalVariant(tile, track)][GetSignalType(tile, track)] + image + condition; + SignalType type = GetSignalType(tile, track); + SignalVariant variant = GetSignalVariant(tile, track); + + if (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) { + /* Normal electric signals are picked from original sprites. */ + sprite = SPR_ORIGINAL_SIGNALS_BASE + image + condition; } else { - sprite = SPR_SIGNALS_BASE + (GetSignalType(tile, track) - 1) * 16 + GetSignalVariant(tile, track) * 64 + image + condition; + /* All other signals are picked from add on sprites. */ + sprite = SPR_SIGNALS_BASE + (type - 1) * 16 + variant * 64 + image + condition; } AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track)); diff --git a/src/table/sprites.h b/src/table/sprites.h index 842d94542..2d29082b3 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -263,6 +263,8 @@ enum Sprites { SPR_MONO_SNOW_OFFSET = 26, SPR_MGLV_SNOW_OFFSET = 26, + SPR_ORIGINAL_SIGNALS_BASE = 1275, + SPR_RAIL_SINGLE_Y = 1005, SPR_RAIL_SINGLE_X = 1006, SPR_RAIL_SINGLE_NORTH = 1007, |