Changeset - r12500:5e5dd00d1e93
[Not reviewed]
master
0 13 0
rubidium - 15 years ago 2009-07-25 08:54:19
rubidium@openttd.org
(svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
13 files changed with 111 insertions and 128 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -179,9 +179,9 @@ static const Order *ResolveOrder(Vehicle
 

	
 
		case OT_GOTO_STATION: {
 
			const Station *st = ::Station::Get(order->GetDestination());
 
			if (st->train_tile != INVALID_TILE) {
 
				for (uint i = 0; i < st->trainst_w; i++) {
 
					TileIndex t = st->train_tile + TileDiffXY(i, 0);
 
			if (st->train_station.tile != INVALID_TILE) {
 
				for (uint i = 0; i < st->train_station.w; i++) {
 
					TileIndex t = st->train_station.tile + TileDiffXY(i, 0);
 
					if (st->TileBelongsToRailStation(t)) return t;
 
				}
 
			} else if (st->dock_tile != INVALID_TILE) {
src/base_station_base.h
Show inline comments
 
@@ -25,6 +25,11 @@ struct StationSpecList {
 

	
 
/** Represents the covered area */
 
struct TileArea {
 
	/** Just construct this tile area */
 
	TileArea() {}
 
	/** Construct this tile area with some set values */
 
	TileArea(TileIndex tile, uint8 w, uint8 h) : tile(tile), w(w), h(h) {}
 

	
 
	TileIndex tile; ///< The base tile of the area
 
	uint8 w;        ///< The width of the area
 
	uint8 h;        ///< The height of the area
src/newgrf_station.cpp
Show inline comments
 
@@ -628,7 +628,7 @@ static const SpriteGroup *StationResolve
 
			break;
 
	}
 

	
 
	if (HasBit(statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->trainst_w + st->trainst_h);
 
	if (HasBit(statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->train_station.w + st->train_station.h);
 
	cargo = min(0xfff, cargo);
 

	
 
	if (cargo > statspec->cargo_threshold) {
src/order_cmd.cpp
Show inline comments
 
@@ -1404,7 +1404,7 @@ static TileIndex GetStationTileForVehicl
 

	
 
	switch (v->type) {
 
		default: NOT_REACHED();
 
		case VEH_TRAIN:     return st->train_tile;
 
		case VEH_TRAIN:     return st->train_station.tile;
 
		case VEH_AIRCRAFT:  return st->airport_tile;
 
		case VEH_SHIP:      return st->dock_tile;
 
		case VEH_ROAD:      return st->GetPrimaryRoadStop(RoadVehicle::From(v))->xy;
src/pathfind.h
Show inline comments
 
@@ -83,7 +83,7 @@ void NewTrainPathfind(TileIndex tile, Ti
 
/**
 
 * Calculates the tile of given station that is closest to a given tile
 
 * for this we assume the station is a rectangle,
 
 * as defined by its top tile (st->train_tile) and its width/height (st->trainst_w, st->trainst_h)
 
 * as defined by its tile are (st->train_station)
 
 * @param station The station to calculate the distance to
 
 * @param tile The tile from where to calculate the distance
 
 * @return The closest station tile to the given tile.
 
@@ -96,12 +96,12 @@ static inline TileIndex CalcClosestStati
 
	const Station *st = Station::From(bst);
 

	
 
	/* If the rail station is (temporarily) not present, use the station sign to drive near the station */
 
	if (st->train_tile == INVALID_TILE) return st->xy;
 
	if (st->train_station.tile == INVALID_TILE) return st->xy;
 

	
 
	uint minx = TileX(st->train_tile);  // topmost corner of station
 
	uint miny = TileY(st->train_tile);
 
	uint maxx = minx + st->trainst_w - 1; // lowermost corner of station
 
	uint maxy = miny + st->trainst_h - 1;
 
	uint minx = TileX(st->train_station.tile);  // topmost corner of station
 
	uint miny = TileY(st->train_station.tile);
 
	uint maxx = minx + st->train_station.w - 1; // lowermost corner of station
 
	uint maxy = miny + st->train_station.h - 1;
 

	
 
	/* we are going the aim for the x coordinate of the closest corner
 
	 * but if we are between those coordinates, we will aim for our own x coordinate */
src/saveload/afterload.cpp
Show inline comments
 
@@ -387,17 +387,17 @@ bool AfterLoadGame()
 
	if (CheckSavegameVersion(2)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->train_tile != 0 && st->trainst_h == 0) {
 
			if (st->train_station.tile != 0 && st->train_station.h == 0) {
 
				uint n = _savegame_type == SGT_OTTD ? 4 : 3; // OTTD uses 4 bits per dimensions, TTD 3 bits
 
				uint w = GB(st->trainst_w, n, n);
 
				uint h = GB(st->trainst_w, 0, n);
 
				uint w = GB(st->train_station.w, n, n);
 
				uint h = GB(st->train_station.w, 0, n);
 

	
 
				if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h);
 
				if (GetRailStationAxis(st->train_station.tile) != AXIS_X) Swap(w, h);
 

	
 
				st->trainst_w = w;
 
				st->trainst_h = h;
 
				st->train_station.w = w;
 
				st->train_station.h = h;
 

	
 
				assert(GetStationIndex(st->train_tile + TileDiffXY(w - 1, h - 1)) == st->index);
 
				assert(GetStationIndex(st->train_station.tile + TileDiffXY(w - 1, h - 1)) == st->index);
 
			}
 
		}
 
	}
 
@@ -452,9 +452,9 @@ bool AfterLoadGame()
 
		/* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->airport_tile == 0) st->airport_tile = INVALID_TILE;
 
			if (st->dock_tile    == 0) st->dock_tile    = INVALID_TILE;
 
			if (st->train_tile   == 0) st->train_tile   = INVALID_TILE;
 
			if (st->airport_tile       == 0) st->airport_tile = INVALID_TILE;
 
			if (st->dock_tile          == 0) st->dock_tile    = INVALID_TILE;
 
			if (st->train_station.tile == 0) st->train_station.tile   = INVALID_TILE;
 
		}
 

	
 
		/* the same applies to Company::location_of_HQ */
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -772,10 +772,10 @@ static const OldChunks station_chunk[] =
 
	OCL_VAR ( OC_UINT32,   1, &_old_town_index ),
 

	
 
	OCL_NULL( 4 ), ///< bus/lorry tile
 
	OCL_SVAR(   OC_TILE, Station, train_tile ),
 
	OCL_SVAR(   OC_TILE, Station, train_station.tile ),
 
	OCL_SVAR(   OC_TILE, Station, airport_tile ),
 
	OCL_SVAR(   OC_TILE, Station, dock_tile ),
 
	OCL_SVAR(  OC_UINT8, Station, trainst_w ),
 
	OCL_SVAR(  OC_UINT8, Station, train_station.w ),
 

	
 
	OCL_NULL( 1 ),         ///< sort-index, no longer in use
 
	OCL_NULL( 2 ),         ///< sign-width, no longer in use
src/saveload/station_sl.cpp
Show inline comments
 
@@ -123,15 +123,15 @@ static const SaveLoad _old_station_desc[
 
	SLE_CONDVAR(Station, xy,                         SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, xy,                         SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDNULL(4, 0, 5),  ///< bus/lorry tile
 
	SLE_CONDVAR(Station, train_tile,                 SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, train_tile,                 SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, train_station.tile,         SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, train_station.tile,         SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport_tile,               SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, airport_tile,               SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, dock_tile,                  SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, dock_tile,                  SLE_UINT32,                  6, SL_MAX_VERSION),
 
	    SLE_REF(Station, town,                       REF_TOWN),
 
	    SLE_VAR(Station, trainst_w,                  SLE_UINT8),
 
	SLE_CONDVAR(Station, trainst_h,                  SLE_UINT8,                   2, SL_MAX_VERSION),
 
	    SLE_VAR(Station, train_station.w,            SLE_UINT8),
 
	SLE_CONDVAR(Station, train_station.h,            SLE_UINT8,                   2, SL_MAX_VERSION),
 

	
 
	SLE_CONDNULL(1, 0, 3),  ///< alpha_order
 

	
 
@@ -299,9 +299,9 @@ static const SaveLoad _station_desc[] = 
 
	SLE_WRITEBYTE(Station, facilities,                 FACIL_NONE),
 
	SLE_ST_INCLUDE(),
 

	
 
	      SLE_VAR(Station, train_tile,                 SLE_UINT32),
 
	      SLE_VAR(Station, trainst_w,                  SLE_UINT8),
 
	      SLE_VAR(Station, trainst_h,                  SLE_UINT8),
 
	      SLE_VAR(Station, train_station.tile,         SLE_UINT32),
 
	      SLE_VAR(Station, train_station.w,            SLE_UINT8),
 
	      SLE_VAR(Station, train_station.h,            SLE_UINT8),
 

	
 
	      SLE_REF(Station, bus_stops,                  REF_ROADSTOPS),
 
	      SLE_REF(Station, truck_stops,                REF_ROADSTOPS),
src/station.cpp
Show inline comments
 
@@ -39,7 +39,7 @@ BaseStation::~BaseStation()
 

	
 
Station::Station(TileIndex tile) :
 
	SpecializedStation<Station, false>(tile),
 
	train_tile(INVALID_TILE),
 
	train_station(INVALID_TILE, 0, 0),
 
	airport_tile(INVALID_TILE),
 
	dock_tile(INVALID_TILE),
 
	indtype(IT_INVALID),
 
@@ -156,7 +156,7 @@ void Station::AddFacility(StationFacilit
 

	
 
void Station::MarkTilesDirty(bool cargo_change) const
 
{
 
	TileIndex tile = this->train_tile;
 
	TileIndex tile = this->train_station.tile;
 
	int w, h;
 

	
 
	if (tile == INVALID_TILE) return;
 
@@ -170,8 +170,8 @@ void Station::MarkTilesDirty(bool cargo_
 
		if (this->num_specs == 0) return;
 
	}
 

	
 
	for (h = 0; h < trainst_h; h++) {
 
		for (w = 0; w < trainst_w; w++) {
 
	for (h = 0; h < train_station.h; h++) {
 
		for (w = 0; w < train_station.w; w++) {
 
			if (this->TileBelongsToRailStation(tile)) {
 
				MarkTileDirtyByTile(tile);
 
			}
 
@@ -226,13 +226,13 @@ uint Station::GetCatchmentRadius() const
 
	uint ret = CA_NONE;
 

	
 
	if (_settings_game.station.modified_catchment) {
 
		if (this->bus_stops    != NULL)         ret = max<uint>(ret, CA_BUS);
 
		if (this->truck_stops  != NULL)         ret = max<uint>(ret, CA_TRUCK);
 
		if (this->train_tile   != INVALID_TILE) ret = max<uint>(ret, CA_TRAIN);
 
		if (this->dock_tile    != INVALID_TILE) ret = max<uint>(ret, CA_DOCK);
 
		if (this->airport_tile != INVALID_TILE) ret = max<uint>(ret, this->Airport()->catchment);
 
		if (this->bus_stops          != NULL)         ret = max<uint>(ret, CA_BUS);
 
		if (this->truck_stops        != NULL)         ret = max<uint>(ret, CA_TRUCK);
 
		if (this->train_station.tile != INVALID_TILE) ret = max<uint>(ret, CA_TRAIN);
 
		if (this->dock_tile          != INVALID_TILE) ret = max<uint>(ret, CA_DOCK);
 
		if (this->airport_tile       != INVALID_TILE) ret = max<uint>(ret, this->Airport()->catchment);
 
	} else {
 
		if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_tile != INVALID_TILE || this->dock_tile != INVALID_TILE || this->airport_tile != INVALID_TILE) {
 
		if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_station.tile != INVALID_TILE || this->dock_tile != INVALID_TILE || this->airport_tile != INVALID_TILE) {
 
			ret = CA_UNMODIFIED;
 
		}
 
	}
src/station_base.h
Show inline comments
 
@@ -83,11 +83,11 @@ public:
 
		return GetAirport(airport_type);
 
	}
 

	
 
	RoadStop *bus_stops;
 
	RoadStop *truck_stops;
 
	TileIndex train_tile;
 
	TileIndex airport_tile;
 
	TileIndex dock_tile;
 
	RoadStop *bus_stops;    ///< All the road stops
 
	RoadStop *truck_stops;  ///< All the truck stops
 
	TileArea train_station; ///< Tile area the train station part covers
 
	TileIndex airport_tile; ///< The location of the airport
 
	TileIndex dock_tile;    ///< The location of the dock
 

	
 
	IndustryType indtype;   ///< Industry type to get the name from
 

	
 
@@ -97,9 +97,6 @@ public:
 
	byte time_since_unload;
 
	byte airport_type;
 

	
 
	/* trainstation width/height */
 
	byte trainst_w, trainst_h;
 

	
 
	uint64 airport_flags;   ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
 

	
 
	byte last_vehicle_type;
src/station_cmd.cpp
Show inline comments
 
@@ -370,9 +370,7 @@ void Station::GetTileArea(TileArea *ta, 
 
{
 
	switch (type) {
 
		case STATION_RAIL:
 
			ta->tile = this->train_tile;
 
			ta->w    = this->trainst_w;
 
			ta->h    = this->trainst_h;
 
			*ta = this->train_station;
 
			return;
 

	
 
		case STATION_AIRPORT:
 
@@ -733,39 +731,39 @@ static bool CanExpandRailStation(const S
 

	
 
	if (_settings_game.station.nonuniform_stations) {
 
		/* determine new size of train station region.. */
 
		int x = min(TileX(st->train_tile), TileX(cur_ta.tile));
 
		int y = min(TileY(st->train_tile), TileY(cur_ta.tile));
 
		new_ta.w = max(TileX(st->train_tile) + new_ta.w, TileX(cur_ta.tile) + cur_ta.w) - x;
 
		new_ta.h = max(TileY(st->train_tile) + new_ta.h, TileY(cur_ta.tile) + cur_ta.h) - y;
 
		int x = min(TileX(st->train_station.tile), TileX(cur_ta.tile));
 
		int y = min(TileY(st->train_station.tile), TileY(cur_ta.tile));
 
		new_ta.w = max(TileX(st->train_station.tile) + new_ta.w, TileX(cur_ta.tile) + cur_ta.w) - x;
 
		new_ta.h = max(TileY(st->train_station.tile) + new_ta.h, TileY(cur_ta.tile) + cur_ta.h) - y;
 
		new_ta.tile = TileXY(x, y);
 
	} else {
 
		/* do not allow modifying non-uniform stations,
 
		 * the uniform-stations code wouldn't handle it well */
 
		BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
 
		BEGIN_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
 
			if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
 
				_error_message = STR_NONUNIFORM_STATIONS_DISALLOWED;
 
				return false;
 
			}
 
		END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
 
		END_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
 

	
 
		/* check so the orientation is the same */
 
		if (GetRailStationAxis(st->train_tile) != axis) {
 
		if (GetRailStationAxis(st->train_station.tile) != axis) {
 
			_error_message = STR_NONUNIFORM_STATIONS_DISALLOWED;
 
			return false;
 
		}
 

	
 
		/* check if the new station adjoins the old station in either direction */
 
		if (new_ta.w == cur_ta.w && st->train_tile == cur_ta.tile + TileDiffXY(0, cur_ta.h)) {
 
		if (new_ta.w == cur_ta.w && st->train_station.tile == cur_ta.tile + TileDiffXY(0, cur_ta.h)) {
 
			/* above */
 
			new_ta.h += cur_ta.h;
 
		} else if (new_ta.w == cur_ta.w && st->train_tile == cur_ta.tile - TileDiffXY(0, new_ta.h)) {
 
		} else if (new_ta.w == cur_ta.w && st->train_station.tile == cur_ta.tile - TileDiffXY(0, new_ta.h)) {
 
			/* below */
 
			new_ta.tile -= TileDiffXY(0, new_ta.h);
 
			new_ta.h += cur_ta.h;
 
		} else if (new_ta.h == cur_ta.h && st->train_tile == cur_ta.tile + TileDiffXY(cur_ta.w, 0)) {
 
		} else if (new_ta.h == cur_ta.h && st->train_station.tile == cur_ta.tile + TileDiffXY(cur_ta.w, 0)) {
 
			/* to the left */
 
			new_ta.w += cur_ta.w;
 
		} else if (new_ta.h == cur_ta.h && st->train_tile == cur_ta.tile - TileDiffXY(new_ta.w, 0)) {
 
		} else if (new_ta.h == cur_ta.h && st->train_station.tile == cur_ta.tile - TileDiffXY(new_ta.w, 0)) {
 
			/* to the right */
 
			new_ta.tile -= TileDiffXY(new_ta.w, 0);
 
			new_ta.w += cur_ta.w;
 
@@ -872,7 +870,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
	if (h_org > _settings_game.station.station_spread || w_org > _settings_game.station.station_spread) return CMD_ERROR;
 

	
 
	/* these values are those that will be stored in train_tile and station_platforms */
 
	TileArea new_location = { tile_org, w_org, h_org };
 
	TileArea new_location(tile_org, w_org, h_org);
 

	
 
	/* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */
 
	StationID est = INVALID_STATION;
 
@@ -922,7 +920,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
		if (st->owner != _current_company)
 
			return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION);
 

	
 
		if (st->train_tile != INVALID_TILE) {
 
		if (st->train_station.tile != INVALID_TILE) {
 
			/* check if we want to expanding an already existing station? */
 
			if (!_settings_game.station.join_stations)
 
				return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_RAILROAD);
 
@@ -982,12 +980,9 @@ CommandCost CmdBuildRailroadStation(Tile
 
		ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL);
 
		if (CmdFailed(ret)) return ret;
 

	
 
		st->train_tile = new_location.tile;
 
		st->train_station = new_location;
 
		st->AddFacility(FACIL_TRAIN, new_location.tile);
 

	
 
		st->trainst_w = new_location.w;
 
		st->trainst_h = new_location.h;
 

	
 
		st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
 

	
 
		if (statspec != NULL) {
 
@@ -1075,58 +1070,54 @@ CommandCost CmdBuildRailroadStation(Tile
 

	
 
static void MakeRailStationAreaSmaller(Station *st)
 
{
 
	uint w = st->trainst_w;
 
	uint h = st->trainst_h;
 
	TileIndex tile = st->train_tile;
 
	TileArea ta = st->train_station;
 

	
 
restart:
 

	
 
	/* too small? */
 
	if (w != 0 && h != 0) {
 
	if (ta.w != 0 && ta.h != 0) {
 
		/* check the left side, x = constant, y changes */
 
		for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(0, i));) {
 
		for (uint i = 0; !st->TileBelongsToRailStation(ta.tile + TileDiffXY(0, i));) {
 
			/* the left side is unused? */
 
			if (++i == h) {
 
				tile += TileDiffXY(1, 0);
 
				w--;
 
			if (++i == ta.h) {
 
				ta.tile += TileDiffXY(1, 0);
 
				ta.w--;
 
				goto restart;
 
			}
 
		}
 

	
 
		/* check the right side, x = constant, y changes */
 
		for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(w - 1, i));) {
 
		for (uint i = 0; !st->TileBelongsToRailStation(ta.tile + TileDiffXY(ta.w - 1, i));) {
 
			/* the right side is unused? */
 
			if (++i == h) {
 
				w--;
 
			if (++i == ta.h) {
 
				ta.w--;
 
				goto restart;
 
			}
 
		}
 

	
 
		/* check the upper side, y = constant, x changes */
 
		for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, 0));) {
 
		for (uint i = 0; !st->TileBelongsToRailStation(ta.tile + TileDiffXY(i, 0));) {
 
			/* the left side is unused? */
 
			if (++i == w) {
 
				tile += TileDiffXY(0, 1);
 
				h--;
 
			if (++i == ta.w) {
 
				ta.tile += TileDiffXY(0, 1);
 
				ta.h--;
 
				goto restart;
 
			}
 
		}
 

	
 
		/* check the lower side, y = constant, x changes */
 
		for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, h - 1));) {
 
		for (uint i = 0; !st->TileBelongsToRailStation(ta.tile + TileDiffXY(i, ta.h - 1));) {
 
			/* the left side is unused? */
 
			if (++i == w) {
 
				h--;
 
			if (++i == ta.w) {
 
				ta.h--;
 
				goto restart;
 
			}
 
		}
 
	} else {
 
		tile = INVALID_TILE;
 
		ta.tile = INVALID_TILE;
 
	}
 

	
 
	st->trainst_w = w;
 
	st->trainst_h = h;
 
	st->train_tile = tile;
 
	st->train_station = ta;
 
}
 

	
 
/** Remove a single tile from a railroad station.
 
@@ -1234,7 +1225,7 @@ CommandCost CmdRemoveFromRailroadStation
 
		UpdateStationSignCoord(st);
 

	
 
		/* if we deleted the whole station, delete the train facility. */
 
		if (st->train_tile == INVALID_TILE) {
 
		if (st->train_station.tile == INVALID_TILE) {
 
			st->facilities &= ~FACIL_TRAIN;
 
			InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
			st->UpdateVirtCoord();
 
@@ -1270,49 +1261,49 @@ static CommandCost RemoveRailroadStation
 
	if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR;
 

	
 
	/* determine width and height of platforms */
 
	tile = st->train_tile;
 
	int w = st->trainst_w;
 
	int h = st->trainst_h;
 

	
 
	assert(w != 0 && h != 0);
 
	TileArea ta = st->train_station;
 

	
 
	assert(ta.w != 0 && ta.h != 0);
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	/* clear all areas of the station */
 
	do {
 
		int w_bak = w;
 
		int w_bak = ta.w;
 
		do {
 
			/* for nonuniform stations, only remove tiles that are actually train station tiles */
 
			if (st->TileBelongsToRailStation(tile)) {
 
				if (!EnsureNoVehicleOnGround(tile)) {
 
			if (st->TileBelongsToRailStation(ta.tile)) {
 
				if (!EnsureNoVehicleOnGround(ta.tile)) {
 
					return CMD_ERROR;
 
				}
 
				cost.AddCost(_price.remove_rail_station);
 
				if (flags & DC_EXEC) {
 
					/* read variables before the station tile is removed */
 
					Track track = GetRailStationTrack(tile);
 
					Owner owner = GetTileOwner(tile); // _current_company can be OWNER_WATER
 
					Track track = GetRailStationTrack(ta.tile);
 
					Owner owner = GetTileOwner(ta.tile); // _current_company can be OWNER_WATER
 
					Train *v = NULL;
 
					if (HasStationReservation(tile)) {
 
						v = GetTrainForReservation(tile, track);
 
					if (HasStationReservation(ta.tile)) {
 
						v = GetTrainForReservation(ta.tile, track);
 
						if (v != NULL) FreeTrainTrackReservation(v);
 
					}
 
					DoClearSquare(tile);
 
					AddTrackToSignalBuffer(tile, track, owner);
 
					YapfNotifyTrackLayoutChange(tile, track);
 
					DoClearSquare(ta.tile);
 
					AddTrackToSignalBuffer(ta.tile, track, owner);
 
					YapfNotifyTrackLayoutChange(ta.tile, track);
 
					if (v != NULL) TryPathReserve(v, true);
 
				}
 
			}
 
			tile += TileDiffXY(1, 0);
 
		} while (--w);
 
		w = w_bak;
 
		tile += TileDiffXY(-w, 1);
 
	} while (--h);
 
			ta.tile += TileDiffXY(1, 0);
 
		} while (--ta.w);
 
		ta.w = w_bak;
 
		ta.tile += TileDiffXY(-ta.w, 1);
 
	} while (--ta.h);
 

	
 
	if (flags & DC_EXEC) {
 
		st->rect.AfterRemoveRect(st, st->train_tile, st->trainst_w, st->trainst_h);
 

	
 
		st->train_tile = INVALID_TILE;
 
		st->trainst_w = st->trainst_h = 0;
 
		st->rect.AfterRemoveRect(st, st->train_station.tile, st->train_station.w, st->train_station.h);
 

	
 
		st->train_station.tile = INVALID_TILE;
 
		st->train_station.w = 0;
 
		st->train_station.h = 0;
 

	
 
		st->facilities &= ~FACIL_TRAIN;
 

	
 
		free(st->speclist);
 
@@ -2923,19 +2914,9 @@ void BuildOilRig(TileIndex tile)
 
	MakeOilrig(tile, st->index, GetWaterClass(tile));
 

	
 
	st->owner = OWNER_NONE;
 
	st->airport_flags = 0;
 
	st->airport_type = AT_OILRIG;
 
	st->xy = tile;
 
	st->bus_stops = NULL;
 
	st->truck_stops = NULL;
 
	st->airport_tile = tile;
 
	st->dock_tile = tile;
 
	st->train_tile = INVALID_TILE;
 
	st->had_vehicle_of_type = 0;
 
	st->time_since_load = 255;
 
	st->time_since_unload = 255;
 
	st->delete_ctr = 0;
 
	st->last_vehicle_type = VEH_INVALID;
 
	st->facilities = FACIL_AIRPORT | FACIL_DOCK;
 
	st->build_date = _date;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -4564,7 +4564,7 @@ void Train::OnNewDay()
 

	
 
		/* update destination */
 
		if (this->current_order.IsType(OT_GOTO_STATION)) {
 
			TileIndex tile = Station::Get(this->current_order.GetDestination())->train_tile;
 
			TileIndex tile = Station::Get(this->current_order.GetDestination())->train_station.tile;
 
			if (tile != INVALID_TILE) this->dest_tile = tile;
 
		}
 

	
src/water_cmd.cpp
Show inline comments
 
@@ -749,11 +749,11 @@ static void FloodVehicles(TileIndex tile
 
	if (!_settings_game.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
 
		const Station *st = Station::GetByTile(tile);
 

	
 
		BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
 
		BEGIN_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
 
			if (st->TileBelongsToRailStation(t)) {
 
				FindVehicleOnPos(tile, &z, &FloodVehicleProc);
 
			}
 
		END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
 
		END_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
 

	
 
		return;
 
	}
0 comments (0 inline, 0 general)