(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.
authorpasky
Sun, 20 Mar 2005 00:32:26 +0000
changeset 1529 3a8196d15b01
parent 1528 94e532d0a921
child 1530 2b46869fc0d4
(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.
misc.c
saveload.c
town_cmd.c
variables.h
--- a/misc.c	Sat Mar 19 23:23:56 2005 +0000
+++ b/misc.c	Sun Mar 20 00:32:26 2005 +0000
@@ -778,6 +778,7 @@
 	{&_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}
 };
 
--- a/saveload.c	Sat Mar 19 23:23:56 2005 +0000
+++ b/saveload.c	Sun Mar 20 00:32:26 2005 +0000
@@ -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
--- a/town_cmd.c	Sat Mar 19 23:23:56 2005 +0000
+++ b/town_cmd.c	Sun Mar 20 00:32:26 2005 +0000
@@ -432,16 +432,14 @@
 
 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 @@
 		s->cargo_type = 0xFF;
 
 	_cur_town_ctr = 0;
+	_cur_town_iter = 0;
 	_total_towns = 0;
 	_town_sort_dirty = true;
 }
--- a/variables.h	Sat Mar 19 23:23:56 2005 +0000
+++ b/variables.h	Sun Mar 20 00:32:26 2005 +0000
@@ -85,6 +85,8 @@
 
 // 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;