summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-01-31 04:34:56 +0000
committertron <tron@openttd.org>2007-01-31 04:34:56 +0000
commitf5b41a2fbb5e164f1c103e7f6d3cd4babb2aaa84 (patch)
tree8afaea6febb39a36db50ccc890f5b6804c9e898b
parentd838a477e21ff1fe5c54e198462dd006d51227f7 (diff)
downloadopenttd-f5b41a2fbb5e164f1c103e7f6d3cd4babb2aaa84.tar.xz
(svn r8474) -Fix
Turn GetPrimaryRoadStop() into a method of struct Station
-rw-r--r--src/roadveh_cmd.cpp5
-rw-r--r--src/station.h7
-rw-r--r--src/station_cmd.cpp15
3 files changed, 10 insertions, 17 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 215cfa0fb..bed8f0a00 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -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) {
diff --git a/src/station.h b/src/station.h
index d7edfd427..a79fb3801 100644
--- a/src/station.h
+++ b/src/station.h
@@ -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);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 12b2f417b..b3ac6e70b 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -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;
}