1
0
Fork 0

(svn r5615) Move GetStationTileForVehicle() to its only user

release/0.5
tron 2006-07-26 10:00:33 +00:00
parent 0973dc78cd
commit 8ed7b09c52
3 changed files with 20 additions and 23 deletions

View File

@ -855,6 +855,24 @@ int32 CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return 0; return 0;
} }
static TileIndex GetStationTileForVehicle(const Vehicle* v, const Station* st)
{
switch (v->type) {
default: NOT_REACHED();
case VEH_Train: return st->train_tile;
case VEH_Aircraft: return st->airport_tile;
case VEH_Ship: return st->dock_tile;
case VEH_Road:
if (v->cargo_type == CT_PASSENGERS) {
return (st->bus_stops != NULL) ? st->bus_stops->xy : 0;
} else {
return (st->truck_stops != NULL) ? st->truck_stops->xy : 0;
}
}
}
/** /**
* *
* Check the orders of a vehicle, to see if there are invalid orders and stuff * Check the orders of a vehicle, to see if there are invalid orders and stuff
@ -879,7 +897,6 @@ void CheckOrders(const Vehicle* v)
if (v->owner == _local_player && v->day_counter % 20 == 0) { if (v->owner == _local_player && v->day_counter % 20 == 0) {
int n_st, problem_type = -1; int n_st, problem_type = -1;
const Order *order; const Order *order;
const Station *st;
int message = 0; int message = 0;
/* Check the order list */ /* Check the order list */
@ -893,11 +910,10 @@ void CheckOrders(const Vehicle* v)
} }
/* Does station have a load-bay for this vehicle? */ /* Does station have a load-bay for this vehicle? */
if (order->type == OT_GOTO_STATION) { if (order->type == OT_GOTO_STATION) {
TileIndex required_tile; const Station* st = GetStation(order->station);
TileIndex required_tile = GetStationTileForVehicle(v, st);
n_st++; n_st++;
st = GetStation(order->station);
required_tile = GetStationTileForVehicle(v, st);
if (required_tile == 0) problem_type = 3; if (required_tile == 0) problem_type = 3;
} }
} }

View File

@ -136,8 +136,6 @@ enum {
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st);
void ShowStationViewWindow(StationID station); void ShowStationViewWindow(StationID station);
void UpdateAllStationVirtCoord(void); void UpdateAllStationVirtCoord(void);

View File

@ -216,23 +216,6 @@ static Station* GetStationAround(TileIndex tile, int w, int h, StationID closest
return (closest_station == INVALID_STATION) ? NULL : GetStation(closest_station); return (closest_station == INVALID_STATION) ? NULL : GetStation(closest_station);
} }
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st)
{
switch (v->type) {
case VEH_Train: return st->train_tile;
case VEH_Aircraft: return st->airport_tile;
case VEH_Ship: return st->dock_tile;
case VEH_Road:
if (v->cargo_type == CT_PASSENGERS) {
return (st->bus_stops != NULL) ? st->bus_stops->xy : 0;
} else {
return (st->truck_stops != NULL) ? st->truck_stops->xy : 0;
}
default:
assert(false);
return 0;
}
}
static bool CheckStationSpreadOut(Station *st, TileIndex tile, int w, int h) static bool CheckStationSpreadOut(Station *st, TileIndex tile, int w, int h)
{ {