From cf9c6fcc5790960d0f85067130667a014d0e177c Mon Sep 17 00:00:00 2001 From: merni-ns Date: Thu, 13 Feb 2025 23:26:22 +0530 Subject: [PATCH] Fix #13307: Return non-zero value when there is a mistake in command-line arguments Specifically, when the savegame passed to -q cannot be read or when non-existent/invalid options are passed --- src/openttd.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openttd.cpp b/src/openttd.cpp index a80d494e86..7c47694456 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -625,6 +625,7 @@ int openttd_main(std::span arguments) SetDParamStr(0, _load_check_data.error_msg); fmt::print(stderr, "{}\n", GetString(_load_check_data.error)); } + ret = 1; return ret; } @@ -640,14 +641,12 @@ int openttd_main(std::span arguments) case 'c': _config_file = mgo.opt; break; case 'x': scanner->save_config = false; break; case 'X': only_local_path = true; break; - case 'h': - i = -2; // Force printing of help. - break; + case 'h': break; // handled below } - if (i == -2) break; + if (i == 'h' || i == -2) break; } - if (i == -2 || !mgo.arguments.empty()) { + if (i == 'h' || i == -2 || !mgo.arguments.empty()) { /* Either the user typed '-h', they made an error, or they added unrecognized command line arguments. * In all cases, print the help, and exit. * @@ -659,6 +658,7 @@ int openttd_main(std::span arguments) BaseSounds::FindSets(); BaseMusic::FindSets(); ShowHelp(); + if (i != 'h') ret = 1; return ret; }