Changeset - r23954:8e43140b9a66
src/aircraft_cmd.cpp
Show inline comments
 
@@ -116,13 +116,12 @@ enum HelicopterRotorStates {
 
 * airports (like helipads only)
 
 * @param v vehicle looking for a hangar
 
 * @return the StationID if one is found, otherwise, INVALID_STATION
 
 */
 
static StationID FindNearestHangar(const Aircraft *v)
 
{
 
	const Station *st;
 
	uint best = 0;
 
	StationID index = INVALID_STATION;
 
	TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
 
	const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
 
	uint max_range = v->acache.cached_max_range_sqr;
 

	
 
@@ -137,13 +136,13 @@ static StationID FindNearestHangar(const
 
		} else {
 
			last_dest = GetTargetAirportIfValid(v);
 
			next_dest = Station::GetIfValid(v->GetNextStoppingStation().value);
 
		}
 
	}
 

	
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT) || !st->airport.HasHangar()) continue;
 

	
 
		const AirportFTAClass *afc = st->airport.GetFTA();
 

	
 
		/* don't crash the plane if we know it can't land at the airport */
 
		if ((afc->flags & AirportFTAClass::SHORT_STRIP) && (avi->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) continue;
src/base_station_base.h
Show inline comments
 
@@ -160,14 +160,12 @@ struct BaseStation : StationPool::PoolIt
 
		return (this->facilities & ~FACIL_WAYPOINT) != 0;
 
	}
 

	
 
	static void PostDestructor(size_t index);
 
};
 

	
 
#define FOR_ALL_BASE_STATIONS(var) FOR_ALL_ITEMS_FROM(BaseStation, station_index, var, 0)
 

	
 
/**
 
 * Class defining several overloaded accessors so we don't
 
 * have to cast base stations that often
 
 */
 
template <class T, bool Tis_waypoint>
 
struct SpecializedStation : public BaseStation {
 
@@ -249,11 +247,16 @@ struct SpecializedStation : public BaseS
 
	 */
 
	static inline const T *From(const BaseStation *st)
 
	{
 
		assert(IsExpected(st));
 
		return (const T *)st;
 
	}
 

	
 
	/**
 
	 * Returns an iterable ensemble of all valid stations of type T
 
	 * @param from index of the first station to consider
 
	 * @return an iterable ensemble of all valid stations of type T
 
	 */
 
	static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); }
 
};
 

	
 
#define FOR_ALL_BASE_STATIONS_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, station_index, var, 0) if (name::IsExpected(var))
 

	
 
#endif /* BASE_STATION_BASE_H */
src/disaster_vehicle.cpp
Show inline comments
 
@@ -705,14 +705,13 @@ static void Disaster_Zeppeliner_Init()
 
{
 
	if (!Vehicle::CanAllocateItem(2)) return;
 

	
 
	/* Pick a random place, unless we find a small airport */
 
	int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
 

	
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->airport.tile != INVALID_TILE && (st->airport.type == AT_SMALL || st->airport.type == AT_LARGE)) {
 
			x = (TileX(st->airport.tile) + 2) * TILE_SIZE;
 
			break;
 
		}
 
	}
 

	
src/economy.cpp
Show inline comments
 
@@ -109,16 +109,15 @@ static PriceMultipliers _price_base_mult
 
 * @return the value of the company.
 
 */
 
Money CalculateCompanyValue(const Company *c, bool including_loan)
 
{
 
	Owner owner = c->index;
 

	
 
	Station *st;
 
	uint num = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->owner == owner) num += CountBits((byte)st->facilities);
 
	}
 

	
 
	Money value = num * _price[PR_STATION_VALUE] * 25;
 

	
 
	Vehicle *v;
 
@@ -185,15 +184,13 @@ int UpdateCompanyRatingAndValue(Company 
 
		}
 
	}
 

	
 
	/* Count stations */
 
	{
 
		uint num = 0;
 
		const Station *st;
 

	
 
		FOR_ALL_STATIONS(st) {
 
		for (const Station *st : Station::Iterate()) {
 
			/* Only count stations that are actually serviced */
 
			if (st->owner == owner && (st->time_since_load <= 20 || st->time_since_unload <= 20)) num += CountBits((byte)st->facilities);
 
		}
 
		_score_part[owner][SCORE_STATIONS] = num;
 
	}
 

	
 
@@ -511,24 +508,22 @@ void ChangeOwnershipOfCompanyItems(Owner
 
	}
 

	
 
	/* Add airport infrastructure count of the old company to the new one. */
 
	if (new_owner != INVALID_OWNER) Company::Get(new_owner)->infrastructure.airport += Company::Get(old_owner)->infrastructure.airport;
 

	
 
	/* convert owner of stations (including deleted ones, but excluding buoys) */
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		if (st->owner == old_owner) {
 
			/* if a company goes bankrupt, set owner to OWNER_NONE so the sign doesn't disappear immediately
 
			 * also, drawing station window would cause reading invalid company's colour */
 
			st->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
 
		}
 
	}
 

	
 
	/* do the same for waypoints (we need to do this here so deleted waypoints are converted too) */
 
	Waypoint *wp;
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (Waypoint *wp : Waypoint::Iterate()) {
 
		if (wp->owner == old_owner) {
 
			wp->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
 
		}
 
	}
 

	
 
	Sign *si;
 
