1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 08:52:40 +01:00

Codechange: validate the given seed

This commit is contained in:
Rubidium
2025-04-24 23:55:38 +02:00
committed by rubidium42
parent 86039a5b69
commit ccbf7f4a46

View File

@@ -1338,7 +1338,17 @@ static bool ConNewGame([[maybe_unused]] uint8_t argc, [[maybe_unused]] char *arg
return true;
}
StartNewGameWithoutGUI((argc == 2) ? std::strtoul(argv[1], nullptr, 10) : GENERATE_NEW_SEED);
uint32_t seed = GENERATE_NEW_SEED;
if (argc >= 2) {
auto param = ParseInteger(argv[1]);
if (!param.has_value()) {
IConsolePrint(CC_ERROR, "The given seed must be a valid number.");
return true;
}
seed = *param;
}
StartNewGameWithoutGUI(seed);
return true;
}