diff --git a/CMakeLists.txt b/CMakeLists.txt index 1032d1fd..3493db77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,7 @@ if (WIN32) if (MSVC) # request 8MB stack for all .exe's - set(STACKSIZE 8388608) + set(STACKSIZE 16388608) set(CMAKE_EXE_LINKER_FLAGS "/STACK:${STACKSIZE}") add_definitions("/wd4244") # disable "conversion from .. to .., possible loss of data" warning diff --git a/bsputil/bsputil.cc b/bsputil/bsputil.cc index 243ec6e9..c1c14529 100644 --- a/bsputil/bsputil.cc +++ b/bsputil/bsputil.cc @@ -825,7 +825,7 @@ int bsputil_main(int _argc, const char **_argv) logging::init(std::nullopt, bsputil_options); if (bsputil_options.remainder.size() != 1 || bsputil_options.operations.empty()) { - bsputil_options.print_help(); + bsputil_options.print_help(true); return 1; } diff --git a/common/entdata.cc b/common/entdata.cc index cbc72e50..a38f05b6 100644 --- a/common/entdata.cc +++ b/common/entdata.cc @@ -169,10 +169,10 @@ void entdict_t::parse(parser_base_t &parser) FError("closing brace without data"); // trim whitespace from start/end - while (std::isspace(keystr.front())) { + while (!keystr.empty() && std::isspace(keystr.front())) { keystr.erase(keystr.begin()); } - while (std::isspace(keystr.back())) { + while (!keystr.empty() && std::isspace(keystr.back())) { keystr.erase(keystr.cbegin()); } diff --git a/common/settings.cc b/common/settings.cc index d769fddf..dd3be518 100644 --- a/common/settings.cc +++ b/common/settings.cc @@ -533,7 +533,7 @@ void setting_container::set_settings(const entdict_t &epairs, source source) } } -void setting_container::print_help() +void setting_container::print_help(bool fatal) { fmt::print("{}usage: {} [-help/-h/-?] [-options] {}\n\n", program_description, program_name, remainder_name); @@ -543,7 +543,7 @@ void setting_container::print_help() } for (auto setting : grouped.second) { - size_t numPadding = std::max(static_cast(0), 28 - (setting->primary_name().size() + 4)); + size_t numPadding = std::max(static_cast(0), 28 - std::min((size_t) 28, (setting->primary_name().size() + 4))); fmt::print( " -{} {:{}} {}\n", setting->primary_name(), setting->format(), numPadding, setting->description()); @@ -555,7 +555,10 @@ void setting_container::print_help() printf("\n"); } - throw quit_after_help_exception(); + if (fatal) + { + throw quit_after_help_exception(); + } } void setting_container::print_summary() @@ -679,7 +682,7 @@ std::vector setting_container::parse(parser_base_t &parser) } if (parser.token == "help" || parser.token == "h" || parser.token == "?") { - print_help(); + print_help(true); } else if (parser.token == "rst") { print_rst_documentation(); } diff --git a/include/common/settings.hh b/include/common/settings.hh index b6a46023..f2b709f2 100644 --- a/include/common/settings.hh +++ b/include/common/settings.hh @@ -577,7 +577,7 @@ public: inline auto grouped() const { return _grouped_settings; } - void print_help(); + void print_help(bool fatal); void print_summary(); void print_rst_documentation(); diff --git a/light/light.cc b/light/light.cc index ff7e3575..ea96b0f2 100644 --- a/light/light.cc +++ b/light/light.cc @@ -447,13 +447,16 @@ void light_settings::initialize(int argc, const char **argv) common_settings::initialize(argc - 1, argv + 1); if (remainder.size() <= 0 || remainder.size() > 1) { - print_help(); + print_help(true); } sourceMap = remainder[0]; } catch (parse_exception &ex) { + print_help(false); + logging::print("ERROR OCCURRED WHEN TRYING TO PARSE ARGUMENTS:\n"); logging::print(ex.what()); - print_help(); + logging::print("\n\n"); + throw settings::quit_after_help_exception(); } } diff --git a/maputil/maputil.cc b/maputil/maputil.cc index ed637006..65dc3fd6 100644 --- a/maputil/maputil.cc +++ b/maputil/maputil.cc @@ -956,7 +956,7 @@ int maputil_main(int argc, const char **argv) logging::init(std::nullopt, maputil_options); if (maputil_options.operations.empty()) { - maputil_options.print_help(); + maputil_options.print_help(true); return 1; } diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 4ec0949d..a21dbd53 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -587,7 +587,7 @@ void qbsp_settings::initialize(int argc, const char **argv) common_settings::initialize(argc - 1, argv + 1); if (remainder.size() <= 0 || remainder.size() > 2) { - print_help(); + print_help(true); } qbsp_options.map_path = remainder[0]; @@ -596,8 +596,11 @@ void qbsp_settings::initialize(int argc, const char **argv) qbsp_options.bsp_path = remainder[1]; } } catch (parse_exception &ex) { + print_help(false); + logging::print("ERROR OCCURRED WHEN TRYING TO PARSE ARGUMENTS:\n"); logging::print(ex.what()); - print_help(); + logging::print("\n\n"); + throw settings::quit_after_help_exception(); } } diff --git a/vis/vis.cc b/vis/vis.cc index eca2114a..9b01cb04 100644 --- a/vis/vis.cc +++ b/vis/vis.cc @@ -46,13 +46,16 @@ void vis_settings::initialize(int argc, const char **argv) common_settings::initialize(argc - 1, argv + 1); if (remainder.size() <= 0 || remainder.size() > 2) { - print_help(); + print_help(true); } sourceMap = DefaultExtension(remainder[0], "bsp"); } catch (parse_exception &ex) { + print_help(false); + logging::print("ERROR OCCURRED WHEN TRYING TO PARSE ARGUMENTS:\n"); logging::print(ex.what()); - print_help(); + logging::print("\n\n"); + throw settings::quit_after_help_exception(); } } } // namespace settings