diff options
Diffstat (limited to 'zenserver/config.cpp')
| -rw-r--r-- | zenserver/config.cpp | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 1e847ce3d..a5a747150 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -9,16 +9,18 @@ #include <zencore/string.h> #include <zenhttp/zenhttp.h> -#pragma warning(push) -#pragma warning(disable : 4267) // warning C4267: '=': conversion from 'size_t' to 'US', possible loss of data +ZEN_THIRD_PARTY_INCLUDES_START #include <cxxopts.hpp> -#pragma warning(pop) - #include <fmt/format.h> #include <zencore/logging.h> #include <sol/sol.hpp> +ZEN_THIRD_PARTY_INCLUDES_END -#include <conio.h> +#if ZEN_PLATFORM_WINDOWS +# include <conio.h> +#else +# include <pwd.h> +#endif #if ZEN_PLATFORM_WINDOWS @@ -53,7 +55,9 @@ PickDefaultStateDirectory() std::filesystem::path PickDefaultStateDirectory() { - return std::filesystem::path("~/.zen"); + int UserId = getuid(); + const passwd* Passwd = getpwuid(UserId); + return std::filesystem::path(Passwd->pw_dir) / ".zen"; } #endif @@ -150,6 +154,22 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) ""); #endif +#if ZEN_WITH_TRACE + options.add_option("ue-trace", + "", + "tracehost", + "Hostname to send the trace to", + cxxopts::value<std::string>(GlobalOptions.TraceHost)->default_value(""), + ""); + + options.add_option("ue-trace", + "", + "tracefile", + "Path to write a trace to", + cxxopts::value<std::string>(GlobalOptions.TraceFile)->default_value(""), + ""); +#endif // ZEN_WITH_TRACE + options.add_option("diagnostics", "", "crash", @@ -277,8 +297,13 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) if (result.count("help")) { zen::logging::ConsoleLog().info("{}", options.help()); +#if ZEN_PLATFORM_WINDOWS zen::logging::ConsoleLog().info("Press any key to exit!"); _getch(); +#else + // Assume the user's in a terminal on all other platforms and that + // they'll use less/more/etc. if need be. +#endif exit(0); } @@ -311,7 +336,15 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio { using namespace fmt::literals; +<<<<<<< HEAD + std::filesystem::path ConfigScript = DataRoot / "zen_cfg.lua"; + zen::IoBuffer LuaScript = zen::IoBufferBuilder::MakeFromFile(ConfigScript); +||||||| b2cc49b + std::filesystem::path ConfigScript = DataRoot / "zen_cfg.lua"; + zen::IoBuffer LuaScript = zen::IoBufferBuilder::MakeFromFile(ConfigScript.native().c_str()); +======= zen::IoBuffer LuaScript = zen::IoBufferBuilder::MakeFromFile(Path.native().c_str()); +>>>>>>> origin/main if (LuaScript) { @@ -320,6 +353,7 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio lua.open_libraries(sol::lib::base); lua.set_function("getenv", [&](const std::string env) -> sol::object { +#if ZEN_PLATFORM_WINDOWS std::wstring EnvVarValue; size_t RequiredSize = 0; std::wstring EnvWide = zen::Utf8ToWide(env); @@ -331,6 +365,10 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio EnvVarValue.resize(RequiredSize); _wgetenv_s(&RequiredSize, EnvVarValue.data(), RequiredSize, EnvWide.c_str()); return sol::make_object(lua, zen::WideToUtf8(EnvVarValue.c_str())); +#else + ZEN_UNUSED(env); + return sol::make_object(lua, sol::lua_nil); +#endif }); try |