summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpasky <pasky@openttd.org>2005-03-20 00:32:26 +0000
committerpasky <pasky@openttd.org>2005-03-20 00:32:26 +0000
commit087d78d4655c36996396b3e98d489891d767252c (patch)
treeae81e0bd3eb672542999bc9ef402dd1d8e63701d
parent1990c139d55324c405eca579bdfd7be774f3a9ee (diff)
downloadopenttd-087d78d4655c36996396b3e98d489891d767252c.tar.xz
(svn r2033) - Fix: Fix some more desync by saving the town growth frequency iterator _cur_town_iter. Needed to bump a svg revision for that thanks to the braindead SlGlob thing, or at least I don't know how to do it without bumping it.
-rw-r--r--misc.c1
-rw-r--r--saveload.c2
-rw-r--r--town_cmd.c9
-rw-r--r--variables.h2
4 files changed, 8 insertions, 6 deletions
diff --git a/misc.c b/misc.c
index 60c904553..21cfb1994 100644
--- a/misc.c
+++ b/misc.c
@@ -778,6 +778,7 @@ static const SaveLoadGlobVarList _date_desc[] = {
{&_next_competitor_start, SLE_FILE_U16 | SLE_VAR_UINT, 0, 255},
{&_trees_tick_ctr, SLE_UINT8, 0, 255},
{&_pause, SLE_UINT8, 4, 255},
+ {&_cur_town_iter, SLE_UINT32, 11, 255},
{NULL, 0, 0, 0}
};
diff --git a/saveload.c b/saveload.c
index 425198c88..bf65e90e0 100644
--- a/saveload.c
+++ b/saveload.c
@@ -8,7 +8,7 @@
#include "saveload.h"
enum {
- SAVEGAME_MAJOR_VERSION = 10,
+ SAVEGAME_MAJOR_VERSION = 11,
SAVEGAME_MINOR_VERSION = 0,
SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION
diff --git a/town_cmd.c b/town_cmd.c
index 718011396..e96b3d0ab 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -432,16 +432,14 @@ static void TownTickHandler(Town *t)
void OnTick_Town(void)
{
- static int counter;
-
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 (counter += GetTownPoolSize();
- counter >= TOWN_GROWTH_FREQUENCY;
- counter -= TOWN_GROWTH_FREQUENCY) {
+ for (_cur_town_iter += GetTownPoolSize();
+ _cur_town_iter >= TOWN_GROWTH_FREQUENCY;
+ _cur_town_iter -= TOWN_GROWTH_FREQUENCY) {
uint32 i = _cur_town_ctr;
Town *t;
@@ -1914,6 +1912,7 @@ void InitializeTowns(void)
s->cargo_type = 0xFF;
_cur_town_ctr = 0;
+ _cur_town_iter = 0;
_total_towns = 0;
_town_sort_dirty = true;
}
diff --git a/variables.h b/variables.h
index 68fc02c19..dc9ed347f 100644
--- a/variables.h
+++ b/variables.h
@@ -85,6 +85,8 @@ VARDEF uint32 _player_seeds[MAX_PLAYERS][2];
// Iterator through all towns in OnTick_Town
VARDEF uint32 _cur_town_ctr;
+// Frequency iterator at the same place
+VARDEF uint32 _cur_town_iter;
VARDEF uint _cur_player_tick_index;
VARDEF uint _next_competitor_start;