Changeset - r11921:e51a930f3ca0
[Not reviewed]
master
0 5 0
rubidium - 15 years ago 2009-05-17 10:35:13
rubidium@openttd.org
(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)
5 files changed with 10 insertions and 30 deletions:
0 comments (0 inline, 0 general)
src/saveload/misc_sl.cpp
Show inline comments
 
@@ -68,14 +68,14 @@ static const SaveLoadGlobVarList _date_d
 
	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()
 
};
 

	
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -1583,7 +1583,6 @@ static bool LoadTTDPatchExtraChunks(Load
 
}
 

	
 
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;
src/saveload/town_sl.cpp
Show inline comments
 
@@ -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[] = {
src/town.h
Show inline comments
 
@@ -341,8 +341,6 @@ Town *CalcClosestTownFromTile(TileIndex 
 

	
 
extern Town *_cleared_town;
 
extern int _cleared_town_rating;
 
extern uint32 _cur_town_ctr;
 
extern uint32 _cur_town_iter;
 

	
 
void ResetHouses();
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -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;
 
}
 

	
0 comments (0 inline, 0 general)