summaryrefslogtreecommitdiff
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
commit463cf2ec6bc487aaf3c1ca6a5ea4bcca56194254 (patch)
tree6a9a867d57cdc9d1a608088bf29d0b1186ef6934
parent7bce62899c796cc114224c159249c7b302d2deae (diff)
downloadopenttd-463cf2ec6bc487aaf3c1ca6a5ea4bcca56194254.tar.xz
(svn r3795) Add a function to request the orientation of a depot
-rw-r--r--road_cmd.c4
-rw-r--r--road_map.c2
-rw-r--r--road_map.h6
-rw-r--r--roadveh_cmd.c24
4 files changed, 22 insertions, 14 deletions
diff --git a/road_cmd.c b/road_cmd.c
index a4480b669..ca558e29c 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -803,7 +803,7 @@ static void DrawTile_Road(TileInfo *ti)
player = GetTileOwner(ti->tile);
if (player < MAX_PLAYERS) ormod = PLAYER_SPRITE_COLOR(player);
- drss = _road_display_datas[ti->map5 & 0xF];
+ drss = _road_display_datas[GetRoadDepotDirection(ti->tile)];
DrawGroundSprite(drss++->image);
@@ -1100,7 +1100,7 @@ static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
case ROAD_DEPOT:
if (v->type == VEH_Road && v->u.road.frame == 11) {
- if (_roadveh_enter_depot_unk0[GB(_m[tile].m5, 0, 2)] == v->u.road.state) {
+ if (_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
RoadVehEnterDepot(v);
return 4;
}
diff --git a/road_map.c b/road_map.c
index 14611e88b..3780334a3 100644
--- a/road_map.c
+++ b/road_map.c
@@ -16,7 +16,7 @@ RoadBits GetAnyRoadBits(TileIndex tile)
default:
case ROAD_NORMAL: return GetRoadBits(tile);
case ROAD_CROSSING: return GetCrossingRoadBits(tile);
- case ROAD_DEPOT: return DiagDirToRoadBits(GB(_m[tile].m5, 0, 2));
+ case ROAD_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile));
}
case MP_STATION:
diff --git a/road_map.h b/road_map.h
index 1aa3ea88c..6eccc3249 100644
--- a/road_map.h
+++ b/road_map.h
@@ -62,6 +62,12 @@ static inline RoadType GetRoadType(TileIndex tile)
}
+static inline DiagDirection GetRoadDepotDirection(TileIndex tile)
+{
+ return (DiagDirection)GB(_m[tile].m5, 0, 2);
+}
+
+
/**
* Returns the RoadBits on an arbitrary tile
* Special behavior:
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];