(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
* Codechange: Made npf.c use some map array accessing wrappers instead of direct access. * Codechange/Fix: Named every enum in tile.h. Fixes a nasty bug on MSVC where arrays would be initialised with zeroes (tnx Asterix_) * Removed magic numbers from tables in tile.c. * Added some explicit casts in tile.h.
This commit is contained in:
18
vehicle.c
18
vehicle.c
@@ -1736,7 +1736,7 @@ byte GetDirectionTowards(Vehicle *v, int x, int y)
|
||||
return (dir+((dirdiff&7)<5?1:-1)) & 7;
|
||||
}
|
||||
|
||||
byte GetVehicleTrackdir(const Vehicle* v)
|
||||
Trackdir GetVehicleTrackdir(const Vehicle* v)
|
||||
{
|
||||
if (v->vehstatus & VS_CRASHED) return 0xFF;
|
||||
|
||||
@@ -1744,28 +1744,28 @@ byte GetVehicleTrackdir(const Vehicle* v)
|
||||
{
|
||||
case VEH_Train:
|
||||
if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */
|
||||
return _dir_to_diag_trackdir[GetDepotDirection(v->tile, TRANSPORT_RAIL)]; /* Train in depot */
|
||||
return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_RAIL)); /* Train in depot */
|
||||
|
||||
if (v->u.rail.track == 0x40) /* train in tunnel, so just use his direction and assume a diagonal track */
|
||||
return _dir_to_diag_trackdir[(v->direction >> 1) & 3];
|
||||
return DiagdirToDiagTrackdir((v->direction >> 1) & 3);
|
||||
|
||||
return _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.rail.track)][v->direction];
|
||||
return TrackDirectionToTrackdir(FIND_FIRST_BIT(v->u.rail.track),v->direction);
|
||||
break;
|
||||
case VEH_Ship:
|
||||
if (v->u.ship.state == 0x80) /* Inside a depot? */
|
||||
/* We'll assume the ship is facing outwards */
|
||||
return _dir_to_diag_trackdir[GetDepotDirection(v->tile, TRANSPORT_WATER)]; /* Ship in depot */
|
||||
return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_WATER)); /* Ship in depot */
|
||||
|
||||
return _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.ship.state)][v->direction];
|
||||
return TrackDirectionToTrackdir(FIND_FIRST_BIT(v->u.ship.state),v->direction);
|
||||
break;
|
||||
case VEH_Road:
|
||||
if (v->u.road.state == 254) /* We'll assume the road vehicle is facing outwards */
|
||||
return _dir_to_diag_trackdir[GetDepotDirection(v->tile, TRANSPORT_ROAD)]; /* Road vehicle in depot */
|
||||
return DiagdirToDiagTrackdir(GetDepotDirection(v->tile, TRANSPORT_ROAD)); /* Road vehicle in depot */
|
||||
|
||||
if (IsRoadStationTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
|
||||
return _dir_to_diag_trackdir[GetRoadStationDir(v->tile)]; /* Road vehicle in a station */
|
||||
return DiagdirToDiagTrackdir(GetRoadStationDir(v->tile)); /* Road vehicle in a station */
|
||||
|
||||
return _dir_to_diag_trackdir[(v->direction >> 1) & 3];
|
||||
return DiagdirToDiagTrackdir((v->direction >> 1) & 3);
|
||||
break;
|
||||
/* case VEH_Aircraft: case VEH_Special: case VEH_Disaster: */
|
||||
default: return 0xFF;
|
||||
|
||||
Reference in New Issue
Block a user