From 32691590fbbc941734ac9ef09f8ece8adb55b427 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 12 Feb 2008 20:14:14 +0000 Subject: (svn r12125) -Codechange: Remove redundant signal lookup table, and document why normal electric signals are handled specially. --- src/rail_cmd.cpp | 23 ++++++++--------------- src/table/sprites.h | 2 ++ 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src') 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, -- cgit v1.2.3-70-g09d2