@@ -660,14 +655,13 @@ static void CompaniesGenStatistics()
 
		CompanyCheckBankrupt(c);
 
	}
 

	
 
	Backup<CompanyID> cur_company(_current_company, FILE_LINE);
 

	
 
	if (!_settings_game.economy.infrastructure_maintenance) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (const Station *st : Station::Iterate()) {
 
			cur_company.Change(st->owner);
 
			CommandCost cost(EXPENSES_PROPERTY, _price[PR_STATION_VALUE] >> 1);
 
			SubtractMoneyFromCompany(cost);
 
		}
 
	} else {
 
		/* Improved monthly infrastructure costs. */
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -53,14 +53,13 @@ void LinkGraphOverlay::RebuildCache()
 
	this->cached_stations.clear();
 
	if (this->company_mask == 0) return;
 

	
 
	DrawPixelInfo dpi;
 
	this->GetWidgetDpi(&dpi);
 

	
 
	const Station *sta;
 
	FOR_ALL_STATIONS(sta) {
 
	for (const Station *sta : Station::Iterate()) {
 
		if (sta->rect.IsEmpty()) continue;
 

	
 
		Point pta = this->GetStationMiddle(sta);
 

	
 
		StationID from = sta->index;
 
		StationLinkMap &seen_links = this->cached_links[from];
src/network/network_server.cpp
Show inline comments
 
@@ -1544,13 +1544,12 @@ void NetworkSocketHandler::SendCompanyIn
 
 * Populate the company stats.
 
 * @param stats the stats to update
 
 */
 
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
 
{
 
	const Vehicle *v;
 
	const Station *s;
 

	
 
	memset(stats, 0, sizeof(*stats) * MAX_COMPANIES);
 

	
 
	/* Go through all vehicles and count the type of vehicles */
 
	FOR_ALL_VEHICLES(v) {
 
		if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle()) continue;
 
@@ -1563,13 +1562,13 @@ void NetworkPopulateCompanyStats(Network
 
			default: continue;
 
		}
 
		stats[v->owner].num_vehicle[type]++;
 
	}
 

	
 
	/* Go through all stations and count the types of stations */
 
	FOR_ALL_STATIONS(s) {
 
	for (const Station *s : Station::Iterate()) {
 
		if (Company::IsValidID(s->owner)) {
 
			NetworkCompanyStats *npi = &stats[s->owner];
 

	
 
			if (s->facilities & FACIL_TRAIN)      npi->num_station[NETWORK_VEH_TRAIN]++;
 
			if (s->facilities & FACIL_TRUCK_STOP) npi->num_station[NETWORK_VEH_LORRY]++;
 
			if (s->facilities & FACIL_BUS_STOP)   npi->num_station[NETWORK_VEH_BUS]++;
src/openttd.cpp
Show inline comments
 
@@ -1310,14 +1310,13 @@ static void CheckCaches()
 
		byte buff[sizeof(VehicleCargoList)];
 
		memcpy(buff, &v->cargo, sizeof(VehicleCargoList));
 
		v->cargo.InvalidateCache();
 
		assert(memcmp(&v->cargo, buff, sizeof(VehicleCargoList)) == 0);
 
	}
 

	
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			byte buff[sizeof(StationCargoList)];
 
			memcpy(buff, &st->goods[c].cargo, sizeof(StationCargoList));
 
			st->goods[c].cargo.InvalidateCache();
 
			assert(memcmp(&st->goods[c].cargo, buff, sizeof(StationCargoList)) == 0);
 
		}
src/saveload/afterload.cpp
Show inline comments
 
@@ -263,14 +263,13 @@ static void InitializeWindowsAndCaches()
 
	FOR_ALL_INDUSTRIES(i) {
 
		if (i->psa != nullptr) {
 
			i->psa->feature = GSF_INDUSTRIES;
 
			i->psa->tile = i->location.tile;
 
		}
 
	}
 
	Station *s;
 
	FOR_ALL_STATIONS(s) {
 
	for (Station *s : Station::Iterate()) {
 
		if (s->airport.psa != nullptr) {
 
			s->airport.psa->feature = GSF_AIRPORTS;
 
			s->airport.psa->tile = s->airport.tile;
 
		}
 
	}
 
	Town *t;
 
@@ -584,20 +583,19 @@ bool AfterLoadGame()
 
	 * They had swapped width and height if station was built along the Y axis.
 
	 * TTO and TTD used 3 bits for width/height, while OpenTTD used 4.
 
	 * Because the data stored by TTDPatch are unusable for rail stations > 7x7,
 
	 * recompute the width and height. Doing this unconditionally for all old
 
	 * savegames simplifies the code. */
 
	if (IsSavegameVersionBefore(SLV_2)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			st->train_station.w = st->train_station.h = 0;
 
		}
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (!IsTileType(t, MP_STATION)) continue;
 
			if (_m[t].m5 > 7) continue; // is it a rail station tile?
 
			st = Station::Get(_m[t].m2);
 
			Station *st = Station::Get(_m[t].m2);
 
			assert(st->train_station.tile != 0);
 
			int dx = TileX(t) - TileX(st->train_station.tile);
 
			int dy = TileY(t) - TileY(st->train_station.tile);
 
			assert(dx >= 0 && dy >= 0);
 
			st->train_station.w = max<uint>(st->train_station.w, dx + 1);
 
			st->train_station.h = max<uint>(st->train_station.h, dy + 1);
 
@@ -647,14 +645,13 @@ bool AfterLoadGame()
 
			c->name = CopyFromOldName(c->name_1);
 
			if (c->name != nullptr) c->name_1 = STR_SV_UNNAMED;
 
			c->president_name = CopyFromOldName(c->president_name_1);
 
			if (c->president_name != nullptr) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
 
		}
 

	
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			st->name = CopyFromOldName(st->string_id);
 
			/* generating new name would be too much work for little effect, use the station name fallback */
 
			if (st->name != nullptr) st->string_id = STR_SV_STNAME_FALLBACK;
 
		}
 

	
 
		Town *t;
 
@@ -666,14 +663,13 @@ bool AfterLoadGame()
 

	
 
	/* From this point the old names array is cleared. */
 
	ResetOldNames();
 

	
 
	if (IsSavegameVersionBefore(SLV_106)) {
 
		/* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			if (st->airport.tile       == 0) st->airport.tile = INVALID_TILE;
 
			if (st->train_station.tile == 0) st->train_station.tile   = INVALID_TILE;
 
		}
 

	
 
		/* the same applies to Company::location_of_HQ */
 
		for (Company *c : Company::Iterate()) {
 
@@ -781,14 +777,13 @@ bool AfterLoadGame()
 
	CargoPacket::AfterLoad();
 

	
 
	/* Oilrig was moved from id 15 to 9. We have to do this conversion
 
	 * here as AfterLoadVehicles can check it indirectly via the newgrf
 
	 * code. */
 
	if (IsSavegameVersionBefore(SLV_139)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			if (st->airport.tile != INVALID_TILE && st->airport.type == 15) {
 
				st->airport.type = AT_OILRIG;
 
			}
 
		}
 
	}
 

	
 
@@ -1395,14 +1390,13 @@ bool AfterLoadGame()
 
		FOR_ALL_ROADVEHICLES(rv) {
 
			rv->vehstatus &= ~0x40;
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_26)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			st->last_vehicle_type = VEH_INVALID;
 
		}
 
	}
 

	
 
	YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
 

	
 
@@ -1417,23 +1411,21 @@ bool AfterLoadGame()
 

	
 
	if (!IsSavegameVersionBefore(SLV_27)) AfterLoadStations();
 

	
 
	/* Time starts at 0 instead of 1920.
 
	 * Account for this in older games by adding an offset */
 
	if (IsSavegameVersionBefore(SLV_31)) {
 
		Station *st;
 
		Waypoint *wp;
 
		Engine *e;
 
		Industry *i;
 
		Vehicle *v;
 

	
 
		_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		_cur_year += ORIGINAL_BASE_YEAR;
 

	
 
		FOR_ALL_STATIONS(st)  st->build_date      += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		FOR_ALL_WAYPOINTS(wp) wp->build_date      += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Station *st : Station::Iterate())   st->build_date      += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Waypoint *wp : Waypoint::Iterate()) wp->build_date      += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		FOR_ALL_ENGINES(e)    e->intro_date       += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Company *c : Company::Iterate()) c->inaugurated_year += ORIGINAL_BASE_YEAR;
 
		FOR_ALL_INDUSTRIES(i) i->last_prod_year   += ORIGINAL_BASE_YEAR;
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
@@ -1562,14 +1554,13 @@ bool AfterLoadGame()
 
		}
 
	}
 

	
 
	/* Buoys do now store the owner of the previous water tile, which can never
 
	 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */
 
	if (IsSavegameVersionBefore(SLV_46)) {
 
		Waypoint *wp;
 
		FOR_ALL_WAYPOINTS(wp) {
 
		for (Waypoint *wp : Waypoint::Iterate()) {
 
			if ((wp->facilities & FACIL_DOCK) != 0 && IsTileOwner(wp->xy, OWNER_NONE) && TileHeight(wp->xy) == 0) SetTileOwner(wp->xy, OWNER_WATER);
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_50)) {
 
		Aircraft *v;
 
@@ -1621,14 +1612,13 @@ bool AfterLoadGame()
 
				ClrBit(v->vehicle_flags, VF_LOADING_FINISHED);
 
			}
 
		}
 
	} else if (IsSavegameVersionBefore(SLV_59)) {
 
		/* For some reason non-loading vehicles could be in the station's loading vehicle list */
 

	
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			std::list<Vehicle *>::iterator iter;
 
			for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
 
				Vehicle *v = *iter;
 
				iter++;
 
				if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v);
 
			}
 
