diff options
author | tron <tron@openttd.org> | 2006-03-12 16:13:16 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-12 16:13:16 +0000 |
commit | eeb5bf41a152087031b0764d5d3b2783922b70ae (patch) | |
tree | 3d2526e7f2638131186fe93a08829d1bf29f22b5 | |
parent | 0100871412ac1b48aa64a87f2d88d8276212963e (diff) | |
download | openttd-eeb5bf41a152087031b0764d5d3b2783922b70ae.tar.xz |
(svn r3831) Add and use GetRailDepotDirection()
-rw-r--r-- | ai/default/default.c | 6 | ||||
-rw-r--r-- | depot.h | 3 | ||||
-rw-r--r-- | rail_cmd.c | 4 | ||||
-rw-r--r-- | rail_map.h | 6 | ||||
-rw-r--r-- | train_cmd.c | 8 | ||||
-rw-r--r-- | vehicle.c | 2 |
6 files changed, 19 insertions, 10 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index 41580720c..7ba7fb137 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -4,6 +4,7 @@ #include "../../openttd.h" #include "../../functions.h" #include "../../map.h" +#include "../../rail_map.h" #include "../../road_map.h" #include "../../tile.h" #include "../../player.h" @@ -3625,8 +3626,9 @@ pos_3: } else { static const byte _depot_bits[] = {0x19,0x16,0x25,0x2A}; - m5 &= 3; - if (GetRailTrackStatus(tile + TileOffsByDir(m5)) & _depot_bits[m5]) + DiagDirection dir = GetRailDepotDirection(tile); + + if (GetRailTrackStatus(tile + TileOffsByDir(dir)) & _depot_bits[dir]) return; DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); @@ -8,6 +8,7 @@ #include "direction.h" #include "pool.h" +#include "rail_map.h" #include "road_map.h" #include "tile.h" #include "variables.h" @@ -103,7 +104,7 @@ static inline DiagDirection GetDepotDirection(TileIndex tile, TransportType type switch (type) { - case TRANSPORT_RAIL: return (DiagDirection)GB(_m[tile].m5, 0, 2); + case TRANSPORT_RAIL: return GetRailDepotDirection(tile); case TRANSPORT_ROAD: return GetRoadDepotDirection(tile); case TRANSPORT_WATER: /* Water is stubborn, it stores the directions in a different order. */ diff --git a/rail_cmd.c b/rail_cmd.c index 8dc36a59d..034a8ad10 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1027,7 +1027,7 @@ static int32 RemoveTrainDepot(TileIndex tile, uint32 flags) return CMD_ERROR; if (flags & DC_EXEC) { - Track track = TrackdirToTrack(DiagdirToDiagTrackdir(GetDepotDirection(tile, TRANSPORT_RAIL))); + Track track = TrackdirToTrack(DiagdirToDiagTrackdir(GetRailDepotDirection(tile))); DoDeleteDepot(tile); SetSignalsOnBothDir(tile, track); @@ -2085,7 +2085,7 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) if (v->type != VEH_Train || !IsTileDepotType(tile, TRANSPORT_RAIL)) return 0; /* depot direction */ - dir = GetDepotDirection(tile, TRANSPORT_RAIL); + dir = GetRailDepotDirection(tile); /* calculate the point where the following wagon should be activated */ /* this depends on the length of the current vehicle */ diff --git a/rail_map.h b/rail_map.h index 9affa2247..ee407a384 100644 --- a/rail_map.h +++ b/rail_map.h @@ -8,6 +8,12 @@ #include "waypoint.h" +static inline DiagDirection GetRailDepotDirection(TileIndex t) +{ + return (DiagDirection)GB(_m[t].m5, 0, 2); +} + + static inline TrackBits GetRailWaypointBits(TileIndex t) { return _m[t].m5 & RAIL_WAYPOINT_TRACK_MASK ? TRACK_BIT_Y : TRACK_BIT_X; diff --git a/train_cmd.c b/train_cmd.c index bc2f28c57..c174937d8 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -540,7 +540,7 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags) v->engine_type = engine; - dir = GB(_m[tile].m5, 0, 2); + dir = GetRailDepotDirection(tile); v->direction = DiagDirToDir(dir); v->tile = tile; @@ -699,7 +699,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->unitnumber = unit_num; - dir = GB(_m[tile].m5, 0, 2); + dir = GetRailDepotDirection(tile); v->direction = DiagDirToDir(dir); v->tile = tile; @@ -3167,7 +3167,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v) if (x + 4 > 15 && (!CheckCompatibleRail(v, tile) || (IsTileDepotType(tile, TRANSPORT_RAIL) && - GetDepotDirection(tile, TRANSPORT_RAIL) == dir))) { + GetRailDepotDirection(tile) == dir))) { v->cur_speed = 0; ReverseTrainDirection(v); return false; @@ -3287,7 +3287,7 @@ static const byte _depot_track_ind[4] = {0,1,0,1}; void TrainEnterDepot(Vehicle *v, TileIndex tile) { - SetSignalsOnBothDir(tile, _depot_track_ind[GB(_m[tile].m5, 0, 2)]); + SetSignalsOnBothDir(tile, _depot_track_ind[GetRailDepotDirection(tile)]); if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v); @@ -1960,7 +1960,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v) switch (v->type) { case VEH_Train: if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */ - return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_RAIL)); /* Train in depot */ + return DiagdirToDiagTrackdir(GetRailDepotDirection(v->tile)); /* Train in depot */ if (v->u.rail.track == 0x40) /* train in tunnel, so just use his direction and assume a diagonal track */ return DiagdirToDiagTrackdir(DirToDiagDir(v->direction)); |