Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rajkosto/rpcs3 into mgs4
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkosto committed Dec 20, 2019
2 parents 994f56d + 315687d commit 5dc3b41
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 73 deletions.
42 changes: 20 additions & 22 deletions rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,16 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
}
}

std::string trophyPath = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name;
const std::string trophyPath = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name;
if (!trp.Install(trophyPath))
{
sceNpTrophy.error("sceNpTrophyRegisterContext(): Failed to install trophy context '%s' (%s)", trophyPath, fs::g_tls_error);
return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE;
}

TROPUSRLoader* tropusr = new TROPUSRLoader();
std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT";
std::string trophyConfPath = trophyPath + "/TROPCONF.SFM";
const std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT";
const std::string trophyConfPath = trophyPath + "/TROPCONF.SFM";
tropusr->Load(trophyUsrPath, trophyConfPath);
ctxt->tropusr.reset(tropusr);

Expand Down Expand Up @@ -612,8 +612,6 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGa

if (n_name == "trophy")
{
u32 trophy_id = atoi(n->GetAttribute("id").c_str());

if (details)
{
details->numTrophies++;
Expand All @@ -628,6 +626,8 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGa

if (data)
{
const u32 trophy_id = atoi(n->GetAttribute("id").c_str());

if (ctxt->tropusr->GetTrophyUnlockState(trophy_id))
{
data->unlockedTrophies++;
Expand Down Expand Up @@ -691,7 +691,7 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt

if (g_cfg.misc.show_trophy_popups)
{
// Figure out how many zeros are needed for padding. (either 0, 1, or 2)
// Figure out how many zeros are needed for padding. (either 0, 1, or 2)
std::string padding = "";
if (trophyId < 10)
{
Expand All @@ -703,17 +703,16 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt
}

// Get icon for the notification.
std::string paddedTrophyId = padding + std::to_string(trophyId);
std::string trophyIconPath = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name + "/TROP" + paddedTrophyId + ".PNG";
fs::file trophyIconFile = fs::file(vfs::get(trophyIconPath));
size_t iconSize = trophyIconFile.size();
std::vector<uchar> trophyIconData;
trophyIconFile.read(trophyIconData, iconSize);
const std::string padded_trophy_id = padding + std::to_string(trophyId);
const std::string trophy_icon_path = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name + "/TROP" + padded_trophy_id + ".PNG";
fs::file trophy_icon_file = fs::file(vfs::get(trophy_icon_path));
std::vector<uchar> trophy_icon_data;
trophy_icon_file.read(trophy_icon_data, trophy_icon_file.size());

vm::var<SceNpTrophyDetails> details({0});
vm::var<SceNpTrophyData> _({0});

s32 ret = sceNpTrophyGetTrophyInfo(context, handle, trophyId, details, _);
const s32 ret = sceNpTrophyGetTrophyInfo(context, handle, trophyId, details, _);
if (ret != CELL_OK)
{
sceNpTrophy.error("Failed to get info for trophy dialog. Error code %x", ret);
Expand All @@ -722,7 +721,7 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt

if (auto trophy_notification_dialog = Emu.GetCallbacks().get_trophy_notification_dialog())
{
trophy_notification_dialog->ShowTrophyNotification(*details, trophyIconData);
trophy_notification_dialog->ShowTrophyNotification(*details, trophy_icon_data);
}
}

Expand Down Expand Up @@ -844,14 +843,19 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
{
found = true;

if (n->GetAttribute("hidden")[0] == 'y' && !ctxt->tropusr->GetTrophyUnlockState(trophyId)) // Trophy is hidden
const bool hidden = n->GetAttribute("hidden")[0] == 'y';
const bool unlocked = !!ctxt->tropusr->GetTrophyUnlockState(trophyId);

if (hidden && !unlocked) // Trophy is hidden
{
return SCE_NP_TROPHY_ERROR_HIDDEN;
}

if (details)
{
details->trophyId = trophyId;
details->hidden = hidden;

switch (n->GetAttribute("ttype")[0])
{
case 'B': details->trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; break;
Expand All @@ -860,12 +864,6 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
case 'P': details->trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; break;
}

switch (n->GetAttribute("hidden")[0])
{
case 'y': details->hidden = true; break;
case 'n': details->hidden = false; break;
}

for (std::shared_ptr<rXmlNode> n2 = n->GetChildren(); n2; n2 = n2->GetNext())
{
const std::string n2_name = n2->GetName();
Expand All @@ -884,7 +882,7 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
if (data)
{
data->trophyId = trophyId;
data->unlocked = ctxt->tropusr->GetTrophyUnlockState(trophyId) != 0; // ???
data->unlocked = unlocked;
data->timestamp = ctxt->tropusr->GetTrophyTimestamp(trophyId);
}
break;
Expand Down
56 changes: 53 additions & 3 deletions rpcs3/Emu/Cell/lv2/sys_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,50 @@ void fmt_class_string<sys_net_error>::format(std::string& out, u64 arg)
});
}

#ifdef _WIN32
// Workaround function for WSAPoll not reporting failed connections
void WSAPollEx(LPWSAPOLLFD fdArray, ULONG fds, INT timeout)
{
bool connecting[lv2_socket::id_count]{};
for (ULONG i = 0; i < fds; i++)
{
if (auto sock = idm::check_unlocked<lv2_socket>(fdArray[i].fd))
{
connecting[i] = sock->is_connecting;
}
}

const auto finished_connecting = [](SOCKET fd)
{
if (auto sock = idm::check_unlocked<lv2_socket>(fd))
sock->is_connecting = false;
};

int r = ::WSAPoll(fdArray, fds, timeout);
for (ULONG i = 0; i < fds; i++)
{
if (connecting[i])
{
if (!fdArray[i].revents)
{
int error = 0;
socklen_t intlen = sizeof(error);
if (getsockopt(fdArray[i].fd, SOL_SOCKET, SO_ERROR, (char*)&error, &intlen) == -1 || error != 0)
{
// Connection silently failed
finished_connecting(fdArray[i].fd);
fdArray[i].revents = POLLERR | POLLHUP | (fdArray[i].events & (POLLIN | POLLOUT));
}
}
else
{
finished_connecting(fdArray[i].fd);
}
}
}
}
#endif

// Error helper functions
static sys_net_error get_last_error(bool is_blocking, int native_error = 0)
{
Expand Down Expand Up @@ -191,7 +235,10 @@ struct network_thread
{
// Wait with 1ms timeout
#ifdef _WIN32
::WSAPoll(fds, socklist.size(), 1);
{
reader_lock lock(id_manager::g_mutex);
WSAPollEx(fds, socklist.size(), 1);
}
#else
::poll(fds, socklist.size(), 1);
#endif
Expand Down Expand Up @@ -522,6 +569,9 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
{
if (result == SYS_NET_EWOULDBLOCK)
{
#ifdef _WIN32
sock.is_connecting = true;
#endif
result = SYS_NET_EINPROGRESS;
}

Expand Down Expand Up @@ -1606,7 +1656,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
}

#ifdef _WIN32
::WSAPoll(_fds, nfds, 0);
WSAPollEx(_fds, nfds, 0);
#else
::poll(_fds, nfds, 0);
#endif
Expand Down Expand Up @@ -1774,7 +1824,7 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
}

#ifdef _WIN32
::WSAPoll(_fds, nfds, 0);
WSAPollEx(_fds, nfds, 0);
#else
::poll(_fds, nfds, 0);
#endif
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ struct lv2_socket final
#ifdef _WIN32
// Remember events (WSAEnumNetworkEvents)
u32 ev_set = 0;
// Tracks connect for WSAPoll workaround
bool is_connecting = false;
#endif

// Native socket (must be non-blocking)
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/Emu/RSX/VK/VKGSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2362,11 +2362,12 @@ void VKGSRender::queue_swap_request()
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT);
}

// Signal pending state as the command queue is now closed
m_current_frame->swap_command_buffer->pending = true;

// Set up a present request for this frame as well
present(m_current_frame);

m_current_frame->swap_command_buffer->pending = true;

// Grab next cb in line and make it usable
m_current_cb_index = (m_current_cb_index + 1) % VK_MAX_ASYNC_CB_COUNT;
m_current_command_buffer = &m_primary_cb_list[m_current_cb_index];
Expand Down
7 changes: 6 additions & 1 deletion rpcs3/Emu/RSX/VK/VKGSRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ struct command_buffer_chunk: public vk::command_buffer
return ret;
}

void flush() const
void flush()
{
reader_lock lock(guard_mutex);

if (!pending)
return;

submit_fence->wait_flush();
}
};
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/Loader/TROPUSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con
{
if (n->GetName() == "trophy")
{
u32 trophy_id = std::atoi(n->GetAttribute("id").c_str());
const u32 trophy_id = std::atoi(n->GetAttribute("id").c_str());

u32 trophy_grade;
switch (n->GetAttribute("ttype")[0])
{
Expand Down Expand Up @@ -219,7 +220,7 @@ u32 TROPUSRLoader::GetTrophyUnlockState(u32 id)
{
if (id >= m_table6.size())
{
LOG_WARNING(LOADER, "TROPUSRLoader::GetUnlockState: Invalid id=%d", id);
LOG_WARNING(LOADER, "TROPUSRLoader::GetTrophyUnlockState: Invalid id=%d", id);
return 0;
}

Expand Down
16 changes: 11 additions & 5 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ bool game_list_frame::IsEntryVisible(const game_info& game)
return category::CategoryInMap(game->info.category, category::cat_boot);
};

bool is_visible = m_show_hidden || !m_hidden_list.contains(qstr(game->info.serial));
return is_visible && matches_category() && SearchMatchesApp(game->info.name, game->info.serial);
const QString serial = qstr(game->info.serial);
bool is_visible = m_show_hidden || !m_hidden_list.contains(serial);
return is_visible && matches_category() && SearchMatchesApp(qstr(game->info.name), serial);
}

void game_list_frame::SortGameList()
Expand Down Expand Up @@ -2057,12 +2058,17 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con
/**
* Returns false if the game should be hidden because it doesn't match search term in toolbar.
*/
bool game_list_frame::SearchMatchesApp(const std::string& name, const std::string& serial)
bool game_list_frame::SearchMatchesApp(const QString& name, const QString& serial) const
{
if (!m_search_text.isEmpty())
{
QString searchText = m_search_text.toLower();
return qstr(name).toLower().contains(searchText) || qstr(serial).toLower().contains(searchText);
const QString searchText = m_search_text.toLower();
QString gameName = m_titles[serial];
if (gameName.isEmpty())
{
gameName = name;
}
return gameName.toLower().contains(searchText) || serial.toLower().contains(searchText);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/game_list_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private Q_SLOTS:
void SortGameList();

int PopulateGameList();
bool SearchMatchesApp(const std::string& name, const std::string& serial);
bool SearchMatchesApp(const QString& name, const QString& serial) const;

bool RemoveCustomConfiguration(const std::string& title_id, game_info game = nullptr, bool is_interactive = false);
bool RemoveCustomPadConfiguration(const std::string& title_id, game_info game = nullptr, bool is_interactive = false);
Expand Down
Loading

0 comments on commit 5dc3b41

Please sign in to comment.