@@ -1701,14 +1691,13 @@ bool AfterLoadGame()
 
				_m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
 
			}
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_74)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				st->goods[c].last_speed = 0;
 
				if (st->goods[c].cargo.AvailableCount() != 0) SetBit(st->goods[c].status, GoodsEntry::GES_RATING);
 
			}
 
		}
 
	}
 
@@ -2034,14 +2023,13 @@ bool AfterLoadGame()
 
		FOR_ALL_SIGNS(si) {
 
			if (si->owner != OWNER_NONE && !Company::IsValidID(si->owner)) si->owner = OWNER_NONE;
 
		}
 

	
 
		/* Station can get named based on an industry type, but the current ones
 
		 * are not, so mark them as if they are not named by an industry. */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			st->indtype = IT_INVALID;
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_104)) {
 
		Aircraft *a;
 
@@ -2171,14 +2159,13 @@ bool AfterLoadGame()
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_114)) {
 
		/* There could be (deleted) stations with invalid owner, set owner to OWNER NONE.
 
		 * The conversion affects oil rigs and buoys too, but it doesn't matter as
 
		 * they have st->owner == OWNER_NONE already. */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			if (!Company::IsValidID(st->owner)) st->owner = OWNER_NONE;
 
		}
 
	}
 

	
 
	/* Trains could now stop in a specific location. */
 
	if (IsSavegameVersionBefore(SLV_117)) {
 
@@ -2210,14 +2197,13 @@ bool AfterLoadGame()
 
		/* We didn't store cargo payment yet, so make them for vehicles that are
 
		 * currently at a station and loading/unloading. If they don't get any
 
		 * payment anymore they just removed in the next load/unload cycle.
 
		 * However, some 0.7 versions might have cargo payment. For those we just
 
		 * add cargopayment for the vehicles that don't have it.
 
		 */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			std::list<Vehicle *>::iterator iter;
 
			for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
 
				/* There are always as many CargoPayments as Vehicles. We need to make the
 
				 * assert() in Pool::GetNew() happy by calling CanAllocateItem(). */
 
				assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
 
				assert(CargoPayment::CanAllocateItem());
 
@@ -2249,14 +2235,13 @@ bool AfterLoadGame()
 
			}
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_124) && !IsSavegameVersionBefore(SLV_1)) {
 
		/* The train station tile area was added, but for really old (TTDPatch) it's already valid. */
 
		Waypoint *wp;
 
		FOR_ALL_WAYPOINTS(wp) {
 
		for (Waypoint *wp : Waypoint::Iterate()) {
 
			if (wp->facilities & FACIL_TRAIN) {
 
				wp->train_station.tile = wp->xy;
 
				wp->train_station.w = 1;
 
				wp->train_station.h = 1;
 
			} else {
 
				wp->train_station.tile = INVALID_TILE;
 
@@ -2440,14 +2425,13 @@ bool AfterLoadGame()
 
				}
 
			}
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_140)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			if (st->airport.tile != INVALID_TILE) {
 
				st->airport.w = st->airport.GetSpec()->size_x;
 
				st->airport.h = st->airport.GetSpec()->size_y;
 
			}
 
		}
 
	}
 
