Compare commits

..

No commits in common. "13da5a82ccecb407bb7060c9e6b54353d71d0758" and "162cb18d9d26555be71ef3c1992eeba37ef16a7d" have entirely different histories.

5 changed files with 18 additions and 82 deletions

View File

@ -42,7 +42,7 @@ void MntPoints::UnmountAll() {
}
std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_read_only,
HostPathType path_type) {
bool force_base_path) {
// Evil games like Turok2 pass double slashes e.g /app0//game.kpf
std::string corrected_path(path);
size_t pos = corrected_path.find("//");
@ -80,24 +80,8 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
}
patch_path /= rel_path;
std::filesystem::path mods_path = mount->host_path;
mods_path += "-mods";
mods_path /= rel_path;
if (path_type == HostPathType::Mod) {
return mods_path;
} else if (path_type == HostPathType::Patch) {
return patch_path;
}
if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) &&
path_type != HostPathType::Base && std::filesystem::exists(mods_path)) {
return mods_path;
}
if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) &&
path_type != HostPathType::Base && !ignore_game_patches &&
std::filesystem::exists(patch_path)) {
!force_base_path && !ignore_game_patches && std::filesystem::exists(patch_path)) {
return patch_path;
}
@ -159,7 +143,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
return std::optional<std::filesystem::path>(current_path);
};
if (path_type != HostPathType::Base && !ignore_game_patches) {
if (!force_base_path && !ignore_game_patches) {
if (const auto path = search(patch_path)) {
return *path;
}
@ -176,54 +160,34 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
// TODO: Does not handle mount points inside mount points.
void MntPoints::IterateDirectory(std::string_view guest_directory,
const IterateDirectoryCallback& callback) {
const auto base_path = GetHostPath(guest_directory, nullptr, HostPathType::Base);
// Forces path types so as not to resolve to base path
const auto patch_path = GetHostPath(guest_directory, nullptr, HostPathType::Patch);
const auto mod_path = GetHostPath(guest_directory, nullptr, HostPathType::Mod);
const auto base_path = GetHostPath(guest_directory, nullptr, true);
const auto patch_path = GetHostPath(guest_directory, nullptr, false);
// Only need to consider patch path if it exists and does not resolve to the same as base.
const auto apply_patch = base_path != patch_path && std::filesystem::exists(patch_path);
// Prepend entries for . and .., as both are treated as files on PS4.
callback(base_path / ".", false);
callback(base_path / "..", false);
// Pass 1: Any files that existed in the base directory, using mod/patch directory if needed.
// Pass 1: Any files that existed in the base directory, using patch directory if needed.
if (std::filesystem::exists(base_path)) {
for (const auto& entry : std::filesystem::directory_iterator(base_path)) {
const auto mod_entry_path = mod_path / entry.path().filename();
const auto patch_entry_path = patch_path / entry.path().filename();
if (std::filesystem::exists(mod_entry_path)) {
callback(mod_entry_path, !std::filesystem::is_directory(mod_entry_path));
continue;
} else if (std::filesystem::exists(patch_entry_path)) {
callback(patch_entry_path, !std::filesystem::is_directory(patch_entry_path));
continue;
if (apply_patch) {
const auto patch_entry_path = patch_path / entry.path().filename();
if (std::filesystem::exists(patch_entry_path)) {
callback(patch_entry_path, !std::filesystem::is_directory(patch_entry_path));
continue;
}
}
callback(entry.path(), !entry.is_directory());
}
}
// Pass 2: Any files that exist only in the patch directory.
if (std::filesystem::exists(patch_path)) {
if (apply_patch) {
for (const auto& entry : std::filesystem::directory_iterator(patch_path)) {
const auto base_entry_path = base_path / entry.path().filename();
if (!std::filesystem::exists(base_entry_path)) {
const auto mod_entry_path = mod_path / entry.path().filename();
if (std::filesystem::exists(mod_entry_path)) {
callback(mod_entry_path, !std::filesystem::is_directory(mod_entry_path));
continue;
}
callback(entry.path(), !entry.is_directory());
}
}
}
// Pass 3: Any files that exist only in the mod directory (confirmed this can be valid)
if (std::filesystem::exists(mod_path)) {
for (const auto& entry : std::filesystem::directory_iterator(mod_path)) {
const auto base_entry_path = base_path / entry.path().filename();
const auto patch_entry_path = patch_path / entry.path().filename();
if (!std::filesystem::exists(base_entry_path) &&
!std::filesystem::exists(patch_entry_path)) {
callback(entry.path(), !entry.is_directory());
}
}

View File

@ -36,13 +36,6 @@ public:
bool read_only;
};
enum class HostPathType {
Default, // Prioritizes Mod, then patch, then base
Base,
Patch,
Mod
};
explicit MntPoints() = default;
~MntPoints() = default;
@ -52,8 +45,7 @@ public:
void UnmountAll();
std::filesystem::path GetHostPath(std::string_view guest_directory,
bool* is_read_only = nullptr,
HostPathType host_path = HostPathType::Default);
bool* is_read_only = nullptr, bool force_base_path = false);
using IterateDirectoryCallback =
std::function<void(const std::filesystem::path& host_path, bool is_file)>;
void IterateDirectory(std::string_view guest_directory,

View File

@ -339,11 +339,7 @@ s32 PS4_SYSV_ABI sceKernelMprotect(const void* addr, u64 size, s32 prot) {
Core::MemoryManager* memory_manager = Core::Memory::Instance();
Core::MemoryProt protection_flags = static_cast<Core::MemoryProt>(prot);
s32 result = memory_manager->Protect(aligned_addr, aligned_size, protection_flags);
if (result == ORBIS_OK) {
memory_manager->InvalidateMemory(aligned_addr, aligned_size);
}
return result;
return memory_manager->Protect(aligned_addr, aligned_size, protection_flags);
}
s32 PS4_SYSV_ABI posix_mprotect(const void* addr, u64 size, s32 prot) {
@ -374,7 +370,6 @@ s32 PS4_SYSV_ABI sceKernelMtypeprotect(const void* addr, u64 size, s32 mtype, s3
s32 result = memory_manager->Protect(aligned_addr, aligned_size, protection_flags);
if (result == ORBIS_OK) {
memory_manager->SetDirectMemoryType(aligned_addr, aligned_size, mtype);
memory_manager->InvalidateMemory(aligned_addr, aligned_size);
}
return result;
}

View File

@ -109,8 +109,7 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
} else {
game_folder = file.parent_path();
if (const auto game_folder_name = game_folder.filename().string();
game_folder_name.ends_with("-UPDATE") || game_folder_name.ends_with("-patch") ||
game_folder_name.ends_with("-mods")) {
game_folder_name.ends_with("-UPDATE") || game_folder_name.ends_with("-patch")) {
// If an executable was launched from a separate update directory,
// use the base game directory as the game folder.
const std::string base_name = game_folder_name.substr(0, game_folder_name.rfind('-'));
@ -293,13 +292,6 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
}
}
std::filesystem::path mods_folder = game_folder;
mods_folder += "-mods";
if (std::filesystem::exists(mods_folder) && !std::filesystem::is_empty(mods_folder)) {
LOG_INFO(Loader, "Files found in game mods folder");
}
// Create stdin/stdout/stderr
Common::Singleton<FileSys::HandleTable>::Instance()->CreateStdHandles();

View File

@ -137,14 +137,7 @@ Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_
Presenter::~Presenter() {
ImGui::Layer::RemoveLayer(Common::Singleton<Core::Devtools::Layer>::Instance());
draw_scheduler.Finish();
present_scheduler.Finish();
flip_scheduler.Finish();
Check(draw_scheduler.CommandBuffer().reset());
Check(present_scheduler.CommandBuffer().reset());
Check(flip_scheduler.CommandBuffer().reset());
const vk::Device device = instance.GetDevice();
for (auto& frame : present_frames) {
vmaDestroyImage(instance.GetAllocator(), frame.image, frame.allocation);