summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-08 15:29:23 +0000
committertron <tron@openttd.org>2006-03-08 15:29:23 +0000
commit86550c94bc2ac30202d3df1f72804faf43f8f202 (patch)
tree6a9a867d57cdc9d1a608088bf29d0b1186ef6934 /roadveh_cmd.c
parentc3fffd07f2eb0fe1ba85af99f61dbf9705e1a803 (diff)
downloadopenttd-86550c94bc2ac30202d3df1f72804faf43f8f202.tar.xz
(svn r3795) Add a function to request the orientation of a depot
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index b941f2e24..e49ac34b2 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -992,7 +992,6 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
int best_track;
uint best_dist, best_maxlen;
uint i;
- byte m5;
{
uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
@@ -1003,7 +1002,7 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
if (IsTileType(tile, MP_STREET)) {
if (GetRoadType(tile) == ROAD_DEPOT && IsTileOwner(tile, v->owner)) {
/* Road depot */
- bitmask |= _road_veh_fp_ax_or[GB(_m[tile].m5, 0, 2)];
+ bitmask |= _road_veh_fp_ax_or[GetRoadDepotDirection(tile)];
}
} else if (IsTileType(tile, MP_STATION) && IsRoadStationTile(tile)) {
if (IsTileOwner(tile, v->owner)) {
@@ -1073,24 +1072,27 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
return_track(ftd.best_trackdir);
}
} else {
+ DiagDirection dir;
+
if (IsTileType(desttile, MP_STREET)) {
- m5 = _m[desttile].m5;
- if (GetRoadType(desttile) == ROAD_DEPOT) goto do_it;
+ if (GetRoadType(desttile) == ROAD_DEPOT) {
+ dir = GetRoadDepotDirection(desttile);
+ goto do_it;
+ }
} else if (IsTileType(desttile, MP_STATION)) {
- m5 = _m[desttile].m5;
- if (IS_BYTE_INSIDE(m5, 0x43, 0x4B)) {
+ if (IS_BYTE_INSIDE(_m[desttile].m5, 0x43, 0x4B)) {
/* We are heading for a station */
- m5 -= 0x43;
+ dir = GetRoadStationDir(tile);
do_it:;
/* When we are heading for a depot or station, we just
* pretend we are heading for the tile in front, we'll
* see from there */
- desttile += TileOffsByDir(m5 & 3);
- if (desttile == tile && bitmask&_road_pf_table_3[m5&3]) {
+ desttile += TileOffsByDir(dir);
+ if (desttile == tile && bitmask & _road_pf_table_3[dir]) {
/* If we are already in front of the
* station/depot and we can get in from here,
* we enter */
- return_track(FindFirstBit2x64(bitmask&_road_pf_table_3[m5&3]));
+ return_track(FindFirstBit2x64(bitmask & _road_pf_table_3[dir]));
}
}
}
@@ -1196,7 +1198,7 @@ static void RoadVehController(Vehicle *v)
v->cur_speed = 0;
- dir = GB(_m[v->tile].m5, 0, 2);
+ dir = GetRoadDepotDirection(v->tile);
v->direction = DiagDirToDir(dir);
rd2 = _roadveh_data_2[dir];