diff options
author | Miguel Horta <mmiguelhorta@gmail.com> | 2018-10-11 00:33:37 +0100 |
---|---|---|
committer | Owen Rudge <owen@owenrudge.net> | 2018-10-11 20:22:31 +0100 |
commit | e00908f5e900ac5314930b2775eb38f91a6c4abe (patch) | |
tree | 026783fc961a05d29cba553db96d992d202b0c8f /src/openttd.cpp | |
parent | fbfa4eb5920b10f57b9fc72730206f4a05c3638d (diff) | |
download | openttd-e00908f5e900ac5314930b2775eb38f91a6c4abe.tar.xz |
Fix #6898: Replace atoi() with strtoul()
Normalize type and parsing of generation_seed across all files
Add assert_compile() to ensure correct type
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r-- | src/openttd.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index 510f00427..a849a2ebd 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -385,7 +385,7 @@ void OpenBrowser(const char *url) /** Callback structure of statements to be executed after the NewGRF scan. */ struct AfterNewGRFScan : NewGRFScanCallback { Year startyear; ///< The start year. - uint generation_seed; ///< Seed for the new game. + uint32 generation_seed; ///< Seed for the new game. char *dedicated_host; ///< Hostname for the dedicated server. uint16 dedicated_port; ///< Port for the dedicated server. char *network_conn; ///< Information about the server to connect to, or NULL. @@ -394,6 +394,8 @@ struct AfterNewGRFScan : NewGRFScanCallback { bool *save_config_ptr; ///< The pointer to the save config setting. bool save_config; ///< The save config setting. + assert_compile(sizeof(generation_seed) == sizeof(_settings_game.game_creation.generation_seed)); + /** * Create a new callback. * @param save_config_ptr Pointer to the save_config local variable which @@ -666,7 +668,7 @@ int openttd_main(int argc, char *argv[]) goto exit_noshutdown; } - case 'G': scanner->generation_seed = atoi(mgo.opt); break; + case 'G': scanner->generation_seed = strtoul(mgo.opt, NULL, 10); break; case 'c': free(_config_file); _config_file = stredup(mgo.opt); break; case 'x': scanner->save_config = false; break; case 'h': |