diff options
author | celestar <celestar@openttd.org> | 2006-04-11 13:10:16 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2006-04-11 13:10:16 +0000 |
commit | dfd8ade37d3b5be48ce3622a3b8a7a0259578f36 (patch) | |
tree | 12cebd4b18af2da2d62f744290508798b2698bf4 | |
parent | f942a6e1f5dc859b15c28b4ff374ccd822af1a7b (diff) | |
download | openttd-dfd8ade37d3b5be48ce3622a3b8a7a0259578f36.tar.xz |
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
-rw-r--r-- | rail_cmd.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index c3e964c23..e2017ddcf 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1050,36 +1050,8 @@ static int32 ClearTile_Track(TileIndex tile, byte flags) } } - - #include "table/track_land.h" -// used for presignals -static const SpriteID _signal_base_sprites[16] = { - 0x4FB, - 0x1323, - 0x1333, - 0x1343, - - // semaphores - 0x1353, - 0x1363, - 0x1373, - 0x1383, - - // mirrored versions - 0x4FB, - 0x1323, - 0x1333, - 0x1343, - - // semaphores - 0x1446, - 0x1456, - 0x1466, - 0x1476, -}; - static void DrawSignalHelper(const TileInfo *ti, byte condition, uint32 image_and_pos) { bool otherside = _opt.road_side & _patches.signal_side; @@ -1097,9 +1069,21 @@ static void DrawSignalHelper(const TileInfo *ti, byte condition, uint32 image_an } }; + 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 = ti->x + SignalPositions[otherside][image_and_pos & 0xF].x; uint y = ti->y + SignalPositions[otherside][image_and_pos & 0xF].y; - uint sprite = _signal_base_sprites[(_m[ti->tile].m4 & 0x7) + (otherside ? 8 : 0)] + (image_and_pos>>4) + ((condition != 0) ? 1 : 0); + SpriteID sprite = SignalBase[otherside][GetSignalVariant(ti->tile)][GetSignalType(ti->tile)] + (image_and_pos>>4) + ((condition != 0) ? 1 : 0); AddSortableSpriteToDraw(sprite, x, y, 1, 1, 10, GetSlopeZ(x,y)); } |