[C++] Uplift version to C++20

This commit is contained in:
Gliniak
2024-12-25 12:05:27 +01:00
committed by Radosław Gliński
parent a6e3d77504
commit c3586bc165
24 changed files with 175 additions and 162 deletions

View File

@@ -103,7 +103,8 @@ std::filesystem::path ContentManager::ResolvePackagePath(
// Content path:
// content_root/title_id/content_type/data_file_name/
auto get_package_path = [&, data, disc_number](const uint32_t title_id) {
uint64_t used_xuid = (data.xuid != -1 && data.xuid != 0) ? data.xuid : xuid;
uint64_t used_xuid =
(data.xuid != -1 && data.xuid != 0) ? data.xuid.get() : xuid;
auto package_root =
ResolvePackageRoot(used_xuid, title_id, data.content_type);
@@ -263,7 +264,8 @@ X_RESULT ContentManager::WriteContentHeaderFile(const uint64_t xuid,
if (data.xuid == -1) {
data.xuid = xuid;
}
uint64_t used_xuid = (data.xuid != -1 && data.xuid != 0) ? data.xuid : xuid;
uint64_t used_xuid =
(data.xuid != -1 && data.xuid != 0) ? data.xuid.get() : xuid;
auto header_path = ResolvePackageHeaderPath(data.file_name(), used_xuid,
data.title_id, data.content_type);

View File

@@ -621,8 +621,8 @@ DECLARE_XAM_EXPORT1(XamLoaderGetMediaInfoEx, kContent, kStub);
dword_result_t XamContentLaunchImageFromFileInternal_entry(
lpstring_t image_location, lpstring_t xex_name, dword_t unk) {
const std::string image_path = image_location;
const std::string xex_name_ = xex_name;
const std::string image_path = static_cast<std::string>(image_location);
const std::string xex_name_ = static_cast<std::string>(xex_name);
vfs::Entry* entry = kernel_state()->file_system()->ResolvePath(image_path);

View File

@@ -115,8 +115,9 @@ dword_result_t XamContentAggregateCreateEnumerator_entry(qword_t xuid,
for (auto& title_id : title_ids) {
// Get all content data.
auto content_datas = kernel_state()->content_manager()->ListContent(
static_cast<uint32_t>(DummyDeviceId::HDD), xuid == -1 ? 0 : xuid,
title_id, content_type_enum);
static_cast<uint32_t>(DummyDeviceId::HDD),
xuid == -1 ? 0 : static_cast<uint64_t>(xuid), title_id,
content_type_enum);
for (const auto& content_data : content_datas) {
auto item = e->AppendItem();
assert_not_null(item);

View File

@@ -111,14 +111,14 @@ void XamModule::SaveLoaderData() {
std::filesystem::path host_path = loader_data_.host_path;
std::string launch_path = loader_data_.launch_path;
auto remove_prefix = [&launch_path](std::string& prefix) {
auto remove_prefix = [&launch_path](std::string_view prefix) {
if (launch_path.compare(0, prefix.length(), prefix) == 0) {
launch_path = launch_path.substr(prefix.length());
}
};
remove_prefix(std::string("game:\\"));
remove_prefix(std::string("d:\\"));
remove_prefix("game:\\");
remove_prefix("d:\\");
if (host_path.extension() == ".xex") {
host_path.remove_filename();

View File

@@ -829,9 +829,11 @@ static dword_result_t XamShowMessageBoxUi(
};
const Emulator* emulator = kernel_state()->emulator();
ui::ImGuiDrawer* imgui_drawer = emulator->imgui_drawer();
auto text = xe::to_utf8(text_ptr.value());
result = xeXamDispatchDialog<MessageBoxDialog>(
new MessageBoxDialog(imgui_drawer, title, xe::to_utf8(text_ptr.value()),
buttons, active_button),
new MessageBoxDialog(imgui_drawer, title, text, buttons,
static_cast<uint32_t>(active_button)),
close, overlapped);
}
return result;
@@ -1012,12 +1014,15 @@ dword_result_t XamShowKeyboardUI_entry(
};
const Emulator* emulator = kernel_state()->emulator();
ui::ImGuiDrawer* imgui_drawer = emulator->imgui_drawer();
std::string title_str = title ? xe::to_utf8(title.value()) : "";
std::string desc_str = description ? xe::to_utf8(description.value()) : "";
std::string def_text_str =
default_text ? xe::to_utf8(default_text.value()) : "";
result = xeXamDispatchDialogEx<KeyboardInputDialog>(
new KeyboardInputDialog(
imgui_drawer, title ? xe::to_utf8(title.value()) : "",
description ? xe::to_utf8(description.value()) : "",
default_text ? xe::to_utf8(default_text.value()) : "",
buffer_length),
new KeyboardInputDialog(imgui_drawer, title_str, desc_str, def_text_str,
buffer_length),
close, overlapped);
}
return result;

View File

@@ -620,7 +620,8 @@ dword_result_t XamUserCreateAchievementEnumerator_entry(
}
const util::XdbfGameData db = kernel_state()->title_xdbf();
uint32_t title_id_ = title_id ? title_id : kernel_state()->title_id();
uint32_t title_id_ =
title_id ? static_cast<uint32_t>(title_id) : kernel_state()->title_id();
const auto user_title_achievements =
kernel_state()->achievement_manager()->GetTitleAchievements(

View File

@@ -354,7 +354,7 @@ dword_result_t ObCreateSymbolicLink_entry(pointer_t<X_ANSI_STRING> path_ptr,
auto target = xe::utf8::canonicalize_guest_path(
util::TranslateAnsiString(kernel_memory(), target_ptr));
if (xe::utf8::starts_with(path, u8"\\??\\")) {
if (xe::utf8::starts_with(path, "\\??\\")) {
path = path.substr(4); // Strip the full qualifier
}

View File

@@ -349,7 +349,9 @@ class object_ref {
void reset(T* value) noexcept { object_ref(value).swap(*this); }
inline bool operator==(const T* right) noexcept { return value_ == right; }
inline bool operator==(const T* right) const noexcept {
return value_ == right;
}
private:
T* value_ = nullptr;