Changeset - r1517:9f1e3f93cf58
[Not reviewed]
master
0 3 0
pasky - 20 years ago 2005-03-17 23:12:23
pasky@openttd.org
(svn r2021) Fix: Enlarge _cur_town_ctr from byte to uint32 so that all the towns are considered when growing them even for big maps, where much more than 256 towns are around; reported by Tomasz DubiƄski <uboottd@hydra.polsl.gliwice.pl>. The savegame still saves just the lowest 8 bits but that doesn't hurt so much.
3 files changed with 7 insertions and 2 deletions:
0 comments (0 inline, 0 general)
misc.c
Show inline comments
 
@@ -769,12 +769,17 @@ static const SaveLoadGlobVarList _date_d
 
	{&_cur_tileloop_tile, 			SLE_FILE_U16 | SLE_VAR_U32, 0, 5},
 
	{&_cur_tileloop_tile, 			SLE_UINT32, 6, 255},
 
	{&_disaster_delay, 					SLE_UINT16, 0, 255},
 
	{&_station_tick_ctr, 				SLE_UINT16, 0, 255},
 
	{&_random_seeds[0][0], 					SLE_UINT32, 0, 255},
 
	{&_random_seeds[0][1], 					SLE_UINT32, 0, 255},
 
	/* XXX: We save only a portion of the _cur_town_ctr, this should be
 
	 * fixed in the next revision bump. It does not hurt so much since
 
	 * it just gives a small single-time penalty to the towns with higher
 
	 * IDs at the load time. _cur_town_ctr is zeroed in InitializeTowns()
 
	 * so the higher octets do not interfere at this time. */
 
	{&_cur_town_ctr, 						SLE_UINT8,	0, 255},
 
	{&_cur_player_tick_index, 	SLE_FILE_U8 | SLE_VAR_UINT, 0, 255},
 
	{&_next_competitor_start, 	SLE_FILE_U16 | SLE_VAR_UINT, 0, 255},
 
	{&_trees_tick_ctr, 					SLE_UINT8,	0, 255},
 
	{&_pause, 									SLE_UINT8,	4, 255},
 
	{NULL,											0,					0,   0}
town_cmd.c
Show inline comments
 
@@ -439,13 +439,13 @@ void OnTick_Town(void)
 

	
 
	/* 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) {
 
		int i = _cur_town_ctr;
 
		uint32 i = _cur_town_ctr;
 
		Town *t;
 

	
 
		if (++_cur_town_ctr >= GetTownPoolSize())
 
			_cur_town_ctr = 0;
 

	
 
		t = GetTown(i);
variables.h
Show inline comments
 
@@ -81,13 +81,13 @@ VARDEF uint16 _disaster_delay;
 
VARDEF uint16 _station_tick_ctr;
 

	
 
VARDEF uint32 _random_seeds[2][2];
 
VARDEF uint32 _player_seeds[MAX_PLAYERS][2];
 

	
 
// Iterator through all towns in OnTick_Town
 
VARDEF byte _cur_town_ctr;
 
VARDEF uint32 _cur_town_ctr;
 

	
 
VARDEF uint _cur_player_tick_index;
 
VARDEF uint _next_competitor_start;
 

	
 
// Determines how often to run the tree loop
 
VARDEF byte _trees_tick_ctr;
0 comments (0 inline, 0 general)