mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-17 17:27:19 +02:00
Write paths as UTF-8 in the remaining messages
Each built its text with path::string(), which throws for a character outside the ANSI code page, so the real error or message was replaced by a code-page error.
This commit is contained in:
1 parent
619331aa0b
commit
2d3430cbd4
6 files changed
+17
-11
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "cas_codec.h"
|
||||
#include "Engine/Core/Platform/path_text.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
@@ -68,7 +69,7 @@ HMODULE oodle(const std::filesystem::path& gameRoot) {
|
||||
std::ranges::sort(matches);
|
||||
handle = LoadLibraryExW(matches.back().c_str(), nullptr,
|
||||
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (!handle) throw std::runtime_error("Cannot load " + matches.back().string() +
|
||||
if (!handle) throw std::runtime_error("Cannot load " + path_utf8(matches.back()) +
|
||||
" (Windows error " + std::to_string(GetLastError()) + ")");
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Engine/Game/Build/20260929/engine.h"
|
||||
#include "Engine/Game/World/custom_level_manifest.h"
|
||||
#include "Engine/Core/Platform/memory.h"
|
||||
#include "Engine/Core/Platform/path_text.h"
|
||||
#include "Engine/Game/Build/20260929/live_mods.h"
|
||||
#include "Engine/Game/Build/addresses.h"
|
||||
#include "Engine/Vfs/mod_catalog.h"
|
||||
@@ -211,7 +212,7 @@ bool refresh_toc(const std::string &superbundle, const std::filesystem::path &fi
|
||||
std::ifstream in(file, std::ios::binary);
|
||||
std::vector<char> bytes((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
||||
if (bytes.size() <= native::toc_header + 4) {
|
||||
problem = file.filename().string() + " could not be read";
|
||||
problem = path_utf8(file.filename()) + " could not be read";
|
||||
return false;
|
||||
}
|
||||
const auto base = reinterpret_cast<std::uintptr_t>(GetModuleHandleW(nullptr));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Engine/Vfs/mod_list.h"
|
||||
#include "Engine/Core/Json/json.h"
|
||||
#include "Engine/Core/Platform/path_text.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
@@ -46,23 +47,23 @@ void write_atomically(const fs::path &path, const std::string &text) {
|
||||
stream.write(text.data(), static_cast<std::streamsize>(text.size()));
|
||||
stream.flush();
|
||||
if (!stream)
|
||||
throw std::runtime_error("Could not write " + path.filename().string() + ". The previous copy was kept.");
|
||||
throw std::runtime_error("Could not write " + path_utf8(path.filename()) + ". The previous copy was kept.");
|
||||
}
|
||||
if (!MoveFileExW(temporary.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH))
|
||||
throw std::runtime_error("Could not replace " + path.filename().string() + ". The previous copy was kept.");
|
||||
throw std::runtime_error("Could not replace " + path_utf8(path.filename()) + ". The previous copy was kept.");
|
||||
}
|
||||
|
||||
std::string read_file(const fs::path &path, std::size_t limit) {
|
||||
std::error_code error;
|
||||
const auto size = fs::file_size(path, error);
|
||||
if (error)
|
||||
throw std::runtime_error("Could not open " + path.filename().string() + ".");
|
||||
throw std::runtime_error("Could not open " + path_utf8(path.filename()) + ".");
|
||||
if (size > limit)
|
||||
throw std::runtime_error(path.filename().string() + " is too large.");
|
||||
throw std::runtime_error(path_utf8(path.filename()) + " is too large.");
|
||||
std::ifstream stream(path, std::ios::binary);
|
||||
std::string text(static_cast<std::size_t>(size), '\0');
|
||||
if (!stream.read(text.data(), static_cast<std::streamsize>(text.size())))
|
||||
throw std::runtime_error("Could not read " + path.filename().string() + ".");
|
||||
throw std::runtime_error("Could not read " + path_utf8(path.filename()) + ".");
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "trainer_session.h"
|
||||
#include "Engine/Core/Json/json.h"
|
||||
#include "Engine/Core/Log/logging.h"
|
||||
#include "Engine/Core/Platform/path_text.h"
|
||||
#include "Engine/Game/Build/addresses.h"
|
||||
#include "Engine/Game/Build/20260929/no_bail.h"
|
||||
#include "Engine/Game/Build/20260929/physics_tuning.h"
|
||||
@@ -1706,7 +1707,7 @@ std::string run(std::string_view verb, const std::vector<std::string> &a) {
|
||||
file << std::format("{}\t0x{:x}\t{}\t{:.6g}\t{:.6g}\n", e.id, e.offset,
|
||||
e.kind == Kind::real ? "real" : e.kind == Kind::flag ? "flag" : e.kind == Kind::curve ? "curve" :
|
||||
e.kind == Kind::graph ? "graph" : "int", e.stock, e.value);
|
||||
return std::format("Wrote {} values to {}.", s.entries.size(), (directory / L"tuning-values.txt").string());
|
||||
return std::format("Wrote {} values to {}.", s.entries.size(), path_utf8(directory / L"tuning-values.txt"));
|
||||
}
|
||||
if (v == "selftest") {
|
||||
if (s.test.step) return "The self test is already running.";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "native_menu_dump.h"
|
||||
#include "native_menu_data.h"
|
||||
#include "Engine/Core/Log/logging.h"
|
||||
#include "Engine/Core/Platform/path_text.h"
|
||||
#include "Engine/Game/Abi/native_data.h"
|
||||
#include "Engine/Game/Build/addresses.h"
|
||||
#include "Engine/Game/Build/20260929/engine.h"
|
||||
@@ -225,7 +226,7 @@ void run_pending_ui_dump(std::uintptr_t base) noexcept {
|
||||
if (text.empty()) text = "asset " + name + " is not loaded in any domain\n";
|
||||
const auto path = dump_path("asset", GetTickCount64());
|
||||
std::ofstream(path, std::ios::trunc) << text;
|
||||
logging::log(logging::Level::info, logging::Channel::ui, "UI dump: asset {} written to {}.", name, path.string());
|
||||
logging::log(logging::Level::info, logging::Channel::ui, "UI dump: asset {} written to {}.", name, path_utf8(path));
|
||||
return;
|
||||
}
|
||||
std::uint32_t only_schema{};
|
||||
@@ -255,7 +256,7 @@ void run_pending_ui_dump(std::uintptr_t base) noexcept {
|
||||
out << "roots " << roots << ", written " << written << ", filter " << (what.empty() ? "all" : what) << "\n"
|
||||
<< text;
|
||||
logging::log(logging::Level::info, logging::Channel::ui,
|
||||
"UI dump: {} of {} roots written to {}.", written, roots, path.string());
|
||||
"UI dump: {} of {} roots written to {}.", written, roots, path_utf8(path));
|
||||
} catch (const std::exception& error) {
|
||||
logging::log(logging::Level::warning, logging::Channel::ui, "UI dump failed: {}.", error.what());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "overlay_internal.h"
|
||||
#include "skate_style.h"
|
||||
#include "Engine/Core/Profiling/profiler.h"
|
||||
#include "Engine/Core/Platform/path_text.h"
|
||||
#include <cstdio>
|
||||
#include <format>
|
||||
|
||||
@@ -251,7 +252,7 @@ void draw_perf_window() {
|
||||
for (const auto& thread : report->threads)
|
||||
ImGui::TextDisabled(" %5.1f%% thread %u %s", thread.cpu_percent, thread.id, thread.label.c_str());
|
||||
if (!report->error.empty()) ImGui::TextColored(ImColor(skate::danger), "%s", report->error.c_str());
|
||||
const auto report_path = report->report.string(), folded_path = report->folded.string();
|
||||
const auto report_path = path_utf8(report->report), folded_path = path_utf8(report->folded);
|
||||
ImGui::TextDisabled("Report: %s", report_path.c_str());
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Copy##report")) ImGui::SetClipboardText(report_path.c_str());
|
||||
|
||||
Reference in new issue
Block a user