diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-11-18 19:42:44 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-11-18 19:42:44 -0300 |
commit | 1a473e42d5aa97d8cd64134c73d9f4a4f3e943ca (patch) | |
tree | 6271f282baa5dedf0a2f38292f6ce2ead1a535a4 | |
parent | 63e84e18241276aace45619a4e421302914a14d4 (diff) | |
parent | fc2c3bda5c637b82d00b42e5da948a09b8bd9aed (diff) |
Merge pull request #2711 from akien-mga/parameters-parsing
Fix arguments parsing in the main function
-rw-r--r-- | main/main.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/main/main.cpp b/main/main.cpp index 9cd190a0e8..3ef357e253 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1007,8 +1007,21 @@ bool Main::start() { bool export_debug=false; List<String> args = OS::get_singleton()->get_cmdline_args(); for (int i=0;i<args.size();i++) { + //parameters that do not have an argument to the right + if (args[i]=="-nodocbase") { + doc_base=false; + } else if (args[i]=="-noquit") { + noquit=true; + } else if (args[i]=="-convert_old") { + convert_old=true; + } else if (args[i]=="-editor" || args[i]=="-e") { + editor=true; + } else if (args[i].length() && args[i][0] != '-' && game_path == "") { + game_path=args[i]; + } //parameters that have an argument to the right - if (i < (args.size()-1)) { + else if (i < (args.size()-1)) { + bool parsed_pair=true; if (args[i]=="-doctool") { doc_tool=args[i+1]; } else if (args[i]=="-script" || args[i]=="-s") { @@ -1037,20 +1050,13 @@ bool Main::start() { } else if (args[i]=="-dumpstrings") { editor=true; //needs editor dumpstrings=args[i+1]; + } else { + // The parameter does not match anything known, don't skip the next argument + parsed_pair=false; + } + if (parsed_pair) { + i++; } - i++; - } - //parameters that do not have an argument to the right - if (args[i]=="-nodocbase") { - doc_base=false; - } else if (args[i]=="-noquit") { - noquit=true; - } else if (args[i]=="-convert_old") { - convert_old=true; - } else if (args[i]=="-editor" || args[i]=="-e") { - editor=true; - } else if (args[i].length() && args[i][0] != '-' && game_path == "") { - game_path=args[i]; } } |