mirror of https://github.com/OpenTTD/OpenTTD
(svn r3795) Add a function to request the orientation of a depot
parent
7bce62899c
commit
463cf2ec6b
|
@ -803,7 +803,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||||
player = GetTileOwner(ti->tile);
|
player = GetTileOwner(ti->tile);
|
||||||
if (player < MAX_PLAYERS) ormod = PLAYER_SPRITE_COLOR(player);
|
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);
|
DrawGroundSprite(drss++->image);
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
|
|
||||||
case ROAD_DEPOT:
|
case ROAD_DEPOT:
|
||||||
if (v->type == VEH_Road && v->u.road.frame == 11) {
|
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);
|
RoadVehEnterDepot(v);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ RoadBits GetAnyRoadBits(TileIndex tile)
|
||||||
default:
|
default:
|
||||||
case ROAD_NORMAL: return GetRoadBits(tile);
|
case ROAD_NORMAL: return GetRoadBits(tile);
|
||||||
case ROAD_CROSSING: return GetCrossingRoadBits(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:
|
case MP_STATION:
|
||||||
|
|
|
@ -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
|
* Returns the RoadBits on an arbitrary tile
|
||||||
* Special behavior:
|
* Special behavior:
|
||||||
|
|
|
@ -992,7 +992,6 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
|
||||||
int best_track;
|
int best_track;
|
||||||
uint best_dist, best_maxlen;
|
uint best_dist, best_maxlen;
|
||||||
uint i;
|
uint i;
|
||||||
byte m5;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
|
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 (IsTileType(tile, MP_STREET)) {
|
||||||
if (GetRoadType(tile) == ROAD_DEPOT && IsTileOwner(tile, v->owner)) {
|
if (GetRoadType(tile) == ROAD_DEPOT && IsTileOwner(tile, v->owner)) {
|
||||||
/* Road depot */
|
/* 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)) {
|
} else if (IsTileType(tile, MP_STATION) && IsRoadStationTile(tile)) {
|
||||||
if (IsTileOwner(tile, v->owner)) {
|
if (IsTileOwner(tile, v->owner)) {
|
||||||
|
@ -1073,24 +1072,27 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
|
||||||
return_track(ftd.best_trackdir);
|
return_track(ftd.best_trackdir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
DiagDirection dir;
|
||||||
|
|
||||||
if (IsTileType(desttile, MP_STREET)) {
|
if (IsTileType(desttile, MP_STREET)) {
|
||||||
m5 = _m[desttile].m5;
|
if (GetRoadType(desttile) == ROAD_DEPOT) {
|
||||||
if (GetRoadType(desttile) == ROAD_DEPOT) goto do_it;
|
dir = GetRoadDepotDirection(desttile);
|
||||||
|
goto do_it;
|
||||||
|
}
|
||||||
} else if (IsTileType(desttile, MP_STATION)) {
|
} else if (IsTileType(desttile, MP_STATION)) {
|
||||||
m5 = _m[desttile].m5;
|
if (IS_BYTE_INSIDE(_m[desttile].m5, 0x43, 0x4B)) {
|
||||||
if (IS_BYTE_INSIDE(m5, 0x43, 0x4B)) {
|
|
||||||
/* We are heading for a station */
|
/* We are heading for a station */
|
||||||
m5 -= 0x43;
|
dir = GetRoadStationDir(tile);
|
||||||
do_it:;
|
do_it:;
|
||||||
/* When we are heading for a depot or station, we just
|
/* When we are heading for a depot or station, we just
|
||||||
* pretend we are heading for the tile in front, we'll
|
* pretend we are heading for the tile in front, we'll
|
||||||
* see from there */
|
* see from there */
|
||||||
desttile += TileOffsByDir(m5 & 3);
|
desttile += TileOffsByDir(dir);
|
||||||
if (desttile == tile && bitmask&_road_pf_table_3[m5&3]) {
|
if (desttile == tile && bitmask & _road_pf_table_3[dir]) {
|
||||||
/* If we are already in front of the
|
/* If we are already in front of the
|
||||||
* station/depot and we can get in from here,
|
* station/depot and we can get in from here,
|
||||||
* we enter */
|
* 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;
|
v->cur_speed = 0;
|
||||||
|
|
||||||
dir = GB(_m[v->tile].m5, 0, 2);
|
dir = GetRoadDepotDirection(v->tile);
|
||||||
v->direction = DiagDirToDir(dir);
|
v->direction = DiagDirToDir(dir);
|
||||||
|
|
||||||
rd2 = _roadveh_data_2[dir];
|
rd2 = _roadveh_data_2[dir];
|
||||||
|
|
Loading…
Reference in New Issue