mirror of https://github.com/OpenTTD/OpenTTD
Fix #6898: Replace atoi() with strtoul()
Normalize type and parsing of generation_seed across all files Add assert_compile() to ensure correct typepull/6939/head
parent
fbfa4eb592
commit
e00908f5e9
|
@ -22,7 +22,7 @@ enum LandscapeGenerator {
|
||||||
LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator
|
LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint GENERATE_NEW_SEED = UINT_MAX; ///< Create a new random seed
|
static const uint32 GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed
|
||||||
|
|
||||||
/** Modes for GenerateWorld */
|
/** Modes for GenerateWorld */
|
||||||
enum GenWorldMode {
|
enum GenWorldMode {
|
||||||
|
@ -97,7 +97,7 @@ void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
|
||||||
void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
|
void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
|
||||||
void PrepareGenerateWorldProgress();
|
void PrepareGenerateWorldProgress();
|
||||||
void ShowGenerateWorldProgress();
|
void ShowGenerateWorldProgress();
|
||||||
void StartNewGameWithoutGUI(uint seed);
|
void StartNewGameWithoutGUI(uint32 seed);
|
||||||
void ShowCreateScenario();
|
void ShowCreateScenario();
|
||||||
void StartScenarioEditor();
|
void StartScenarioEditor();
|
||||||
|
|
||||||
|
|
|
@ -870,7 +870,7 @@ void StartScenarioEditor()
|
||||||
* Start a normal game without the GUI.
|
* Start a normal game without the GUI.
|
||||||
* @param seed The seed of the new game.
|
* @param seed The seed of the new game.
|
||||||
*/
|
*/
|
||||||
void StartNewGameWithoutGUI(uint seed)
|
void StartNewGameWithoutGUI(uint32 seed)
|
||||||
{
|
{
|
||||||
/* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
|
/* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
|
||||||
_settings_newgame.game_creation.generation_seed = seed;
|
_settings_newgame.game_creation.generation_seed = seed;
|
||||||
|
|
|
@ -385,7 +385,7 @@ void OpenBrowser(const char *url)
|
||||||
/** Callback structure of statements to be executed after the NewGRF scan. */
|
/** Callback structure of statements to be executed after the NewGRF scan. */
|
||||||
struct AfterNewGRFScan : NewGRFScanCallback {
|
struct AfterNewGRFScan : NewGRFScanCallback {
|
||||||
Year startyear; ///< The start year.
|
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.
|
char *dedicated_host; ///< Hostname for the dedicated server.
|
||||||
uint16 dedicated_port; ///< Port for the dedicated server.
|
uint16 dedicated_port; ///< Port for the dedicated server.
|
||||||
char *network_conn; ///< Information about the server to connect to, or NULL.
|
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_ptr; ///< The pointer to the save config setting.
|
||||||
bool save_config; ///< 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.
|
* Create a new callback.
|
||||||
* @param save_config_ptr Pointer to the save_config local variable which
|
* @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;
|
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 'c': free(_config_file); _config_file = stredup(mgo.opt); break;
|
||||||
case 'x': scanner->save_config = false; break;
|
case 'x': scanner->save_config = false; break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
Loading…
Reference in New Issue