diff options
author | tron <tron@openttd.org> | 2006-03-18 13:20:50 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-18 13:20:50 +0000 |
commit | d8dcedcfd23f4e875788087c054187fe37bd8a43 (patch) | |
tree | 3e6f1c59c1d5d2c85f13911e3728aa9619db888b | |
parent | b610872f35209ab796aae289c9a01c26b86f1b03 (diff) | |
download | openttd-d8dcedcfd23f4e875788087c054187fe37bd8a43.tar.xz |
(svn r3946) Add short hand names for common track combinations
-rw-r--r-- | rail.c | 12 | ||||
-rw-r--r-- | rail.h | 4 | ||||
-rw-r--r-- | rail_cmd.c | 56 | ||||
-rw-r--r-- | rail_map.h | 8 |
4 files changed, 42 insertions, 38 deletions
@@ -55,12 +55,12 @@ const TrackdirBits _track_crosses_trackdirs[] = { /* Maps a track to all tracks that make 90 deg turns with it. */ const TrackBits _track_crosses_tracks[] = { - TRACK_BIT_Y, /* TRACK_X */ - TRACK_BIT_X, /* TRACK_Y */ - TRACK_BIT_LEFT | TRACK_BIT_RIGHT, /* TRACK_UPPER */ - TRACK_BIT_LEFT | TRACK_BIT_RIGHT, /* TRACK_LOWER */ - TRACK_BIT_UPPER | TRACK_BIT_LOWER, /* TRACK_LEFT */ - TRACK_BIT_UPPER | TRACK_BIT_LOWER /* TRACK_RIGHT */ + TRACK_BIT_Y, /* TRACK_X */ + TRACK_BIT_X, /* TRACK_Y */ + TRACK_BIT_VERT, /* TRACK_UPPER */ + TRACK_BIT_VERT, /* TRACK_LOWER */ + TRACK_BIT_HORZ, /* TRACK_LEFT */ + TRACK_BIT_HORZ /* TRACK_RIGHT */ }; /* Maps a trackdir to the (4-way) direction the tile is exited when following @@ -500,9 +500,7 @@ static inline bool TracksOverlap(TrackBits bits) /* We know that there are at least two tracks present. When there are more * than 2 tracks, they will surely overlap. When there are two, they will * always overlap unless they are lower & upper or right & left. */ - return - bits != (TRACK_BIT_UPPER | TRACK_BIT_LOWER) && - bits != (TRACK_BIT_LEFT | TRACK_BIT_RIGHT); + return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT; } void DrawTrainDepotSprite(int x, int y, int image, RailType railtype); diff --git a/rail_cmd.c b/rail_cmd.c index 5b5c529e2..de303fa4a 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -122,9 +122,7 @@ static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags if ((flags & DC_NO_RAIL_OVERLAP) || type == RAIL_TYPE_SIGNALS) { /* If we are not allowed to overlap (flag is on for ai players or we have * signals on the tile), check that */ - return - future == (TRACK_BIT_UPPER | TRACK_BIT_LOWER) || - future == (TRACK_BIT_LEFT | TRACK_BIT_RIGHT); + return future == TRACK_BIT_HORZ || future == TRACK_BIT_VERT; } else { /* Normally, we may overlap and any combination is valid */ return true; @@ -136,7 +134,7 @@ static const byte _valid_tileh_slopes[][15] = { // set of normal ones { - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_X, @@ -164,18 +162,18 @@ static const byte _valid_tileh_slopes[][15] = { TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_LEFT, TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, TRACK_BIT_UPPER, TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_LEFT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, + TRACK_BIT_ALL, TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, + TRACK_BIT_ALL }, // allowed rail on coast tile @@ -186,18 +184,18 @@ static const byte _valid_tileh_slopes[][15] = { TRACK_BIT_Y|TRACK_BIT_LEFT|TRACK_BIT_LOWER, TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, TRACK_BIT_X|TRACK_BIT_RIGHT|TRACK_BIT_LOWER, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, TRACK_BIT_UPPER, TRACK_BIT_X|TRACK_BIT_LEFT|TRACK_BIT_UPPER, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, + TRACK_BIT_ALL, TRACK_BIT_Y|TRACK_BIT_RIGHT|TRACK_BIT_UPPER, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, - TRACK_BIT_X|TRACK_BIT_Y|TRACK_BIT_UPPER|TRACK_BIT_LOWER|TRACK_BIT_LEFT|TRACK_BIT_RIGHT, + TRACK_BIT_ALL, + TRACK_BIT_ALL }, }; @@ -707,8 +705,8 @@ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2) /* See if this is a valid track combination for signals, (ie, no overlap) */ TrackBits trackbits = GetTrackBits(tile); if (KILL_FIRST_BIT(trackbits) != 0 && /* More than one track present */ - trackbits != (TRACK_BIT_UPPER | TRACK_BIT_LOWER) && /* Horizontal parallel, non-intersecting tracks */ - trackbits != (TRACK_BIT_LEFT | TRACK_BIT_RIGHT) /* Vertical parallel, non-intersecting tracks */ + trackbits != TRACK_BIT_HORZ && + trackbits != TRACK_BIT_VERT ) return CMD_ERROR; } @@ -1292,16 +1290,16 @@ static void DrawTrackBits(TileInfo* ti, TrackBits track, bool earth, bool snow, (image++, track == TRACK_BIT_LOWER) || (image++, track == TRACK_BIT_RIGHT) || (image++, track == TRACK_BIT_LEFT) || - (image++, track == (TRACK_BIT_X | TRACK_BIT_Y)) || + (image++, track == TRACK_BIT_CROSS) || - (image = rti->base_sprites.track_ns, track == (TRACK_BIT_UPPER | TRACK_BIT_LOWER)) || - (image++, track == (TRACK_BIT_LEFT | TRACK_BIT_RIGHT)) || + (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_RIGHT | TRACK_BIT_UPPER | TRACK_BIT_X))) || - (image++, !(track & (TRACK_BIT_LEFT | TRACK_BIT_LOWER | TRACK_BIT_X))) || - (image++, !(track & (TRACK_BIT_LEFT | TRACK_BIT_UPPER | TRACK_BIT_Y))) || - (image++, !(track & (TRACK_BIT_RIGHT | TRACK_BIT_LOWER | TRACK_BIT_Y))) || + (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); if (ti->tileh != 0) { @@ -1890,7 +1888,7 @@ static void TileLoop_Track(TileIndex tile) PlayerID owner = GetTileOwner(tile); if (rail == (TRACK_BIT_LOWER | TRACK_BIT_RIGHT) || ( - !(rail & (TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT)) && + (rail & TRACK_BIT_3WAY_NW) == 0 && (rail & TRACK_BIT_X) )) { TileIndex n = tile + TileDiffXY(0, -1); @@ -1904,7 +1902,7 @@ static void TileLoop_Track(TileIndex tile) } if (rail == (TRACK_BIT_UPPER | TRACK_BIT_LEFT) || ( - !(rail & (TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT)) && + (rail & TRACK_BIT_3WAY_SE) == 0 && (rail & TRACK_BIT_X) )) { TileIndex n = tile + TileDiffXY(0, 1); @@ -1919,7 +1917,7 @@ static void TileLoop_Track(TileIndex tile) } if (rail == (TRACK_BIT_LOWER | TRACK_BIT_LEFT) || ( - !(rail & (TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT)) && + (rail & TRACK_BIT_3WAY_NE) == 0 && (rail & TRACK_BIT_Y) )) { TileIndex n = tile + TileDiffXY(-1, 0); @@ -1933,7 +1931,7 @@ static void TileLoop_Track(TileIndex tile) } if (rail == (TRACK_BIT_UPPER | TRACK_BIT_RIGHT) || ( - !(rail & (TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT)) && + (rail & TRACK_BIT_3WAY_SE) == 0 && (rail & TRACK_BIT_Y) )) { TileIndex n = tile + TileDiffXY(1, 0); diff --git a/rail_map.h b/rail_map.h index e03893470..42d790982 100644 --- a/rail_map.h +++ b/rail_map.h @@ -94,6 +94,14 @@ typedef enum TrackBits { TRACK_BIT_LOWER = 1U << TRACK_LOWER, TRACK_BIT_LEFT = 1U << TRACK_LEFT, TRACK_BIT_RIGHT = 1U << TRACK_RIGHT, + TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y, + TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER, + TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT, + TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT, + TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, + TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT, + TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT, + TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT, TRACK_BIT_MASK = 0x3FU } TrackBits; |