mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-14 10:50:13 +01:00
Use different mutex for overlay to try to fix lag.
This commit is contained in:
parent
1dc5bcc5c1
commit
43a5b13302
2 changed files with 13 additions and 6 deletions
|
@ -123,7 +123,7 @@ void Steam_Overlay::SetNotificationInset(int nHorizontalInset, int nVerticalInse
|
||||||
|
|
||||||
void Steam_Overlay::SetupOverlay()
|
void Steam_Overlay::SetupOverlay()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
if (!setup_overlay_called)
|
if (!setup_overlay_called)
|
||||||
{
|
{
|
||||||
setup_overlay_called = true;
|
setup_overlay_called = true;
|
||||||
|
@ -238,7 +238,7 @@ void Steam_Overlay::SetLobbyInvite(Friend friendId, uint64 lobbyId)
|
||||||
if (!Ready())
|
if (!Ready())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
auto i = friends.find(friendId);
|
auto i = friends.find(friendId);
|
||||||
if (i != friends.end())
|
if (i != friends.end())
|
||||||
{
|
{
|
||||||
|
@ -257,7 +257,7 @@ void Steam_Overlay::SetRichInvite(Friend friendId, const char* connect_str)
|
||||||
if (!Ready())
|
if (!Ready())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
auto i = friends.find(friendId);
|
auto i = friends.find(friendId);
|
||||||
if (i != friends.end())
|
if (i != friends.end())
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ void Steam_Overlay::SetRichInvite(Friend friendId, const char* connect_str)
|
||||||
|
|
||||||
void Steam_Overlay::FriendConnect(Friend _friend)
|
void Steam_Overlay::FriendConnect(Friend _friend)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
int id = find_free_friend_id(friends);
|
int id = find_free_friend_id(friends);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -289,7 +289,7 @@ void Steam_Overlay::FriendConnect(Friend _friend)
|
||||||
|
|
||||||
void Steam_Overlay::FriendDisconnect(Friend _friend)
|
void Steam_Overlay::FriendDisconnect(Friend _friend)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
auto it = friends.find(_friend);
|
auto it = friends.find(_friend);
|
||||||
if (it != friends.end())
|
if (it != friends.end())
|
||||||
friends.erase(it);
|
friends.erase(it);
|
||||||
|
@ -297,6 +297,7 @@ void Steam_Overlay::FriendDisconnect(Friend _friend)
|
||||||
|
|
||||||
void Steam_Overlay::AddMessageNotification(std::string const& message)
|
void Steam_Overlay::AddMessageNotification(std::string const& message)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
int id = find_free_notification_id(notifications);
|
int id = find_free_notification_id(notifications);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -313,6 +314,7 @@ void Steam_Overlay::AddMessageNotification(std::string const& message)
|
||||||
|
|
||||||
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
int id = find_free_notification_id(notifications);
|
int id = find_free_notification_id(notifications);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -330,6 +332,7 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
||||||
|
|
||||||
void Steam_Overlay::AddInviteNotification(std::pair<const Friend, friend_window_state>& wnd_state)
|
void Steam_Overlay::AddInviteNotification(std::pair<const Friend, friend_window_state>& wnd_state)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
int id = find_free_notification_id(notifications);
|
int id = find_free_notification_id(notifications);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -596,7 +599,7 @@ void Steam_Overlay::CreateFonts()
|
||||||
// Try to make this function as short as possible or it might affect game's fps.
|
// Try to make this function as short as possible or it might affect game's fps.
|
||||||
void Steam_Overlay::OverlayProc()
|
void Steam_Overlay::OverlayProc()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
|
|
||||||
if (!Ready())
|
if (!Ready())
|
||||||
return;
|
return;
|
||||||
|
@ -666,6 +669,7 @@ void Steam_Overlay::OverlayProc()
|
||||||
|
|
||||||
void Steam_Overlay::Callback(Common_Message *msg)
|
void Steam_Overlay::Callback(Common_Message *msg)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
if (msg->has_steam_messages())
|
if (msg->has_steam_messages())
|
||||||
{
|
{
|
||||||
Friend frd;
|
Friend frd;
|
||||||
|
@ -689,6 +693,7 @@ void Steam_Overlay::Callback(Common_Message *msg)
|
||||||
|
|
||||||
void Steam_Overlay::RunCallbacks()
|
void Steam_Overlay::RunCallbacks()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
if (overlay_state_changed)
|
if (overlay_state_changed)
|
||||||
{
|
{
|
||||||
GameOverlayActivated_t data = { 0 };
|
GameOverlayActivated_t data = { 0 };
|
||||||
|
|
|
@ -92,6 +92,8 @@ class Steam_Overlay
|
||||||
std::vector<Notification> notifications;
|
std::vector<Notification> notifications;
|
||||||
bool overlay_state_changed;
|
bool overlay_state_changed;
|
||||||
|
|
||||||
|
std::recursive_mutex overlay_mutex;
|
||||||
|
|
||||||
Steam_Overlay(Steam_Overlay const&) = delete;
|
Steam_Overlay(Steam_Overlay const&) = delete;
|
||||||
Steam_Overlay(Steam_Overlay&&) = delete;
|
Steam_Overlay(Steam_Overlay&&) = delete;
|
||||||
Steam_Overlay& operator=(Steam_Overlay const&) = delete;
|
Steam_Overlay& operator=(Steam_Overlay const&) = delete;
|
||||||
|
|
Loading…
Reference in a new issue