Add: Setting to save a unique id for each savegame

pull/78/head
damfr 6 years ago
parent 868c6f924a
commit 5f6858c379

@ -105,6 +105,11 @@ static void _GenerateWorld(void *)
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
if (_settings_game.game_creation.generation_seed == GENERATE_NEW_SEED) _settings_game.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
_random.SetSeed(_settings_game.game_creation.generation_seed);
/* Generates a unique id for the savegame, to avoid accidentally overwriting a save */
/* We keep id 0 for old savegames that don't have an id */
_settings_game.game_creation.generation_unique_id = _interactive_random.Next(UINT32_MAX - 1) + 1; /* Generates between [1,UINT32_MAX] */
SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);

@ -3045,6 +3045,12 @@ bool AfterLoadGame()
}
}
if (IsSavegameVersionBefore(203)) {
/* Generate a random id for savegames that didn't have one */
/* We keep id 0 for old savegames that don't have an id */
_settings_game.game_creation.generation_unique_id = _interactive_random.Next(UINT32_MAX-1) + 1; /* Generates between [1;UINT32_MAX] */
}
/* Station acceptance is some kind of cache */
if (IsSavegameVersionBefore(127)) {
Station *st;

@ -270,8 +270,9 @@
* 200 #6805 Extend railtypes to 64, adding uint16 to map array.
* 201 #6885 Extend NewGRF persistant storages.
* 202 #6867 Increase industry cargo slots to 16 in, 16 out
* 203 #6973 Add unique id to savegames
*/
extern const uint16 SAVEGAME_VERSION = 202; ///< Current savegame version of OpenTTD.
extern const uint16 SAVEGAME_VERSION = 203; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.

@ -283,6 +283,7 @@ struct NetworkSettings {
/** Settings related to the creation of games. */
struct GameCreationSettings {
uint32 generation_seed; ///< noise seed for world generation
uint32 generation_unique_id; ///< random id to differentiate savegames
Year starting_year; ///< starting date
uint8 map_x; ///< X size of map
uint8 map_y; ///< Y size of map

@ -2208,6 +2208,15 @@ min = 0
max = UINT32_MAX
cat = SC_EXPERT
[SDT_VAR]
base = GameSettings
var = game_creation.generation_unique_id
type = SLE_UINT32
from = 203
def = 0
min = 0
max = UINT32_MAX
[SDT_VAR]
base = GameSettings
var = game_creation.tree_placer

Loading…
Cancel
Save