From 3fe6a7e607fce8de8c4b885ee0cdffa48717feb4 Mon Sep 17 00:00:00 2001 From: xThrasherrr Date: Mon, 5 Oct 2026 17:51:03 -0600 Subject: [PATCH] Use UTF-8 for config paths in server messages In a server folder outside the ANSI code page, path.string() threw while building the error for a failed config write. At startup that second throw escaped the catch in main, so the server crashed with an empty log instead of saying it could not write the config. --- Server/main.cpp | 7 ++++--- Server/server_config.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Server/main.cpp b/Server/main.cpp index ef9a1b7b..e4125140 100644 --- a/Server/main.cpp +++ b/Server/main.cpp @@ -8,6 +8,7 @@ #include "server_update.h" #include "steam_server.h" #include "Extension/Multiplayer/Session/monotonic_clock.h" +#include "Engine/Core/Platform/path_text.h" #include "Engine/Core/Text/word_filter.h" #include "Engine/Game/World/world_layer_catalog.h" #include "Engine/Game/World/world_names.h" @@ -301,14 +302,14 @@ int run(int argc, char **argv, bool skip_update) { const bool fresh = !std::filesystem::exists(config_file); std::vector added; config = load_config(config_file, &added); - if (fresh) write_log("Wrote a default " + config_file.filename().string() + ". Edit it to name the server and add admins."); + if (fresh) write_log("Wrote a default " + path_utf8(config_file.filename()) + ". Edit it to name the server and add admins."); if (!added.empty()) { std::string names; for (const auto &name : added) names += (names.empty() ? "" : ", ") + name; - write_log("Added new settings to " + config_file.filename().string() + " with their defaults: " + names + "."); + write_log("Added new settings to " + path_utf8(config_file.filename()) + " with their defaults: " + names + "."); } } catch (const std::exception &e) { - write_log("Cannot read " + config_file.string() + ": " + e.what()); + write_log("Cannot read " + path_utf8(config_file) + ": " + e.what()); return 1; } // Maps: the retail ones and custom maps from Mods\\reskate-levels.json. diff --git a/Server/server_config.cpp b/Server/server_config.cpp index ab2f1840..82b44654 100644 --- a/Server/server_config.cpp +++ b/Server/server_config.cpp @@ -1,5 +1,6 @@ #include "server_config.h" #include "Engine/Core/Json/json.h" +#include "Engine/Core/Platform/path_text.h" #include "Extension/Multiplayer/Net/protocol.h" #include "Engine/Game/World/world_names.h" #include @@ -207,7 +208,7 @@ void save_config(const ServerConfig &c) { { std::ofstream out(temporary, std::ios::binary | std::ios::trunc); out << to_json(c).dump(2) << '\n'; - if (!out) throw std::runtime_error("Cannot write " + temporary.string()); + if (!out) throw std::runtime_error("Cannot write " + path_utf8(temporary)); } std::filesystem::rename(temporary, c.file); }