summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/saveload/misc_sl.cpp6
-rw-r--r--src/saveload/oldloader_sl.cpp8
-rw-r--r--src/saveload/town_sl.cpp5
-rw-r--r--src/town.h2
-rw-r--r--src/town_cmd.cpp19
5 files changed, 10 insertions, 30 deletions
diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp
index 088c1b26e..7766ae505 100644
--- a/src/saveload/misc_sl.cpp
+++ b/src/saveload/misc_sl.cpp
@@ -68,14 +68,14 @@ static const SaveLoadGlobVarList _date_desc[] = {
SLE_CONDNULL(2, 0, 119),
SLEG_VAR(_random.state[0], SLE_UINT32),
SLEG_VAR(_random.state[1], SLE_UINT32),
- SLEG_CONDVAR(_cur_town_ctr, SLE_FILE_U8 | SLE_VAR_U32, 0, 9),
- SLEG_CONDVAR(_cur_town_ctr, SLE_UINT32, 10, SL_MAX_VERSION),
+ SLE_CONDNULL(1, 0, 9),
+ SLE_CONDNULL(4, 10, 119),
SLEG_VAR(_cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
SLEG_CONDVAR(_next_competitor_start, SLE_FILE_U16 | SLE_VAR_U32, 0, 108),
SLEG_CONDVAR(_next_competitor_start, SLE_UINT32, 109, SL_MAX_VERSION),
SLEG_VAR(_trees_tick_ctr, SLE_UINT8),
SLEG_CONDVAR(_pause_mode, SLE_UINT8, 4, SL_MAX_VERSION),
- SLEG_CONDVAR(_cur_town_iter, SLE_UINT32, 11, SL_MAX_VERSION),
+ SLE_CONDNULL(4, 10, 119),
SLEG_END()
};
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 787adde34..a0764d408 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1583,7 +1583,6 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
}
extern TileIndex _cur_tileloop_tile;
-static uint32 _old_cur_town_ctr;
static const OldChunks main_chunk[] = {
OCL_ASSERT( OC_TTD, 0 ),
OCL_ASSERT( OC_TTO, 0 ),
@@ -1618,7 +1617,7 @@ static const OldChunks main_chunk[] = {
OCL_ASSERT( OC_TTD, 0x4B26 ),
OCL_ASSERT( OC_TTO, 0x3A20 ),
- OCL_VAR ( OC_UINT32, 1, &_old_cur_town_ctr ),
+ OCL_NULL( 4 ), ///< town counter, no longer in use
OCL_NULL( 2 ), ///< timer_counter, no longer in use
OCL_NULL( 2 ), ///< land_code, no longer in use
@@ -1774,9 +1773,6 @@ bool LoadTTDMain(LoadgameState *ls)
/* Fix some general stuff */
_settings_game.game_creation.landscape = _settings_game.game_creation.landscape & 0xF;
- /* Remap some pointers */
- _cur_town_ctr = RemapTownIndex(_old_cur_town_ctr);
-
/* Fix the game to be compatible with OpenTTD */
FixOldTowns();
FixOldVehicles();
@@ -1813,8 +1809,6 @@ bool LoadTTOMain(LoadgameState *ls)
_settings_game.game_creation.landscape = 0;
_trees_tick_ctr = 0xFF;
- _cur_town_ctr = RemapTownIndex(_old_cur_town_ctr);
-
if (!FixTTOMapArray() || !FixTTOEngines()) {
DEBUG(oldloader, 0, "Conversion failed");
return false;
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index 2b25356a7..c28f6acac 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -189,11 +189,6 @@ static void Load_TOWN()
_total_towns++;
}
-
- /* This is to ensure all pointers are within the limits of
- * the size of the TownPool */
- if (_cur_town_ctr > GetMaxTownIndex())
- _cur_town_ctr = 0;
}
extern const ChunkHandler _town_chunk_handlers[] = {
diff --git a/src/town.h b/src/town.h
index db7bf04f5..3ad04d22e 100644
--- a/src/town.h
+++ b/src/town.h
@@ -341,8 +341,6 @@ Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
extern Town *_cleared_town;
extern int _cleared_town_rating;
-extern uint32 _cur_town_ctr;
-extern uint32 _cur_town_iter;
void ResetHouses();
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index f56c35205..76380ded3 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -683,17 +683,12 @@ void OnTick_Town()
{
if (_game_mode == GM_EDITOR) return;
- /* Make sure each town's tickhandler invocation frequency is about the
- * same - TOWN_GROWTH_FREQUENCY - independent on the number of towns. */
- for (_cur_town_iter += GetMaxTownIndex() + 1;
- _cur_town_iter >= TOWN_GROWTH_FREQUENCY;
- _cur_town_iter -= TOWN_GROWTH_FREQUENCY) {
- uint32 i = _cur_town_ctr;
-
- if (++_cur_town_ctr > GetMaxTownIndex())
- _cur_town_ctr = 0;
-
- if (Town::IsValidID(i)) TownTickHandler(Town::Get(i));
+ Town *t;
+ FOR_ALL_TOWNS(t) {
+ /* Run town tick at regular intervals, but not all at once. */
+ if ((_tick_counter + t->index) % TOWN_GROWTH_FREQUENCY == 0) {
+ TownTickHandler(t);
+ }
}
}
@@ -2877,8 +2872,6 @@ void InitializeTowns()
s->cargo_type = CT_INVALID;
}
- _cur_town_ctr = 0;
- _cur_town_iter = 0;
_total_towns = 0;
}