@@ -2545,18 +2529,17 @@ bool AfterLoadGame()
 
		}
 

	
 
		/* Waypoints with custom name may have a non-unique town_cn,
 
		 * renumber those. First set all affected waypoints to the
 
		 * highest possible number to get them numbered in the
 
		 * order they have in the pool. */
 
		Waypoint *wp;
 
		FOR_ALL_WAYPOINTS(wp) {
 
		for (Waypoint *wp : Waypoint::Iterate()) {
 
			if (wp->name != nullptr) wp->town_cn = UINT16_MAX;
 
		}
 

	
 
		FOR_ALL_WAYPOINTS(wp) {
 
		for (Waypoint* wp : Waypoint::Iterate()) {
 
			if (wp->name != nullptr) MakeDefaultName(wp);
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_152)) {
 
		_industry_builder.Reset(); // Initialize industry build data.
 
@@ -2803,14 +2786,13 @@ bool AfterLoadGame()
 
					ind->psa = nullptr;
 
				}
 
			}
 
		}
 

	
 
		if (!IsSavegameVersionBefore(SLV_145)) {
 
			Station *st;
 
			FOR_ALL_STATIONS(st) {
 
			for (Station *st : Station::Iterate()) {
 
				if (!(st->facilities & FACIL_AIRPORT)) continue;
 
				assert(st->airport.psa != nullptr);
 

	
 
				/* Check if the old storage was empty. */
 
				bool is_empty = true;
 
				for (uint i = 0; i < sizeof(st->airport.psa->storage); i++) {
 
@@ -3139,14 +3121,13 @@ bool AfterLoadGame()
 

	
 
	if (IsSavegameVersionBefore(SLV_SERVE_NEUTRAL_INDUSTRIES)) {
 
		/* Ensure the original neutral industry/station behaviour is used */
 
		_settings_game.station.serve_neutral_industries = true;
 

	
 
		/* Link oil rigs to their industry and back. */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			if (IsTileType(st->xy, MP_STATION) && IsOilRig(st->xy)) {
 
				/* Industry tile is always adjacent during construction by TileDiffXY(0, 1) */
 
				st->industry = Industry::GetByTile(st->xy + TileDiffXY(0, 1));
 
				st->industry->neutral_station = st;
 
			}
 
		}
 
@@ -3175,25 +3156,23 @@ bool AfterLoadGame()
 
			if (IsTileType(t, MP_STATION)) {
 
				if (IsDock(t) || IsOilRig(t)) Station::GetByTile(t)->ship_station.Add(t);
 
			}
 
		}
 

	
 
		/* Scan for docking tiles */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			if (st->ship_station.tile != INVALID_TILE) UpdateStationDockingTiles(st);
 
		}
 
	}
 

	
 
	/* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */
 
	Station::RecomputeCatchmentForAll();
 

	
 
	/* Station acceptance is some kind of cache */
 
	if (IsSavegameVersionBefore(SLV_127)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
 
		for (Station *st : Station::Iterate()) UpdateStationAcceptance(st, false);
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
 
	AfterLoadLabelMaps();
 
	AfterLoadCompanyStats();
src/saveload/cargopacket_sl.cpp
Show inline comments
 
@@ -39,14 +39,13 @@
 

	
 
		/* Store position of the station where the goods come from, so there
 
		 * are no very high payments when stations get removed. However, if the
 
		 * station where the goods came from is already removed, the source
 
		 * information is lost. In that case we set it to the position of this
 
		 * station */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				GoodsEntry *ge = &st->goods[c];
 

	
 
				const StationCargoPacketMap *packets = ge->cargo.Packets();
 
				for (StationCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
 
					CargoPacket *cp = *it;
 
@@ -69,14 +68,13 @@
 
		/* Only since version 68 we have cargo packets. Savegames from before used
 
		 * 'new CargoPacket' + cargolist.Append so their caches are already
 
		 * correct and do not need rebuilding. */
 
		Vehicle *v;
 
		FOR_ALL_VEHICLES(v) v->cargo.InvalidateCache();
 

	
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (Station *st : Station::Iterate()) {
 
			for (CargoID c = 0; c < NUM_CARGO; c++) st->goods[c].cargo.InvalidateCache();
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_181)) {
 
		Vehicle *v;
src/saveload/company_sl.cpp
Show inline comments
 
@@ -94,14 +94,13 @@ CompanyManagerFace ConvertFromOldCompany
 
void AfterLoadCompanyStats()
 
{
 
	/* Reset infrastructure statistics to zero. */
 
	for (Company *c : Company::Iterate()) MemSetT(&c->infrastructure, 0);
 

	
 
	/* Collect airport count. */
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if ((st->facilities & FACIL_AIRPORT) && Company::IsValidID(st->owner)) {
 
			Company::Get(st->owner)->infrastructure.airport++;
 
		}
 
	}
 

	
 
	Company *c;
src/saveload/station_sl.cpp
Show inline comments
 
@@ -54,14 +54,13 @@ void MoveBuoysToWaypoints()
 
		if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
 

	
 
		UpdateWaypointOrder(&v->current_order);
 
	}
 

	
 
	/* Now make the stations waypoints */
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) continue;
 

	
 
		StationID index    = st->index;
 
		TileIndex xy       = st->xy;
 
		Town *town         = st->town;
 
		StringID string_id = st->string_id;
 
@@ -106,14 +105,13 @@ void MoveBuoysToWaypoints()
 
	}
 
}
 

	
 
