summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-17 19:09:30 +0000
committercelestar <celestar@openttd.org>2006-04-17 19:09:30 +0000
commit6935fb6455aed5a688e27cf528ee4bf3875698ae (patch)
treefb2c3b2221e130d8bc622ad2f50fbbddbb0d8574 /rail_cmd.c
parent3b6cbf62d423a7dde0c3dc6adfebdbc5e62c57d5 (diff)
downloadopenttd-6935fb6455aed5a688e27cf528ee4bf3875698ae.tar.xz
(svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index c5d210cff..ae14f6bc3 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -1015,9 +1015,9 @@ static int32 ClearTile_Track(TileIndex tile, byte flags)
#include "table/track_land.h"
-static void DrawSingleSignal(TileIndex tile, byte condition, uint32 image_and_pos)
+static void DrawSingleSignal(TileIndex tile, byte condition, uint image, uint pos)
{
- bool otherside = _opt.road_side & _patches.signal_side;
+ bool side = _opt.road_side & _patches.signal_side;
static const Point SignalPositions[2][12] = {
{ /* Signals on the left side */
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */
@@ -1044,9 +1044,11 @@ static void DrawSingleSignal(TileIndex tile, byte condition, uint32 image_and_po
}
};
- uint x = TileX(tile) * TILE_SIZE + SignalPositions[otherside][image_and_pos & 0xF].x;
- uint y = TileY(tile) * TILE_SIZE + SignalPositions[otherside][image_and_pos & 0xF].y;
- SpriteID sprite = SignalBase[otherside][GetSignalVariant(tile)][GetSignalType(tile)] + (image_and_pos>>4) + ((condition != 0) ? 1 : 0);
+ uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x;
+ uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y;
+
+ SpriteID sprite = SignalBase[side][GetSignalVariant(tile)][GetSignalType(tile)] + image + condition;
+
AddSortableSpriteToDraw(sprite, x, y, 1, 1, 10, GetSlopeZ(x,y));
}
@@ -1248,13 +1250,7 @@ static void DrawTrackBits(TileInfo* ti, TrackBits track, bool flat)
static void DrawSignals(TileIndex tile, TrackBits rails)
{
-#define HAS_SIGNAL(x) (m23 & (byte)(0x1 << (x)))
-#define ISON_SIGNAL(x) (m23 & (byte)(0x10 << (x)))
-#define MAYBE_DRAW_SIGNAL(x,y,z) if (HAS_SIGNAL(x)) DrawSingleSignal(tile, ISON_SIGNAL(x), ((y-0x4FB) << 4)|(z))
-
- byte m23;
-
- m23 = (_m[tile].m3 >> 4) | (_m[tile].m2 & 0xF0);
+#define MAYBE_DRAW_SIGNAL(x,y,z) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, GetSingleSignalState(tile, x), y - 0x4FB, z)
if (!(rails & TRACK_BIT_Y)) {
if (!(rails & TRACK_BIT_X)) {