summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes E. Krause <j.k@eclipso.de>2019-03-12 20:41:37 +0100
committerPeterN <peter@fuzzle.org>2019-03-13 07:47:32 +0000
commit43ced57794ca5546e5f5a18eb82990d20845967c (patch)
treee1ba30db0ea65f6cb0c0b73f1f5b5b1ce62a47b4
parente6798ffdca7d374ad23e35f56017a6777cf527ce (diff)
downloadopenttd-43ced57794ca5546e5f5a18eb82990d20845967c.tar.xz
Cleanup: Remove questionable syntax in track drawing
-rw-r--r--src/rail_cmd.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index aa4e7ab55..1c07932cd 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2285,23 +2285,30 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y;
} else {
/* track on flat ground */
- (image = rti->base_sprites.track_y, track == TRACK_BIT_Y) ||
- (image++, track == TRACK_BIT_X) ||
- (image++, track == TRACK_BIT_UPPER) ||
- (image++, track == TRACK_BIT_LOWER) ||
- (image++, track == TRACK_BIT_RIGHT) ||
- (image++, track == TRACK_BIT_LEFT) ||
- (image++, track == TRACK_BIT_CROSS) ||
-
- (image = rti->base_sprites.track_ns, track == TRACK_BIT_HORZ) ||
- (image++, track == TRACK_BIT_VERT) ||
-
- (junction = true, false) ||
- (image = rti->base_sprites.ground, (track & TRACK_BIT_3WAY_NE) == 0) ||
- (image++, (track & TRACK_BIT_3WAY_SW) == 0) ||
- (image++, (track & TRACK_BIT_3WAY_NW) == 0) ||
- (image++, (track & TRACK_BIT_3WAY_SE) == 0) ||
- (image++, true);
+ switch (track) {
+ /* single track, select combined track + ground sprite*/
+ case TRACK_BIT_Y: image = rti->base_sprites.track_y; break;
+ case TRACK_BIT_X: image = rti->base_sprites.track_y + 1; break;
+ case TRACK_BIT_UPPER: image = rti->base_sprites.track_y + 2; break;
+ case TRACK_BIT_LOWER: image = rti->base_sprites.track_y + 3; break;
+ case TRACK_BIT_RIGHT: image = rti->base_sprites.track_y + 4; break;
+ case TRACK_BIT_LEFT: image = rti->base_sprites.track_y + 5; break;
+ case TRACK_BIT_CROSS: image = rti->base_sprites.track_y + 6; break;
+
+ /* double diagonal track, select combined track + ground sprite*/
+ case TRACK_BIT_HORZ: image = rti->base_sprites.track_ns; break;
+ case TRACK_BIT_VERT: image = rti->base_sprites.track_ns + 1; break;
+
+ /* junction, select only ground sprite, handle track sprite later */
+ default:
+ junction = true;
+ if ((track & TRACK_BIT_3WAY_NE) == 0) { image = rti->base_sprites.ground; break; }
+ if ((track & TRACK_BIT_3WAY_SW) == 0) { image = rti->base_sprites.ground + 1; break; }
+ if ((track & TRACK_BIT_3WAY_NW) == 0) { image = rti->base_sprites.ground + 2; break; }
+ if ((track & TRACK_BIT_3WAY_SE) == 0) { image = rti->base_sprites.ground + 3; break; }
+ image = rti->base_sprites.ground + 4;
+ break;
+ }
}
switch (rgt) {