Changeset - r12586:54de0e97d6e2
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-08-02 14:54:42
rubidium@openttd.org
(svn r17039) -Fix (r16988): segfault when removing rail with waypoint remover and vice versa
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -1180,49 +1180,50 @@ restart:
 
 * Remove a number of tiles from any rail station within the area.
 
 * @param ta the area to clear station tile from
 
 * @param affected_stations the stations affected
 
 * @param flags the command flags
 
 * @param removal_cost the cost for removing the tile
 
 * @tparam T the type of station to remove
 
 * @return the number of cleared tiles or an error
 
 */
 
template <class T>
 
CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected_stations, DoCommandFlag flags, Money removal_cost)
 
{
 
	/* Count of the number of tiles removed */
 
	int quantity = 0;
 

	
 
	/* Do the action for every tile into the area */
 
	TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
 
		/* Make sure the specified tile is a rail station */
 
		if (!HasStationTileRail(tile)) continue;
 

	
 
		/* If there is a vehicle on ground, do not allow to remove (flood) the tile */
 
		if (!EnsureNoVehicleOnGround(tile)) continue;
 

	
 
		/* Check ownership of station */
 
		T *st = T::GetByTile(tile);
 
		if (st != NULL && _current_company != OWNER_WATER && !CheckOwnership(st->owner)) continue;
 
		if (st == NULL) continue;
 
		if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) continue;
 

	
 
		/* Do not allow removing from stations if non-uniform stations are not enabled
 
		 * The check must be here to give correct error message
 
		 */
 
		if (!_settings_game.station.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED);
 

	
 
		/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
 
		quantity++;
 

	
 
		if (flags & DC_EXEC) {
 
			/* read variables before the station tile is removed */
 
			uint specindex = GetCustomStationSpecIndex(tile);
 
			Track track = GetRailStationTrack(tile);
 
			Owner owner = GetTileOwner(tile);
 
			RailType rt = GetRailType(tile);
 
			Train *v = NULL;
 

	
 
			if (HasStationReservation(tile)) {
 
				v = GetTrainForReservation(tile, track);
 
				if (v != NULL) {
 
					/* Free train reservation. */
 
					FreeTrainTrackReservation(v);
 
					if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
 
					Vehicle *temp = v;
0 comments (0 inline, 0 general)