Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes #14992

Merged
merged 4 commits into from Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellPad.cpp
Expand Up @@ -60,7 +60,7 @@ pad_info::pad_info(utils::serial& ar)
, port_setting(ar)
, reported_info(ar)
{
reported_info = {};
//reported_info = {};
sys_io_serialize(ar);
}

Expand Down
34 changes: 26 additions & 8 deletions rpcs3/Emu/System.cpp
Expand Up @@ -3848,30 +3848,36 @@ void Emulator::GetBdvdDir(std::string& bdvd_dir, std::string& sfb_dir, std::stri
std::string main_dir;
std::string_view main_dir_name;

for (std::string search_dir = elf_dir;;)
std::string parent_dir;

for (std::string search_dir = elf_dir.substr(0, elf_dir.find_last_not_of(fs::delim) + 1);; search_dir = std::move(parent_dir))
{
std::string parent_dir = fs::get_parent_dir(search_dir);
parent_dir = fs::get_parent_dir(search_dir);

if (parent_dir.size() == search_dir.size())
{
// Keep looking until root directory is reached
break;
}

if (IsValidSfb(parent_dir + "/PS3_DISC.SFB"))
std::string_view dir_name = std::string_view{search_dir}.substr(search_dir.find_last_of(fs::delim) + 1);

if (dir_name.size() != ("PS3_GAME"sv).size())
{
main_dir_name = std::string_view{search_dir}.substr(search_dir.find_last_of(fs::delim) + 1);
continue;
}

if (main_dir_name == "PS3_GAME" || std::regex_match(main_dir_name.begin(), main_dir_name.end(), std::regex("^PS3_GM[[:digit:]]{2}$")))
if (dir_name == "PS3_GAME"sv || std::regex_match(dir_name.begin(), dir_name.end(), std::regex("^PS3_GM[[:digit:]]{2}$")))
{
if (IsValidSfb(parent_dir + "/PS3_DISC.SFB"))
{
// Remember valid disc directory
main_dir_name = {}; // Remove old string reference
main_dir = search_dir;
sfb_dir = parent_dir;
main_dir_name = std::string_view{main_dir}.substr(main_dir.find_last_of(fs::delim) + 1);
}
}

search_dir = std::move(parent_dir);
}

if (!sfb_dir.empty())
Expand Down Expand Up @@ -4005,7 +4011,19 @@ bool Emulator::IsVsh()
bool Emulator::IsValidSfb(const std::string& path)
{
fs::file sfb_file{path, fs::read + fs::isfile};
return sfb_file && sfb_file.size() >= 4 && sfb_file.read<u32>() == ".SFB"_u32;

if (sfb_file)
{
if (sfb_file.size() < 4 || sfb_file.read<u32>() != ".SFB"_u32)
{
sys_log.error("PS3_DISC.SFB file may be truncated or corrupted. (path='%s')", path);
return false;
}

return true;
}

return false;
}

void Emulator::SaveSettings(const std::string& settings, const std::string& title_id)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/system_progress.cpp
Expand Up @@ -201,7 +201,7 @@ void progress_dialog_server::operator()()
if (pdone < ptotal && g_cfg.misc.show_ppu_compilation_hint)
{
const u64 passed_usec = (get_system_time() - start_time);
const u64 remaining_usec = passed_usec * (pdone ? ((static_cast<u64>(ptotal) - pdone) / pdone) : ptotal);
const u64 remaining_usec = pdone ? utils::rational_mul<u64>(passed_usec, pdone, static_cast<u64>(ptotal) - pdone) : (passed_usec * ptotal);

// Only show compile notification if we estimate at least 100ms
if (remaining_usec >= 100'000ULL)
Expand Down
37 changes: 22 additions & 15 deletions rpcs3/main.cpp
Expand Up @@ -86,7 +86,8 @@ static semaphore<> s_qt_init;

static atomic_t<bool> s_headless = false;
static atomic_t<bool> s_no_gui = false;
static atomic_t<char*> s_argv0;
static atomic_t<char*> s_argv0 = nullptr;
static bool s_is_error_launch = false;

std::string g_input_config_override;

Expand All @@ -105,25 +106,30 @@ LOG_CHANNEL(q_debug, "QDEBUG");
#ifdef __linux__
extern void jit_announce(uptr, usz, std::string_view);
#endif
std::string buf(_text);
std::string buf;

// Check if thread id is in string
if (_text.find("\nThread id = "sv) == umax && !thread_ctrl::is_main())
if (!s_is_error_launch)
{
// Append thread id if it isn't already, except on main thread
fmt::append(buf, "\n\nThread id = %u.", thread_ctrl::get_tid());
}
buf = std::string(_text);

if (!g_tls_serialize_name.empty())
{
fmt::append(buf, "\nSerialized Object: %s", g_tls_serialize_name);
}
// Check if thread id is in string
if (_text.find("\nThread id = "sv) == umax && !thread_ctrl::is_main())
{
// Append thread id if it isn't already, except on main thread
fmt::append(buf, "\n\nThread id = %u.", thread_ctrl::get_tid());
}

fmt::append(buf, "\nTitle: \"%s\" (emulation is %s)", Emu.GetTitleAndTitleID(), Emu.IsStopped() ? "stopped" : "running");
fmt::append(buf, "\nBuild: \"%s\"", rpcs3::get_verbose_version());
fmt::append(buf, "\nDate: \"%s\"", std::chrono::system_clock::now());
if (!g_tls_serialize_name.empty())
{
fmt::append(buf, "\nSerialized Object: %s", g_tls_serialize_name);
}

fmt::append(buf, "\nTitle: \"%s\" (emulation is %s)", Emu.GetTitleAndTitleID(), Emu.IsStopped() ? "stopped" : "running");
fmt::append(buf, "\nBuild: \"%s\"", rpcs3::get_verbose_version());
fmt::append(buf, "\nDate: \"%s\"", std::chrono::system_clock::now());
}

std::string_view text = buf;
std::string_view text = s_is_error_launch ? _text : buf;

if (s_headless)
{
Expand Down Expand Up @@ -457,6 +463,7 @@ int main(int argc, char** argv)
error += argv[i];
}

s_is_error_launch = true;
report_fatal_error(error);
}

Expand Down