summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-05-17 10:35:13 +0000
committerrubidium <rubidium@openttd.org>2009-05-17 10:35:13 +0000
commitf457cff73c08b3d338d9a601e84b18aba66e2a64 (patch)
tree126b97f8660ce42f4c357b8ec271798c2a40a0d5 /src/town_cmd.cpp
parent6b2f9e8c9edd6a8e5528898db0bbdb884b0221a2 (diff)
downloadopenttd-f457cff73c08b3d338d9a601e84b18aba66e2a64.tar.xz
(svn r16329) -Fix: possible desync when removing lots of towns in-game (not that we allow removing towns now, but better not have desync prone code lingering around)
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp19
1 files changed, 6 insertions, 13 deletions
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;
}