mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 06:46:43 +00:00
(svn r8474) -Fix
Turn GetPrimaryRoadStop() into a method of struct Station
This commit is contained in:
parent
d838a477e2
commit
f5b41a2fbb
@ -690,8 +690,7 @@ static void ProcessRoadVehOrder(Vehicle *v)
|
||||
v->last_station_visited = INVALID_STATION;
|
||||
}
|
||||
|
||||
rs = GetPrimaryRoadStop(
|
||||
GetStation(order->dest),
|
||||
rs = GetStation(order->dest)->GetPrimaryRoadStop(
|
||||
v->cargo_type == CT_PASSENGERS ? RoadStop::BUS : RoadStop::TRUCK
|
||||
);
|
||||
|
||||
@ -1660,7 +1659,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
|
||||
/* update destination */
|
||||
if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) {
|
||||
Station* st = GetStation(v->current_order.dest);
|
||||
RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RoadStop::BUS : RoadStop::TRUCK);
|
||||
RoadStop* rs = st->GetPrimaryRoadStop(v->cargo_type == CT_PASSENGERS ? RoadStop::BUS : RoadStop::TRUCK);
|
||||
RoadStop* best = NULL;
|
||||
|
||||
if (rs != NULL) {
|
||||
|
@ -97,6 +97,12 @@ struct StationRect : public Rect {
|
||||
};
|
||||
|
||||
struct Station {
|
||||
public:
|
||||
RoadStop *GetPrimaryRoadStop(RoadStop::Type type) const
|
||||
{
|
||||
return type == RoadStop::BUS ? bus_stops : truck_stops;
|
||||
}
|
||||
|
||||
TileIndex xy;
|
||||
RoadStop *bus_stops;
|
||||
RoadStop *truck_stops;
|
||||
@ -270,7 +276,6 @@ const DrawTileSprites *GetStationTileLayout(byte gfx);
|
||||
void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
|
||||
|
||||
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type);
|
||||
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStop::Type type);
|
||||
uint GetNumRoadStops(const Station* st, RoadStop::Type type);
|
||||
RoadStop * AllocateRoadStop( void );
|
||||
void ClearSlot(Vehicle *v);
|
||||
|
@ -80,23 +80,12 @@ DEFINE_OLD_POOL(RoadStop, RoadStop, RoadStopPoolNewBlock, NULL)
|
||||
extern void UpdateAirplanesOnNewStation(Station *st);
|
||||
|
||||
|
||||
RoadStop* GetPrimaryRoadStop(const Station* st, RoadStop::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case RoadStop::BUS: return st->bus_stops;
|
||||
case RoadStop::TRUCK: return st->truck_stops;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type)
|
||||
{
|
||||
const Station* st = GetStationByTile(tile);
|
||||
RoadStop* rs;
|
||||
|
||||
for (rs = GetPrimaryRoadStop(st, type); rs->xy != tile; rs = rs->next) {
|
||||
for (rs = st->GetPrimaryRoadStop(type); rs->xy != tile; rs = rs->next) {
|
||||
assert(rs->next != NULL);
|
||||
}
|
||||
|
||||
@ -109,7 +98,7 @@ uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type)
|
||||
const RoadStop *rs;
|
||||
|
||||
assert(st != NULL);
|
||||
for (rs = GetPrimaryRoadStop(st, type); rs != NULL; rs = rs->next) num++;
|
||||
for (rs = st->GetPrimaryRoadStop(type); rs != NULL; rs = rs->next) num++;
|
||||
|
||||
return num;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user