diff --git a/src/net/clientthread.h b/src/net/clientthread.h index 2d1b3a4d..5a0be2d6 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -91,6 +91,7 @@ public: bool GetPlayerIdFromName(const std::string &playerName, unsigned &playerId) const; ServerStats GetStatData() const; unsigned GetGameId() const; + unsigned GetGuiPlayerId() const; Gsasl *GetAuthContext(); @@ -158,7 +159,6 @@ protected: void SetGameData(const GameData &gameData); const StartData &GetStartData() const; void SetStartData(const StartData &startData); - unsigned GetGuiPlayerId() const; void SetGuiPlayerId(unsigned guiPlayerId); boost::shared_ptr GetGame(); @@ -259,6 +259,7 @@ private: unsigned m_curGameNum; unsigned m_guiPlayerId; + mutable boost::mutex m_guiPlayerIdMutex; bool m_sessionEstablished; mutable boost::mutex m_curStatsMutex; diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 2e2c2b7d..f12d6101 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -963,12 +963,14 @@ ClientThread::SetStartData(const StartData &startData) unsigned ClientThread::GetGuiPlayerId() const { + boost::mutex::scoped_lock lock(m_guiPlayerIdMutex); return m_guiPlayerId; } void ClientThread::SetGuiPlayerId(unsigned guiPlayerId) { + boost::mutex::scoped_lock lock(m_guiPlayerIdMutex); m_guiPlayerId = guiPlayerId; } diff --git a/src/session.cpp b/src/session.cpp index 2cf778f4..1af1eb82 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -490,6 +490,14 @@ unsigned Session::getClientCurrentGameId() const return id; } +unsigned Session::getClientUniquePlayerId() const +{ + unsigned id = 0; + if (myNetClient) + id = myNetClient->GetGuiPlayerId(); + return id; +} + bool Session::getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName) { bool retVal = false; diff --git a/src/session.h b/src/session.h index 30d654dc..4f6ee5dd 100755 --- a/src/session.h +++ b/src/session.h @@ -96,6 +96,7 @@ public: PlayerInfo getClientPlayerInfo(unsigned playerId) const; ServerStats getClientStats() const; unsigned getClientCurrentGameId() const; + unsigned getClientUniquePlayerId() const; bool getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName);