Mercurial > hg > openttd
changeset 3167:3d360e619f7d draft
(svn r3795) Add a function to request the orientation of a depot
author | tron <tron@openttd.org> |
---|---|
date | Wed, 08 Mar 2006 15:29:23 +0000 |
parents | 50848af4c1bb |
children | ee5658ed56d4 |
files | road_cmd.c road_map.c road_map.h roadveh_cmd.c |
diffstat | 4 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/road_cmd.c +++ b/road_cmd.c @@ -803,7 +803,7 @@ 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 @@ 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; }
--- a/road_map.c +++ b/road_map.c @@ -16,7 +16,7 @@ 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:
--- a/road_map.h +++ b/road_map.h @@ -62,6 +62,12 @@ } +static inline DiagDirection GetRoadDepotDirection(TileIndex tile) +{ + return (DiagDirection)GB(_m[tile].m5, 0, 2); +} + + /** * Returns the RoadBits on an arbitrary tile * Special behavior:
--- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -992,7 +992,6 @@ int best_track; uint best_dist, best_maxlen; uint i; - byte m5; { uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); @@ -1003,7 +1002,7 @@ 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 @@ 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 @@ 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];