Changeset - r12237:db085a58789e
[Not reviewed]
master
0 4 0
smatz - 15 years ago 2009-06-26 10:45:20
smatz@openttd.org
(svn r16662) -Codechange: replace GetRoadStopByTile() by RoadStop::GetByTile()
4 files changed with 28 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/roadstop.cpp
Show inline comments
 
@@ -7,6 +7,7 @@
 
#include "station_map.h"
 
#include "core/pool_func.hpp"
 
#include "roadstop_base.h"
 
#include "station_base.h"
 

	
 
RoadStopPool _roadstop_pool("RoadStop");
 
INSTANTIATE_POOL_METHODS(RoadStop)
 
@@ -48,6 +49,23 @@ RoadStop *RoadStop::GetNextRoadStop(cons
 
	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()
 
{
 
	_roadstop_pool.CleanPool();
src/roadstop_base.h
Show inline comments
 
@@ -114,6 +114,8 @@ struct RoadStop : RoadStopPool::PoolItem
 
	}
 

	
 
	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)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -496,7 +496,7 @@ void RoadVehicle::UpdateDeltaXY(Directio
 

	
 
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 */
 
	rs->SetEntranceBusy(false);
 
@@ -1040,7 +1040,7 @@ static Trackdir RoadFindPathToDest(RoadV
 
			} else {
 
				/* Proper station type, check if there is free loading bay */
 
				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 */
 
					trackdirs = TRACKDIR_BIT_NONE;
 
				}
 
@@ -1491,7 +1491,7 @@ again:
 
				return false;
 
			}
 
			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
 
				 * 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) &&
 
			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);
 

	
 
		/* 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 */
 
				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) {
 
						/* Bay in next stop along is free - use it */
src/station_cmd.cpp
Show inline comments
 
@@ -56,17 +56,6 @@ bool IsHangar(TileIndex t)
 
	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)
 
{
 
	uint num = 0;
 
@@ -1513,10 +1502,10 @@ static CommandCost RemoveRoadStop(Statio
 
	RoadStop *cur_stop;
 
	if (is_truck) { // truck stop
 
		primary_stop = &st->truck_stops;
 
		cur_stop = GetRoadStopByTile(tile, ROADSTOP_TRUCK);
 
		cur_stop = RoadStop::GetByTile(tile, ROADSTOP_TRUCK);
 
	} else {
 
		primary_stop = &st->bus_stops;
 
		cur_stop = GetRoadStopByTile(tile, ROADSTOP_BUS);
 
		cur_stop = RoadStop::GetByTile(tile, ROADSTOP_BUS);
 
	}
 

	
 
	assert(cur_stop != NULL);
 
@@ -2560,7 +2549,7 @@ static VehicleEnterTileStatus VehicleEnt
 
		if (rv->state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)rv->state) && rv->frame == 0) {
 
			if (IsRoadStop(tile) && IsRoadVehFront(v)) {
 
				/* 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 (!rv->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
0 comments (0 inline, 0 general)