mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-26 17:26:42 +01:00
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.
This commit is contained in:
1 parent
a9742673da
commit
3fe6a7e607
2 files changed
+6
-4
No files matched your search
+4
-3
@@ -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<std::string> 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\<mod>\reskate-levels.json.
|
||||
|
||||
@@ -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 <algorithm>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user