Mercurial > hg > openttd
changeset 3506:6033a91bfec7 draft
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
author | celestar <celestar@openttd.org> |
---|---|
date | Tue, 11 Apr 2006 13:10:16 +0000 |
parents | 9604df1e9283 |
children | f77278ecac59 |
files | rail_cmd.c |
diffstat | 1 files changed, 13 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/rail_cmd.c +++ b/rail_cmd.c @@ -1050,36 +1050,8 @@ } } - - #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 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)); }