Changeset - r12064:dab8b4af4fd5
[Not reviewed]
master
0 1 0
smatz - 15 years ago 2009-05-31 09:34:40
smatz@openttd.org
(svn r16476) -Fix (r16475): wrong version of the patch
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/station.cpp
Show inline comments
 
@@ -33,97 +33,97 @@ INSTANTIATE_POOL_METHODS(RoadStop)
 
Station::Station(TileIndex tile)
 
{
 
	DEBUG(station, cDebugCtorLevel, "I+%3d", index);
 

	
 
	xy = tile;
 
	airport_tile = dock_tile = train_tile = INVALID_TILE;
 
	bus_stops = truck_stops = NULL;
 
	had_vehicle_of_type = 0;
 
	time_since_load = 255;
 
	time_since_unload = 255;
 
	delete_ctr = 0;
 
	facilities = 0;
 

	
 
	last_vehicle_type = VEH_INVALID;
 
	indtype = IT_INVALID;
 

	
 
	random_bits = 0; // Random() must be called when station is really built (DC_EXEC)
 
	waiting_triggers = 0;
 
}
 

	
 
/**
 
 * Clean up a station by clearing vehicle orders and invalidating windows.
 
 * Aircraft-Hangar orders need special treatment here, as the hangars are
 
 * actually part of a station (tiletype is STATION), but the order type
 
 * is OT_GOTO_DEPOT.
 
 */
 
Station::~Station()
 
{
 
	DEBUG(station, cDebugCtorLevel, "I-%3d", index);
 

	
 
	free(this->name);
 
	free(this->speclist);
 

	
 
	if (CleaningPool()) return;
 

	
 
	while (!loading_vehicles.empty()) {
 
		loading_vehicles.front()->LeaveStation();
 
	}
 

	
 
	Aircraft *a;
 
	FOR_ALL_AIRCRAFT(a) {
 
		if (!IsNormalAircraft(a)) continue;
 
		if (a->targetairport == this->index) a->targetairport = INVALID_STATION;
 
	}
 

	
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		/* Forget about this station if this station is removed */
 
		if (v->last_station_visited == destination && type == OT_GOTO_STATION) {
 
		if (v->last_station_visited == this->index) {
 
			v->last_station_visited = INVALID_STATION;
 
		}
 
	}
 

	
 
	MarkDirty();
 
	InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
 

	
 
	DeleteWindowById(WC_STATION_VIEW, index);
 
	WindowNumber wno = (index << 16) | VLW_STATION_LIST | this->owner;
 
	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 

	
 
	/* Now delete all orders that go to the station */
 
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
 

	
 
	/* Subsidies need removal as well */
 
	DeleteSubsidyWithStation(index);
 

	
 
	/* Remove all news items */
 
	DeleteStationNews(this->index);
 

	
 
	InvalidateWindowData(WC_SELECT_STATION, 0, 0);
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		goods[c].cargo.Truncate(0);
 
	}
 

	
 
	CargoPacket *cp;
 
	FOR_ALL_CARGOPACKETS(cp) {
 
		/* Don't allow cargo packets with invalid source station */
 
		if (cp->source == this->index) cp->source = INVALID_STATION;
 
	}
 
}
 

	
 

	
 
/**
 
 * Get the primary road stop (the first road stop) that the given vehicle can load/unload.
 
 * @param v the vehicle to get the first road stop for
 
 * @return the first roadstop that this vehicle can load at
 
 */
 
RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
 
{
 
	RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK);
 

	
 
	for (; rs != NULL; rs = rs->next) {
 
		/* The vehicle cannot go to this roadstop (different roadtype) */
0 comments (0 inline, 0 general)