void AfterLoadStations()
 
{
 
	/* Update the speclists of all stations to point to the currently loaded custom stations. */
 
	BaseStation *st;
 
	FOR_ALL_BASE_STATIONS(st) {
 
	for (BaseStation *st : BaseStation::Iterate()) {
 
		for (uint i = 0; i < st->num_specs; i++) {
 
			if (st->speclist[i].grfid == 0) continue;
 

	
 
			st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
 
		}
 

	
 
@@ -373,14 +371,13 @@ static void Load_STNS()
 
static void Ptrs_STNS()
 
{
 
	/* Don't run when savegame version is higher than or equal to 123. */
 
	if (!IsSavegameVersionBefore(SLV_123)) return;
 

	
 
	uint num_cargo = IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		if (!IsSavegameVersionBefore(SLV_68)) {
 
			for (CargoID i = 0; i < num_cargo; i++) {
 
				GoodsEntry *ge = &st->goods[i];
 
				SwapPackets(ge);
 
				SlObject(ge, GetGoodsDesc());
 
				SwapPackets(ge);
 
@@ -511,15 +508,14 @@ static void RealSave_STNN(BaseStation *b
 
		SlObject(&bst->speclist[i], _station_speclist_desc);
 
	}
 
}
 

	
 
static void Save_STNN()
 
{
 
	BaseStation *st;
 
	/* Write the stations */
 
	FOR_ALL_BASE_STATIONS(st) {
 
	for (BaseStation *st : BaseStation::Iterate()) {
 
		SlSetArrayIndex(st->index);
 
		SlAutolength((AutolengthProc*)RealSave_STNN, st);
 
	}
 
}
 

	
 
static void Load_STNN()
 
@@ -585,14 +581,13 @@ static void Load_STNN()
 
static void Ptrs_STNN()
 
{
 
	/* Don't run when savegame version lower than 123. */
 
	if (IsSavegameVersionBefore(SLV_123)) return;
 

	
 
	uint num_cargo = IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		for (CargoID i = 0; i < num_cargo; i++) {
 
			GoodsEntry *ge = &st->goods[i];
 
			if (IsSavegameVersionBefore(SLV_183)) {
 
				SwapPackets(ge);
 
				SlObject(ge, GetGoodsDesc());
 
				SwapPackets(ge);
 
@@ -603,14 +598,13 @@ static void Ptrs_STNN()
 
				}
 
			}
 
		}
 
		SlObject(st, _station_desc);
 
	}
 

	
 
	Waypoint *wp;
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (Waypoint *wp : Waypoint::Iterate()) {
 
		SlObject(wp, _waypoint_desc);
 
	}
 
}
 

	
 
static void Save_ROADSTOP()
 
{
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -162,14 +162,13 @@ void ConvertOldMultiheadToNew()
 

	
 

	
 
/** need to be called to load aircraft from old version */
 
void UpdateOldAircraft()
 
{
 
	/* set airport_flags to 0 for all airports just to be sure */
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		st->airport.flags = 0; // reset airport
 
	}
 

	
 
	Aircraft *a;
 
	FOR_ALL_AIRCRAFT(a) {
 
		/* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
src/script/api/script_depotlist.cpp
Show inline comments
 
@@ -23,14 +23,13 @@ ScriptDepotList::ScriptDepotList(ScriptT
 
		case ScriptTile::TRANSPORT_ROAD:  tile_type = ::MP_ROAD; break;
 
		case ScriptTile::TRANSPORT_RAIL:  tile_type = ::MP_RAILWAY; break;
 
		case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break;
 

	
 
		case ScriptTile::TRANSPORT_AIR: {
 
			/* Hangars are not seen as real depots by the depot code. */
 
			const Station *st;
 
			FOR_ALL_STATIONS(st) {
 
			for (const Station *st : Station::Iterate()) {
 
				if (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) {
 
					for (uint i = 0; i < st->airport.GetNumHangars(); i++) {
 
						this->AddItem(st->airport.GetHangarTile(i));
 
					}
 
				}
 
			}
src/script/api/script_stationlist.cpp
Show inline comments
 
@@ -15,14 +15,13 @@
 
#include "../../vehicle_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptStationList::ScriptStationList(ScriptStation::StationType station_type)
 
{
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		if ((st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (st->facilities & station_type) != 0) this->AddItem(st->index);
 
	}
 
}
 

	
 
ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
 
{
src/script/api/script_town.cpp
Show inline comments
 
@@ -343,14 +343,13 @@
 
	const Town *t = ::Town::Get(town_id);
 
	if (_settings_game.economy.station_noise_level) {
 
		return t->MaxTownNoise() - t->noise_reached;
 
	}
 

	
 
	int num = 0;
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
 
	}
 
	return max(0, 2 - num);
 
}
 

	
 
/* static */ ScriptTown::RoadLayout ScriptTown::GetRoadLayout(TownID town_id)
src/script/api/script_waypointlist.cpp
Show inline comments
 
@@ -14,14 +14,13 @@
 
#include "../../waypoint_base.h"
 

	
 
#include "../../safeguards.h"
 

	
 
ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type)
 
{
 
	const Waypoint *wp;
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (const Waypoint *wp : Waypoint::Iterate()) {
 
		if ((wp->facilities & waypoint_type) &&
 
				(wp->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || wp->owner == OWNER_NONE)) this->AddItem(wp->index);
 
	}
 
}
 

	
 
ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id)
src/settings.cpp
Show inline comments
 
@@ -1230,14 +1230,13 @@ static bool CheckFreeformEdges(int32 p1)
 
			/* Check if there is a ship on the northern border. */
 
			if (TileX(s->tile) == 0 || TileY(s->tile) == 0) {
 
				ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_EMPTY, INVALID_STRING_ID, WL_ERROR);
 
				return false;
 
			}
 
		}
 
		BaseStation *st;
 
		FOR_ALL_BASE_STATIONS(st) {
 
		for (const BaseStation *st : BaseStation::Iterate()) {
 
			/* Check if there is a non-deleted buoy on the northern border. */
 
			if (st->IsInUse() && (TileX(st->xy) == 0 || TileY(st->xy) == 0)) {
 
				ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_EMPTY, INVALID_STRING_ID, WL_ERROR);
 
				return false;
 
			}
 
		}
src/station.cpp
Show inline comments
 
@@ -39,14 +39,13 @@ INSTANTIATE_POOL_METHODS(Station)
 

	
 
StationKdtree _station_kdtree(Kdtree_StationXYFunc);
 

	
 
void RebuildStationKdtree()
 
{
 
	std::vector<StationID> stids;
 
	BaseStation *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		stids.push_back(st->index);
 
	}
 
	_station_kdtree.Build(stids.begin(), stids.end());
 
}
 

	
 

	
 
@@ -477,14 +476,13 @@ void Station::RecomputeCatchment()
 
/**
 
 * Recomputes catchment of all stations.
 
 * This will additionally recompute nearby stations for all towns and industries.
 
 */
 
/* static */ void Station::RecomputeCatchmentForAll()
 
{
 
	Station *st;
 
	FOR_ALL_STATIONS(st) { st->RecomputeCatchment(); }
 
	for (Station *st : Station::Iterate()) { st->RecomputeCatchment(); }
 
}
 

	
 
/************************************************************************/
 
/*                     StationRect implementation                       */
 
/************************************************************************/
 

	
 
@@ -657,14 +655,13 @@ StationRect& StationRect::operator = (co
 
 * @return Total cost.
 
 */
 
Money AirportMaintenanceCost(Owner owner)
 
{
 
	Money total_cost = 0;
 

	
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->owner == owner && (st->facilities & FACIL_AIRPORT)) {
 
			total_cost += _price[PR_INFRASTRUCTURE_AIRPORT] * st->airport.GetSpec()->maintenance_cost;
 
		}
 
	}
 
	/* 3 bits fraction for the maintenance cost factor. */
 
	return total_cost >> 3;
src/station_base.h
Show inline comments
 
@@ -522,14 +522,12 @@ public:
 

	
 
	uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override;
 

	
 
	void GetTileArea(TileArea *ta, StationType type) const override;
 
};
 

	
 
