mirror of https://github.com/OpenTTD/OpenTTD
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
parent
f2e55319dd
commit
90554ee390
|
@ -7,6 +7,7 @@
|
||||||
#include "station_map.h"
|
#include "station_map.h"
|
||||||
#include "core/pool_func.hpp"
|
#include "core/pool_func.hpp"
|
||||||
#include "roadstop_base.h"
|
#include "roadstop_base.h"
|
||||||
|
#include "station_base.h"
|
||||||
|
|
||||||
RoadStopPool _roadstop_pool("RoadStop");
|
RoadStopPool _roadstop_pool("RoadStop");
|
||||||
INSTANTIATE_POOL_METHODS(RoadStop)
|
INSTANTIATE_POOL_METHODS(RoadStop)
|
||||||
|
@ -48,6 +49,23 @@ RoadStop *RoadStop::GetNextRoadStop(const RoadVehicle *v) const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a roadstop at given tile
|
||||||
|
* @param tile tile with roadstop
|
||||||
|
* @param type roadstop type
|
||||||
|
* @return pointer to RoadStop
|
||||||
|
* @pre there has to be roadstop of given type there!
|
||||||
|
*/
|
||||||
|
/* static */ RoadStop *RoadStop::GetByTile(TileIndex tile, RoadStopType type)
|
||||||
|
{
|
||||||
|
const Station *st = Station::GetByTile(tile);
|
||||||
|
|
||||||
|
for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) {
|
||||||
|
if (rs->xy == tile) return rs;
|
||||||
|
assert(rs->next != NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InitializeRoadStops()
|
void InitializeRoadStops()
|
||||||
{
|
{
|
||||||
_roadstop_pool.CleanPool();
|
_roadstop_pool.CleanPool();
|
||||||
|
|
|
@ -114,6 +114,8 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
|
||||||
}
|
}
|
||||||
|
|
||||||
RoadStop *GetNextRoadStop(const struct RoadVehicle *v) const;
|
RoadStop *GetNextRoadStop(const struct RoadVehicle *v) const;
|
||||||
|
|
||||||
|
static RoadStop *GetByTile(TileIndex tile, RoadStopType type);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_ROADSTOPS_FROM(var, start) FOR_ALL_ITEMS_FROM(RoadStop, roadstop_index, var, start)
|
#define FOR_ALL_ROADSTOPS_FROM(var, start) FOR_ALL_ITEMS_FROM(RoadStop, roadstop_index, var, start)
|
||||||
|
|
|
@ -496,7 +496,7 @@ void RoadVehicle::UpdateDeltaXY(Direction direction)
|
||||||
|
|
||||||
static void ClearCrashedStation(RoadVehicle *v)
|
static void ClearCrashedStation(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
|
RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
|
||||||
|
|
||||||
/* Mark the station entrance as not busy */
|
/* Mark the station entrance as not busy */
|
||||||
rs->SetEntranceBusy(false);
|
rs->SetEntranceBusy(false);
|
||||||
|
@ -1040,7 +1040,7 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection
|
||||||
} else {
|
} else {
|
||||||
/* Proper station type, check if there is free loading bay */
|
/* Proper station type, check if there is free loading bay */
|
||||||
if (!_settings_game.pf.roadveh_queue && IsStandardRoadStopTile(tile) &&
|
if (!_settings_game.pf.roadveh_queue && IsStandardRoadStopTile(tile) &&
|
||||||
!GetRoadStopByTile(tile, rstype)->HasFreeBay()) {
|
!RoadStop::GetByTile(tile, rstype)->HasFreeBay()) {
|
||||||
/* Station is full and RV queuing is off */
|
/* Station is full and RV queuing is off */
|
||||||
trackdirs = TRACKDIR_BIT_NONE;
|
trackdirs = TRACKDIR_BIT_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1491,7 +1491,7 @@ again:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsRoadStop(v->tile)) {
|
if (IsRoadStop(v->tile)) {
|
||||||
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
|
RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
|
||||||
|
|
||||||
/* Vehicle is leaving a road stop tile, mark bay as free
|
/* Vehicle is leaving a road stop tile, mark bay as free
|
||||||
* For drive-through stops, only do it if the vehicle stopped here */
|
* For drive-through stops, only do it if the vehicle stopped here */
|
||||||
|
@ -1640,7 +1640,7 @@ again:
|
||||||
GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
|
GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
|
||||||
v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
|
v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
|
||||||
|
|
||||||
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
|
RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
|
||||||
Station *st = Station::GetByTile(v->tile);
|
Station *st = Station::GetByTile(v->tile);
|
||||||
|
|
||||||
/* Vehicle is at the stop position (at a bay) in a road stop.
|
/* Vehicle is at the stop position (at a bay) in a road stop.
|
||||||
|
@ -1655,7 +1655,7 @@ again:
|
||||||
|
|
||||||
/* Check if next inline bay is free */
|
/* Check if next inline bay is free */
|
||||||
if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type) && GetStationIndex(v->tile) == GetStationIndex(next_tile)) {
|
if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type) && GetStationIndex(v->tile) == GetStationIndex(next_tile)) {
|
||||||
RoadStop *rs_n = GetRoadStopByTile(next_tile, type);
|
RoadStop *rs_n = RoadStop::GetByTile(next_tile, type);
|
||||||
|
|
||||||
if (rs_n->IsFreeBay(HasBit(v->state, RVS_USING_SECOND_BAY)) && rs_n->num_vehicles < RoadStop::MAX_VEHICLES) {
|
if (rs_n->IsFreeBay(HasBit(v->state, RVS_USING_SECOND_BAY)) && rs_n->num_vehicles < RoadStop::MAX_VEHICLES) {
|
||||||
/* Bay in next stop along is free - use it */
|
/* Bay in next stop along is free - use it */
|
||||||
|
|
|
@ -56,17 +56,6 @@ bool IsHangar(TileIndex t)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type)
|
|
||||||
{
|
|
||||||
const Station *st = Station::GetByTile(tile);
|
|
||||||
|
|
||||||
for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) {
|
|
||||||
if (rs->xy == tile) return rs;
|
|
||||||
assert(rs->next != NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint GetNumRoadStopsInStation(const Station *st, RoadStopType type)
|
static uint GetNumRoadStopsInStation(const Station *st, RoadStopType type)
|
||||||
{
|
{
|
||||||
uint num = 0;
|
uint num = 0;
|
||||||
|
@ -1513,10 +1502,10 @@ static CommandCost RemoveRoadStop(Station *st, DoCommandFlag flags, TileIndex ti
|
||||||
RoadStop *cur_stop;
|
RoadStop *cur_stop;
|
||||||
if (is_truck) { // truck stop
|
if (is_truck) { // truck stop
|
||||||
primary_stop = &st->truck_stops;
|
primary_stop = &st->truck_stops;
|
||||||
cur_stop = GetRoadStopByTile(tile, ROADSTOP_TRUCK);
|
cur_stop = RoadStop::GetByTile(tile, ROADSTOP_TRUCK);
|
||||||
} else {
|
} else {
|
||||||
primary_stop = &st->bus_stops;
|
primary_stop = &st->bus_stops;
|
||||||
cur_stop = GetRoadStopByTile(tile, ROADSTOP_BUS);
|
cur_stop = RoadStop::GetByTile(tile, ROADSTOP_BUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(cur_stop != NULL);
|
assert(cur_stop != NULL);
|
||||||
|
@ -2560,7 +2549,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i
|
||||||
if (rv->state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)rv->state) && rv->frame == 0) {
|
if (rv->state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)rv->state) && rv->frame == 0) {
|
||||||
if (IsRoadStop(tile) && IsRoadVehFront(v)) {
|
if (IsRoadStop(tile) && IsRoadVehFront(v)) {
|
||||||
/* Attempt to allocate a parking bay in a road stop */
|
/* Attempt to allocate a parking bay in a road stop */
|
||||||
RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile));
|
RoadStop *rs = RoadStop::GetByTile(tile, GetRoadStopType(tile));
|
||||||
|
|
||||||
if (IsDriveThroughStopTile(tile)) {
|
if (IsDriveThroughStopTile(tile)) {
|
||||||
if (!rv->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
|
if (!rv->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
|
||||||
|
|
Loading…
Reference in New Issue