diff options
| author | Martin Ridgers <[email protected]> | 2021-09-22 22:46:21 +0200 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-09-22 22:46:21 +0200 |
| commit | 1623f7471b9b0c09b7e9c98652c280d1f6559ca1 (patch) | |
| tree | 78518774fe79ddf3e266a75c699b697971f52f4b /zenserver/config.cpp | |
| parent | Merged main into linux-mac (diff) | |
| parent | Clang format fix. (diff) | |
| download | zen-1623f7471b9b0c09b7e9c98652c280d1f6559ca1.tar.xz zen-1623f7471b9b0c09b7e9c98652c280d1f6559ca1.zip | |
Merge main
Diffstat (limited to 'zenserver/config.cpp')
| -rw-r--r-- | zenserver/config.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 164d2a792..c21638258 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -17,6 +17,8 @@ #include <zencore/logging.h> #include <sol/sol.hpp> +#include <conio.h> + #if ZEN_PLATFORM_WINDOWS // Used for getting My Documents for default data directory @@ -219,7 +221,8 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z if (result.count("help")) { zen::logging::ConsoleLog().info("{}", options.help()); - + zen::logging::ConsoleLog().info("Press any key to exit!"); + _getch(); exit(0); } @@ -274,14 +277,24 @@ ParseServiceConfig(const std::filesystem::path& DataRoot, ZenServiceConfig& Serv try { - sol::load_result config = lua.load(std::string_view((const char*)LuaScript.Data(), LuaScript.Size()), "zencfg"); + sol::load_result config = lua.load(std::string_view((const char*)LuaScript.Data(), LuaScript.Size()), "zen_cfg"); + + if (!config.valid()) + { + sol::error err = config; + + std::string ErrorString = sol::to_string(config.status()); + + throw std::runtime_error("{} error: {}"_format(ErrorString, err.what())); + } + config(); } catch (std::exception& e) { - ZEN_ERROR("config script failure: {}", e.what()); + ZEN_ERROR("config failure: {}", e.what()); - throw std::runtime_error("fatal zen global config script ({}) failure: {}"_format(ConfigScript, e.what()).c_str()); + throw std::runtime_error("failed to run global config script ('{}'): {}"_format(ConfigScript, e.what()).c_str()); } ServiceConfig.MeshEnabled = lua["mesh"]["enable"].get_or(ServiceConfig.MeshEnabled); |