#define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var)
 

	
 
/** Iterator to iterate over all tiles belonging to an airport. */
 
class AirportTileIterator : public OrthogonalTileIterator {
 
private:
 
	const Station *st; ///< The station the airport is a part of.
 

	
 
public:
src/station_cmd.cpp
Show inline comments
 
@@ -248,14 +248,13 @@ static StringID GenerateStationName(Stat
 
	const Town *t = st->town;
 
	uint32 free_names = UINT32_MAX;
 

	
 
	bool indtypes[NUM_INDUSTRYTYPES];
 
	memset(indtypes, 0, sizeof(indtypes));
 

	
 
	const Station *s;
 
	FOR_ALL_STATIONS(s) {
 
	for (const Station *s : Station::Iterate()) {
 
		if (s != st && s->town == t) {
 
			if (s->indtype != IT_INVALID) {
 
				indtypes[s->indtype] = true;
 
				StringID name = GetIndustrySpec(s->indtype)->station_name;
 
				if (name != STR_UNDEFINED) {
 
					/* Filter for other industrytypes with the same name */
 
@@ -446,15 +445,13 @@ void Station::MoveSign(TileIndex new_xy)
 
	_station_kdtree.Insert(this->index);
 
}
 

	
 
/** Update the virtual coords needed to draw the station sign for all stations. */
 
void UpdateAllStationVirtCoords()
 
{
 
	BaseStation *st;
 

	
 
	FOR_ALL_BASE_STATIONS(st) {
 
	for (BaseStation *st : BaseStation::Iterate()) {
 
		st->UpdateVirtCoord();
 
	}
 
}
 

	
 
/**
 
 * Get a mask of the cargo types that the station accepts.
 
@@ -2209,17 +2206,16 @@ Town *AirportGetNearestTown(const Airpor
 

	
 

	
 
/** Recalculate the noise generated by the airports of each town */
 
void UpdateAirportsNoise()
 
{
 
	Town *t;
 
	const Station *st;
 

	
 
	FOR_ALL_TOWNS(t) t->noise_reached = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->airport.tile != INVALID_TILE && st->airport.type != AT_OILRIG) {
 
			const AirportSpec *as = st->airport.GetSpec();
 
			AirportTileIterator it(st);
 
			uint dist;
 
			Town *nearest = AirportGetNearestTown(as, it, dist);
 
			nearest->noise_reached += GetAirportNoiseLevelForDistance(as, dist);
 
@@ -2290,14 +2286,13 @@ CommandCost CmdBuildAirport(TileIndex ti
 
			authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
 
			authority_refuse_town = nearest;
 
		}
 
	} else {
 
		Town *t = ClosestTownFromTile(tile, UINT_MAX);
 
		uint num = 0;
 
		const Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (const Station *st : Station::Iterate()) {
 
			if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
 
		}
 
		if (num >= 2) {
 
			authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
 
			authority_refuse_town = t;
 
		}
 
@@ -3821,14 +3816,13 @@ static void StationHandleSmallTick(BaseS
 
}
 

	
 
void OnTick_Station()
 
{
 
	if (_game_mode == GM_EDITOR) return;
 

	
 
	BaseStation *st;
 
	FOR_ALL_BASE_STATIONS(st) {
 
	for (BaseStation *st : BaseStation::Iterate()) {
 
		StationHandleSmallTick(st);
 

	
 
		/* Clean up the link graph about once a week. */
 
		if (Station::IsExpected(st) && (_tick_counter + st->index) % STATION_LINKGRAPH_TICKS == 0) {
 
			DeleteStaleLinks(Station::From(st));
 
		};
 
@@ -3845,15 +3839,13 @@ void OnTick_Station()
 
	}
 
}
 

	
 
/** Monthly loop for stations. */
 
void StationMonthlyLoop()
 
{
 
	Station *st;
 

	
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			GoodsEntry *ge = &st->goods[i];
 
			SB(ge->status, GoodsEntry::GES_LAST_MONTH, 1, GB(ge->status, GoodsEntry::GES_CURRENT_MONTH, 1));
 
			ClrBit(ge->status, GoodsEntry::GES_CURRENT_MONTH);
 
		}
 
	}
 
@@ -3919,15 +3911,13 @@ static uint UpdateStationWaiting(Station
 
	st->MarkTilesDirty(true);
 
	return amount;
 
}
 

	
 
static bool IsUniqueStationName(const char *name)
 
{
 
	const Station *st;
 

	
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->name != nullptr && strcmp(st->name, name) == 0) return false;
 
	}
 

	
 
	return true;
 
}
 

	
src/station_gui.cpp
Show inline comments
 
@@ -226,14 +226,13 @@ protected:
 
		if (!this->stations.NeedRebuild()) return;
 

	
 
		DEBUG(misc, 3, "Building station list for company %d", owner);
 

	
 
		this->stations.clear();
 

	
 
		const Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (const Station *st : Station::Iterate()) {
 
			if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, true, owner))) {
 
				if (this->facilities & st->facilities) { // only stations with selected facilities
 
					int num_waiting_cargo = 0;
 
					for (CargoID j = 0; j < NUM_CARGO; j++) {
 
						if (st->goods[j].HasRating()) {
 
							num_waiting_cargo++; // count number of waiting cargo
 
@@ -2239,14 +2238,13 @@ static const T *FindStationsNearby(TileA
 
	/* Check the inside, to return, if we sit on another station */
 
	TILE_AREA_LOOP(t, ta) {
 
		if (t < MapSize() && IsTileType(t, MP_STATION) && T::IsValidID(GetStationIndex(t))) return T::GetByTile(t);
 
	}
 

	
 
	/* Look for deleted stations */
 
	const BaseStation *st;
 
	FOR_ALL_BASE_STATIONS(st) {
 
	for (const BaseStation *st : BaseStation::Iterate()) {
 
		if (T::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) {
 
			/* Include only within station spread (yes, it is strictly less than) */
 
			if (max(DistanceMax(ta.tile, st->xy), DistanceMax(TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1), st->xy)) < _settings_game.station.station_spread) {
 
				_deleted_stations_nearby.push_back({st->xy, st->index});
 

	
 
				/* Add the station when it's within where we're going to build */
src/terraform_gui.cpp
Show inline comments
 
@@ -505,14 +505,13 @@ static void ResetLandscapeConfirmationCa
 
			delete c;
 
		}
 

	
 
		_generating_world = false;
 

	
 
		/* Delete all station signs */
 
		BaseStation *st;
 
		FOR_ALL_BASE_STATIONS(st) {
 
		for (BaseStation *st : BaseStation::Iterate()) {
 
			/* There can be buoys, remove them */
 
			if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
 
			if (!st->IsInUse()) delete st;
 
		}
 

	
 
		/* Now that all vehicles are gone, we can reset the engine pool. Maybe it reduces some NewGRF changing-mess */
src/town_cmd.cpp
Show inline comments
 
@@ -2869,14 +2869,13 @@ CommandCost CmdDeleteTown(TileIndex tile
 
{
 
	if (_game_mode != GM_EDITOR && !_generating_world) return CMD_ERROR;
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 

	
 
	/* Stations refer to towns. */
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->town == t) {
 
			/* Non-oil rig stations are always a problem. */
 
			if (!(st->facilities & FACIL_AIRPORT) || st->airport.type != AT_OILRIG) return CMD_ERROR;
 
			/* We can only automatically delete oil rigs *if* there's no vehicle on them. */
 
			CommandCost ret = DoCommand(st->airport.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
			if (ret.Failed()) return ret;
 
@@ -3156,14 +3155,13 @@ static CommandCost TownActionBribe(Town 
 
	if (flags & DC_EXEC) {
 
		if (Chance16(1, 14)) {
 
			/* set as unwanted for 6 months */
 
			t->unwanted[_current_company] = 6;
 

	
 
			/* set all close by station ratings to 0 */
 
			Station *st;
 
			FOR_ALL_STATIONS(st) {
 
			for (Station *st : Station::Iterate()) {
 
				if (st->town == t && st->owner == _current_company) {
 
					for (CargoID i = 0; i < NUM_CARGO; i++) st->goods[i].rating = 0;
 
				}
 
			}
 

	
 
			/* only show error message to the executing player. All errors are handled command.c
src/vehicle.cpp
Show inline comments
 
@@ -944,14 +944,13 @@ void CallVehicleTicks()
 
	_vehicles_to_autoreplace.clear();
 

	
 
	RunVehicleDayProc();
 

	
 
	{
 
		PerformanceMeasurer framerate(PFE_GL_ECONOMY);
 
		Station *st;
 
		FOR_ALL_STATIONS(st) LoadUnloadStation(st);
 
		for (Station *st : Station::Iterate()) LoadUnloadStation(st);
 
	}
 
	PerformanceAccumulator::Reset(PFE_GL_TRAINS);
 
	PerformanceAccumulator::Reset(PFE_GL_ROADVEHS);
 
	PerformanceAccumulator::Reset(PFE_GL_SHIPS);
 
	PerformanceAccumulator::Reset(PFE_GL_AIRCRAFT);
 

	
src/viewport.cpp
Show inline comments
 
@@ -2244,19 +2244,17 @@ void RebuildViewportKdtree()
 
	/* Reset biggest size sign seen */
 
	_viewport_sign_maxwidth = 0;
 

	
 
	std::vector<ViewportSignKdtreeItem> items;
 
	items.reserve(BaseStation::GetNumItems() + Town::GetNumItems() + Sign::GetNumItems());
 

	
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeStation(st->index));
 
	}
 

	
 
	const Waypoint *wp;
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (const Waypoint *wp : Waypoint::Iterate()) {
 
		if (wp->sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeWaypoint(wp->index));
 
	}
 

	
 
	const Town *town;
 
	FOR_ALL_TOWNS(town) {
 
		if (town->cache.sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeTown(town->index));
src/waypoint_base.h
Show inline comments
 
@@ -64,13 +64,7 @@ struct Waypoint FINAL : SpecializedStati
 
	inline bool IsOfType(const Waypoint *wp) const
 
	{
 
		return this->string_id == wp->string_id;
 
	}
 
};
 

	
 
/**
 
 * Iterate over all waypoints.
 
 * @param var The variable used for iteration.
 
 */
 
#define FOR_ALL_WAYPOINTS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Waypoint, var)
 

	
 
#endif /* WAYPOINT_BASE_H */
src/waypoint_cmd.cpp
Show inline comments
 
@@ -67,16 +67,16 @@ void Waypoint::MoveSign(TileIndex new_xy
 
 * @param str  the string to get the 'type' of
 
 * @param cid previous owner of the waypoint
 
 * @return the deleted nearby waypoint
 
 */
 
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile, StringID str, CompanyID cid)
 
{
 
	Waypoint *wp, *best = nullptr;
 
	Waypoint *best = nullptr;
 
	uint thres = 8;
 

	
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (Waypoint *wp : Waypoint::Iterate()) {
 
		if (!wp->IsInUse() && wp->string_id == str && wp->owner == cid) {
 
			uint cur_dist = DistanceManhattan(tile, wp->xy);
 

	
 
			if (cur_dist < thres) {
 
				thres = cur_dist;
 
				best = wp;
 
@@ -394,15 +394,13 @@ CommandCost RemoveBuoy(TileIndex tile, D
 
 * Check whether the name is unique amongst the waypoints.
 
 * @param name The name to check.
 
 * @return True iff the name is unique.
 
 */
 
static bool IsUniqueWaypointName(const char *name)
 
{
 
	const Waypoint *wp;
 

	
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (const Waypoint *wp : Waypoint::Iterate()) {
 
		if (wp->name != nullptr && strcmp(wp->name, name) == 0) return false;
 
	}
 

	
 
	return true;
 
}
 

	
0 comments (0 inline, 0 general)