mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace FOR_ALL_TOWNS with range-based for loops
parent
0b489f9924
commit
ee7a8eebca
|
@ -302,8 +302,6 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
assert(old_owner != _local_company);
|
assert(old_owner != _local_company);
|
||||||
}
|
}
|
||||||
|
|
||||||
Town *t;
|
|
||||||
|
|
||||||
assert(old_owner != new_owner);
|
assert(old_owner != new_owner);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -357,7 +355,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
if (new_owner == INVALID_OWNER) RebuildSubsidisedSourceAndDestinationCache();
|
if (new_owner == INVALID_OWNER) RebuildSubsidisedSourceAndDestinationCache();
|
||||||
|
|
||||||
/* Take care of rating and transport rights in towns */
|
/* Take care of rating and transport rights in towns */
|
||||||
FOR_ALL_TOWNS(t) {
|
for (Town *t : Town::Iterate()) {
|
||||||
/* If a company takes over, give the ratings to that company. */
|
/* If a company takes over, give the ratings to that company. */
|
||||||
if (new_owner != INVALID_OWNER) {
|
if (new_owner != INVALID_OWNER) {
|
||||||
if (HasBit(t->have_ratings, old_owner)) {
|
if (HasBit(t->have_ratings, old_owner)) {
|
||||||
|
|
|
@ -347,9 +347,7 @@ struct NetworkChatWindow : public Window {
|
||||||
* Not that the following assumes all town indices are adjacent, ie no
|
* Not that the following assumes all town indices are adjacent, ie no
|
||||||
* towns have been deleted. */
|
* towns have been deleted. */
|
||||||
if (*item < (uint)MAX_CLIENT_SLOTS + Town::GetPoolSize()) {
|
if (*item < (uint)MAX_CLIENT_SLOTS + Town::GetPoolSize()) {
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate(*item - MAX_CLIENT_SLOTS)) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_SLOTS) {
|
|
||||||
/* Get the town-name via the string-system */
|
/* Get the town-name via the string-system */
|
||||||
SetDParam(0, t->index);
|
SetDParam(0, t->index);
|
||||||
GetString(chat_tab_temp_buffer, STR_TOWN_NAME, lastof(chat_tab_temp_buffer));
|
GetString(chat_tab_temp_buffer, STR_TOWN_NAME, lastof(chat_tab_temp_buffer));
|
||||||
|
|
|
@ -83,8 +83,7 @@ void InitializeBuildingCounts()
|
||||||
{
|
{
|
||||||
memset(&_building_counts, 0, sizeof(_building_counts));
|
memset(&_building_counts, 0, sizeof(_building_counts));
|
||||||
|
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
memset(&t->cache.building_counts, 0, sizeof(t->cache.building_counts));
|
memset(&t->cache.building_counts, 0, sizeof(t->cache.building_counts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1188,8 +1188,7 @@ static void CheckCaches()
|
||||||
|
|
||||||
/* Check the town caches. */
|
/* Check the town caches. */
|
||||||
std::vector<TownCache> old_town_caches;
|
std::vector<TownCache> old_town_caches;
|
||||||
Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
old_town_caches.push_back(t->cache);
|
old_town_caches.push_back(t->cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,7 +1197,7 @@ static void CheckCaches()
|
||||||
RebuildSubsidisedSourceAndDestinationCache();
|
RebuildSubsidisedSourceAndDestinationCache();
|
||||||
|
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
FOR_ALL_TOWNS(t) {
|
for (Town *t : Town::Iterate()) {
|
||||||
if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
|
if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
|
||||||
DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
|
DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,9 +169,7 @@ static void ConvertTownOwner()
|
||||||
/* since savegame version 4.1, exclusive transport rights are stored at towns */
|
/* since savegame version 4.1, exclusive transport rights are stored at towns */
|
||||||
static void UpdateExclusiveRights()
|
static void UpdateExclusiveRights()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
t->exclusivity = INVALID_COMPANY;
|
t->exclusivity = INVALID_COMPANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,8 +268,7 @@ static void InitializeWindowsAndCaches()
|
||||||
s->airport.psa->tile = s->airport.tile;
|
s->airport.psa->tile = s->airport.tile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) {
|
for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) {
|
||||||
(*it)->feature = GSF_FAKE_TOWNS;
|
(*it)->feature = GSF_FAKE_TOWNS;
|
||||||
(*it)->tile = t->xy;
|
(*it)->tile = t->xy;
|
||||||
|
@ -651,8 +648,7 @@ bool AfterLoadGame()
|
||||||
if (st->name != nullptr) st->string_id = STR_SV_STNAME_FALLBACK;
|
if (st->name != nullptr) st->string_id = STR_SV_STNAME_FALLBACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
t->name = CopyFromOldName(t->townnametype);
|
t->name = CopyFromOldName(t->townnametype);
|
||||||
if (t->name != nullptr) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
|
if (t->name != nullptr) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
|
||||||
}
|
}
|
||||||
|
@ -980,8 +976,7 @@ bool AfterLoadGame()
|
||||||
/* From version 9.0, we update the max passengers of a town (was sometimes negative
|
/* From version 9.0, we update the max passengers of a town (was sometimes negative
|
||||||
* before that. */
|
* before that. */
|
||||||
if (IsSavegameVersionBefore(SLV_9)) {
|
if (IsSavegameVersionBefore(SLV_9)) {
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) UpdateTownMaxPass(t);
|
||||||
FOR_ALL_TOWNS(t) UpdateTownMaxPass(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From version 16.0, we included autorenew on engines, which are now saved, but
|
/* From version 16.0, we included autorenew on engines, which are now saved, but
|
||||||
|
@ -1570,9 +1565,7 @@ bool AfterLoadGame()
|
||||||
* fast was added in version 54. From version 56 this is now saved in the
|
* fast was added in version 54. From version 56 this is now saved in the
|
||||||
* town as cities can be built specifically in the scenario editor. */
|
* town as cities can be built specifically in the scenario editor. */
|
||||||
if (IsSavegameVersionBefore(SLV_56)) {
|
if (IsSavegameVersionBefore(SLV_56)) {
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) {
|
if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) {
|
||||||
t->larger_town = true;
|
t->larger_town = true;
|
||||||
}
|
}
|
||||||
|
@ -2018,8 +2011,7 @@ bool AfterLoadGame()
|
||||||
if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
|
if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
|
if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
|
||||||
for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
|
for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
|
||||||
}
|
}
|
||||||
|
@ -2108,8 +2100,7 @@ bool AfterLoadGame()
|
||||||
|
|
||||||
/* Initialize layout of all towns. Older versions were using different
|
/* Initialize layout of all towns. Older versions were using different
|
||||||
* generator for random town layout, use it if needed. */
|
* generator for random town layout, use it if needed. */
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
if (_settings_game.economy.town_layout != TL_RANDOM) {
|
if (_settings_game.economy.town_layout != TL_RANDOM) {
|
||||||
t->layout = _settings_game.economy.town_layout;
|
t->layout = _settings_game.economy.town_layout;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2791,9 +2782,7 @@ bool AfterLoadGame()
|
||||||
if (IsSavegameVersionBefore(SLV_164)) FixupTrainLengths();
|
if (IsSavegameVersionBefore(SLV_164)) FixupTrainLengths();
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_165)) {
|
if (IsSavegameVersionBefore(SLV_165)) {
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
/* Set the default cargo requirement for town growth */
|
/* Set the default cargo requirement for town growth */
|
||||||
switch (_settings_game.game_creation.landscape) {
|
switch (_settings_game.game_creation.landscape) {
|
||||||
case LT_ARCTIC:
|
case LT_ARCTIC:
|
||||||
|
@ -2827,8 +2816,7 @@ bool AfterLoadGame()
|
||||||
Town::Get(GetTownIndex(t))->cargo_accepted.Add(t);
|
Town::Get(GetTownIndex(t))->cargo_accepted.Add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
Town *town;
|
for (Town *town : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(town) {
|
|
||||||
UpdateTownCargoes(town);
|
UpdateTownCargoes(town);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2984,8 +2972,7 @@ bool AfterLoadGame()
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_198)) {
|
if (IsSavegameVersionBefore(SLV_198)) {
|
||||||
/* Convert towns growth_rate and grow_counter to ticks */
|
/* Convert towns growth_rate and grow_counter to ticks */
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
/* 0x8000 = TOWN_GROWTH_RATE_CUSTOM previously */
|
/* 0x8000 = TOWN_GROWTH_RATE_CUSTOM previously */
|
||||||
if (t->growth_rate & 0x8000) SetBit(t->flags, TOWN_CUSTOM_GROWTH);
|
if (t->growth_rate & 0x8000) SetBit(t->flags, TOWN_CUSTOM_GROWTH);
|
||||||
if (t->growth_rate != TOWN_GROWTH_RATE_NONE) {
|
if (t->growth_rate != TOWN_GROWTH_RATE_NONE) {
|
||||||
|
|
|
@ -152,10 +152,8 @@ static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type)
|
||||||
|
|
||||||
static void FixOldTowns()
|
static void FixOldTowns()
|
||||||
{
|
{
|
||||||
Town *town;
|
|
||||||
|
|
||||||
/* Convert town-names if needed */
|
/* Convert town-names if needed */
|
||||||
FOR_ALL_TOWNS(town) {
|
for (Town *town : Town::Iterate()) {
|
||||||
if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
|
if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
|
||||||
town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings_game.game_creation.town_name;
|
town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings_game.game_creation.town_name;
|
||||||
town->townnameparts = RemapOldTownName(town->townnameparts, _settings_game.game_creation.town_name);
|
town->townnameparts = RemapOldTownName(town->townnameparts, _settings_game.game_creation.town_name);
|
||||||
|
|
|
@ -24,12 +24,11 @@
|
||||||
*/
|
*/
|
||||||
void RebuildTownCaches()
|
void RebuildTownCaches()
|
||||||
{
|
{
|
||||||
Town *town;
|
|
||||||
InitializeBuildingCounts();
|
InitializeBuildingCounts();
|
||||||
RebuildTownKdtree();
|
RebuildTownKdtree();
|
||||||
|
|
||||||
/* Reset town population and num_houses */
|
/* Reset town population and num_houses */
|
||||||
FOR_ALL_TOWNS(town) {
|
for (Town *town : Town::Iterate()) {
|
||||||
town->cache.population = 0;
|
town->cache.population = 0;
|
||||||
town->cache.num_houses = 0;
|
town->cache.num_houses = 0;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +37,7 @@ void RebuildTownCaches()
|
||||||
if (!IsTileType(t, MP_HOUSE)) continue;
|
if (!IsTileType(t, MP_HOUSE)) continue;
|
||||||
|
|
||||||
HouseID house_id = GetHouseType(t);
|
HouseID house_id = GetHouseType(t);
|
||||||
town = Town::GetByTile(t);
|
Town *town = Town::GetByTile(t);
|
||||||
IncreaseBuildingCount(town, house_id);
|
IncreaseBuildingCount(town, house_id);
|
||||||
if (IsHouseCompleted(t)) town->cache.population += HouseSpec::Get(house_id)->population;
|
if (IsHouseCompleted(t)) town->cache.population += HouseSpec::Get(house_id)->population;
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ void RebuildTownCaches()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the population and num_house dependent values */
|
/* Update the population and num_house dependent values */
|
||||||
FOR_ALL_TOWNS(town) {
|
for (Town *town : Town::Iterate()) {
|
||||||
UpdateTownRadius(town);
|
UpdateTownRadius(town);
|
||||||
UpdateTownCargoes(town);
|
UpdateTownCargoes(town);
|
||||||
}
|
}
|
||||||
|
@ -263,9 +262,7 @@ static void RealSave_Town(Town *t)
|
||||||
|
|
||||||
static void Save_TOWN()
|
static void Save_TOWN()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
SlSetArrayIndex(t->index);
|
SlSetArrayIndex(t->index);
|
||||||
SlAutolength((AutolengthProc*)RealSave_Town, t);
|
SlAutolength((AutolengthProc*)RealSave_Town, t);
|
||||||
}
|
}
|
||||||
|
@ -311,8 +308,7 @@ static void Ptrs_TOWN()
|
||||||
/* Don't run when savegame version lower than 161. */
|
/* Don't run when savegame version lower than 161. */
|
||||||
if (IsSavegameVersionBefore(SLV_161)) return;
|
if (IsSavegameVersionBefore(SLV_161)) return;
|
||||||
|
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
SlObject(t, _town_desc);
|
SlObject(t, _town_desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
|
|
||||||
ScriptTownList::ScriptTownList()
|
ScriptTownList::ScriptTownList()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
this->AddItem(t->index);
|
this->AddItem(t->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -914,8 +914,7 @@ void SmallMapWindow::DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) co
|
||||||
*/
|
*/
|
||||||
void SmallMapWindow::DrawTowns(const DrawPixelInfo *dpi) const
|
void SmallMapWindow::DrawTowns(const DrawPixelInfo *dpi) const
|
||||||
{
|
{
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
/* Remap the town coordinate */
|
/* Remap the town coordinate */
|
||||||
Point pt = this->RemapTile(TileX(t->xy), TileY(t->xy));
|
Point pt = this->RemapTile(TileX(t->xy), TileY(t->xy));
|
||||||
int x = pt.x - this->subscroll - (t->cache.sign.width_small >> 1);
|
int x = pt.x - this->subscroll - (t->cache.sign.width_small >> 1);
|
||||||
|
|
|
@ -381,8 +381,7 @@ static void AddIndustryToDeliver(Industry *ind, Station *st)
|
||||||
*/
|
*/
|
||||||
void Station::RemoveFromAllNearbyLists()
|
void Station::RemoveFromAllNearbyLists()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) { t->stations_near.erase(this); }
|
||||||
FOR_ALL_TOWNS(t) { t->stations_near.erase(this); }
|
|
||||||
for (Industry *i : Industry::Iterate()) { i->stations_near.erase(this); }
|
for (Industry *i : Industry::Iterate()) { i->stations_near.erase(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2185,10 +2185,10 @@ uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
|
||||||
*/
|
*/
|
||||||
Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist)
|
Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist)
|
||||||
{
|
{
|
||||||
Town *t, *nearest = nullptr;
|
Town *nearest = nullptr;
|
||||||
uint add = as->size_x + as->size_y - 2; // GetMinimalAirportDistanceToTile can differ from DistanceManhattan by this much
|
uint add = as->size_x + as->size_y - 2; // GetMinimalAirportDistanceToTile can differ from DistanceManhattan by this much
|
||||||
mindist = UINT_MAX - add; // prevent overflow
|
mindist = UINT_MAX - add; // prevent overflow
|
||||||
FOR_ALL_TOWNS(t) {
|
for (Town *t : Town::Iterate()) {
|
||||||
if (DistanceManhattan(t->xy, it) < mindist + add) { // avoid calling GetMinimalAirportDistanceToTile too often
|
if (DistanceManhattan(t->xy, it) < mindist + add) { // avoid calling GetMinimalAirportDistanceToTile too often
|
||||||
TileIterator *copy = it.Clone();
|
TileIterator *copy = it.Clone();
|
||||||
uint dist = GetMinimalAirportDistanceToTile(*copy, t->xy);
|
uint dist = GetMinimalAirportDistanceToTile(*copy, t->xy);
|
||||||
|
@ -2207,9 +2207,7 @@ Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint
|
||||||
/** Recalculate the noise generated by the airports of each town */
|
/** Recalculate the noise generated by the airports of each town */
|
||||||
void UpdateAirportsNoise()
|
void UpdateAirportsNoise()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) t->noise_reached = 0;
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) t->noise_reached = 0;
|
|
||||||
|
|
||||||
for (const Station *st : Station::Iterate()) {
|
for (const Station *st : Station::Iterate()) {
|
||||||
if (st->airport.tile != INVALID_TILE && st->airport.type != AT_OILRIG) {
|
if (st->airport.tile != INVALID_TILE && st->airport.type != AT_OILRIG) {
|
||||||
|
|
|
@ -130,8 +130,7 @@ static inline void SetPartOfSubsidyFlag(SourceType type, SourceID index, PartOfS
|
||||||
/** Perform a full rebuild of the subsidies cache. */
|
/** Perform a full rebuild of the subsidies cache. */
|
||||||
void RebuildSubsidisedSourceAndDestinationCache()
|
void RebuildSubsidisedSourceAndDestinationCache()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) t->cache.part_of_subsidy = POS_NONE;
|
||||||
FOR_ALL_TOWNS(t) t->cache.part_of_subsidy = POS_NONE;
|
|
||||||
|
|
||||||
for (Industry *i : Industry::Iterate()) i->part_of_subsidy = POS_NONE;
|
for (Industry *i : Industry::Iterate()) i->part_of_subsidy = POS_NONE;
|
||||||
|
|
||||||
|
|
|
@ -185,9 +185,6 @@ TileIndexDiff GetHouseNorthPart(HouseID &house);
|
||||||
|
|
||||||
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
|
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
|
||||||
|
|
||||||
#define FOR_ALL_TOWNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Town, town_index, var, start)
|
|
||||||
#define FOR_ALL_TOWNS(var) FOR_ALL_TOWNS_FROM(var, 0)
|
|
||||||
|
|
||||||
void ResetHouses();
|
void ResetHouses();
|
||||||
|
|
||||||
void ClearTownHouse(Town *t, TileIndex tile);
|
void ClearTownHouse(Town *t, TileIndex tile);
|
||||||
|
|
|
@ -67,8 +67,7 @@ TownKdtree _town_kdtree(&Kdtree_TownXYFunc);
|
||||||
void RebuildTownKdtree()
|
void RebuildTownKdtree()
|
||||||
{
|
{
|
||||||
std::vector<TownID> townids;
|
std::vector<TownID> townids;
|
||||||
Town *town;
|
for (const Town *town : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(town) {
|
|
||||||
townids.push_back(town->index);
|
townids.push_back(town->index);
|
||||||
}
|
}
|
||||||
_town_kdtree.Build(townids.begin(), townids.end());
|
_town_kdtree.Build(townids.begin(), townids.end());
|
||||||
|
@ -408,9 +407,7 @@ void Town::UpdateVirtCoord()
|
||||||
/** Update the virtual coords needed to draw the town sign for all towns. */
|
/** Update the virtual coords needed to draw the town sign for all towns. */
|
||||||
void UpdateAllTownVirtCoords()
|
void UpdateAllTownVirtCoords()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
t->UpdateVirtCoord();
|
t->UpdateVirtCoord();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,9 +434,7 @@ static void ChangePopulation(Town *t, int mod)
|
||||||
uint32 GetWorldPopulation()
|
uint32 GetWorldPopulation()
|
||||||
{
|
{
|
||||||
uint32 pop = 0;
|
uint32 pop = 0;
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate()) pop += t->cache.population;
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) pop += t->cache.population;
|
|
||||||
return pop;
|
return pop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,10 +839,9 @@ void UpdateTownCargoes(Town *t)
|
||||||
/** Updates the bitmap of all cargoes accepted by houses. */
|
/** Updates the bitmap of all cargoes accepted by houses. */
|
||||||
void UpdateTownCargoBitmap()
|
void UpdateTownCargoBitmap()
|
||||||
{
|
{
|
||||||
Town *town;
|
|
||||||
_town_cargoes_accepted = 0;
|
_town_cargoes_accepted = 0;
|
||||||
|
|
||||||
FOR_ALL_TOWNS(town) {
|
for (const Town *town : Town::Iterate()) {
|
||||||
_town_cargoes_accepted |= town->cargo_accepted_total;
|
_town_cargoes_accepted |= town->cargo_accepted_total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -874,8 +868,7 @@ void OnTick_Town()
|
||||||
{
|
{
|
||||||
if (_game_mode == GM_EDITOR) return;
|
if (_game_mode == GM_EDITOR) return;
|
||||||
|
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
TownTickHandler(t);
|
TownTickHandler(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1842,9 +1835,7 @@ static CommandCost TownCanBePlacedHere(TileIndex tile)
|
||||||
*/
|
*/
|
||||||
static bool IsUniqueTownName(const char *name)
|
static bool IsUniqueTownName(const char *name)
|
||||||
{
|
{
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
if (t->name != nullptr && strcmp(t->name, name) == 0) return false;
|
if (t->name != nullptr && strcmp(t->name, name) == 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3642,9 +3633,7 @@ CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType
|
||||||
|
|
||||||
void TownsMonthlyLoop()
|
void TownsMonthlyLoop()
|
||||||
{
|
{
|
||||||
Town *t;
|
for (Town *t : Town::Iterate()) {
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
if (t->road_build_months != 0) t->road_build_months--;
|
if (t->road_build_months != 0) t->road_build_months--;
|
||||||
|
|
||||||
if (t->exclusive_counter != 0) {
|
if (t->exclusive_counter != 0) {
|
||||||
|
|
|
@ -689,8 +689,7 @@ private:
|
||||||
if (this->towns.NeedRebuild()) {
|
if (this->towns.NeedRebuild()) {
|
||||||
this->towns.clear();
|
this->towns.clear();
|
||||||
|
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
this->towns.push_back(t);
|
this->towns.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,8 +990,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
this->towns.clear();
|
this->towns.clear();
|
||||||
|
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
this->string_filter.ResetState();
|
this->string_filter.ResetState();
|
||||||
|
|
||||||
SetDParam(0, t->index);
|
SetDParam(0, t->index);
|
||||||
|
|
|
@ -94,8 +94,7 @@ bool VerifyTownName(uint32 r, const TownNameParams *par, TownNames *town_names)
|
||||||
if (town_names->find(buf1) != town_names->end()) return false;
|
if (town_names->find(buf1) != town_names->end()) return false;
|
||||||
town_names->insert(buf1);
|
town_names->insert(buf1);
|
||||||
} else {
|
} else {
|
||||||
const Town *t;
|
for (const Town *t : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
/* We can't just compare the numbers since
|
/* We can't just compare the numbers since
|
||||||
* several numbers may map to a single name. */
|
* several numbers may map to a single name. */
|
||||||
const char *buf = t->name;
|
const char *buf = t->name;
|
||||||
|
|
|
@ -2255,8 +2255,7 @@ void RebuildViewportKdtree()
|
||||||
if (wp->sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeWaypoint(wp->index));
|
if (wp->sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeWaypoint(wp->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
const Town *town;
|
for (const Town *town : Town::Iterate()) {
|
||||||
FOR_ALL_TOWNS(town) {
|
|
||||||
if (town->cache.sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeTown(town->index));
|
if (town->cache.sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeTown(town->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue