Adding function to find out in which game a user is playing.
This commit is contained in:
@@ -91,6 +91,7 @@ public:
|
|||||||
GameInfo GetGameInfo(unsigned gameId) const;
|
GameInfo GetGameInfo(unsigned gameId) const;
|
||||||
PlayerInfo GetPlayerInfo(unsigned playerId) const;
|
PlayerInfo GetPlayerInfo(unsigned playerId) const;
|
||||||
bool GetPlayerIdFromName(const std::string &playerName, unsigned &playerId) const;
|
bool GetPlayerIdFromName(const std::string &playerName, unsigned &playerId) const;
|
||||||
|
unsigned GetGameIdOfPlayer(unsigned playerId) const;
|
||||||
ServerStats GetStatData() const;
|
ServerStats GetStatData() const;
|
||||||
unsigned GetGameId() const;
|
unsigned GetGameId() const;
|
||||||
unsigned GetGuiPlayerId() const;
|
unsigned GetGuiPlayerId() const;
|
||||||
|
|||||||
@@ -449,6 +449,35 @@ ClientThread::GetPlayerIdFromName(const string &playerName, unsigned &playerId)
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
ClientThread::GetGameIdOfPlayer(unsigned playerId) const
|
||||||
|
{
|
||||||
|
unsigned gameId = 0; // Default: no game (invalid id).
|
||||||
|
|
||||||
|
// Iterate through all games to find the player.
|
||||||
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
|
GameInfoMap::const_iterator i = m_gameInfoMap.begin();
|
||||||
|
GameInfoMap::const_iterator i_end = m_gameInfoMap.end();
|
||||||
|
while (i != i_end)
|
||||||
|
{
|
||||||
|
PlayerIdList::const_iterator j = (*i).second.players.begin();
|
||||||
|
PlayerIdList::const_iterator j_end = (*i).second.players.end();
|
||||||
|
while (j != j_end)
|
||||||
|
{
|
||||||
|
if (playerId == *j)
|
||||||
|
{
|
||||||
|
gameId = (*i).first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
if (gameId)
|
||||||
|
break;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return gameId;
|
||||||
|
}
|
||||||
|
|
||||||
ClientCallback &
|
ClientCallback &
|
||||||
ClientThread::GetCallback()
|
ClientThread::GetCallback()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -495,6 +495,14 @@ PlayerInfo Session::getClientPlayerInfo(unsigned playerId) const
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Session::getGameIdOfPlayer(unsigned playerId) const
|
||||||
|
{
|
||||||
|
unsigned gameId = 0;
|
||||||
|
if (myNetClient)
|
||||||
|
gameId = myNetClient->GetGameIdOfPlayer(playerId);
|
||||||
|
return gameId;
|
||||||
|
}
|
||||||
|
|
||||||
ServerStats Session::getClientStats() const
|
ServerStats Session::getClientStats() const
|
||||||
{
|
{
|
||||||
ServerStats stats;
|
ServerStats stats;
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public:
|
|||||||
ServerInfo getClientServerInfo(unsigned serverId) const;
|
ServerInfo getClientServerInfo(unsigned serverId) const;
|
||||||
GameInfo getClientGameInfo(unsigned gameId) const;
|
GameInfo getClientGameInfo(unsigned gameId) const;
|
||||||
PlayerInfo getClientPlayerInfo(unsigned playerId) const;
|
PlayerInfo getClientPlayerInfo(unsigned playerId) const;
|
||||||
|
unsigned getGameIdOfPlayer(unsigned playerId) const;
|
||||||
ServerStats getClientStats() const;
|
ServerStats getClientStats() const;
|
||||||
unsigned getClientCurrentGameId() const;
|
unsigned getClientCurrentGameId() const;
|
||||||
unsigned getClientUniquePlayerId() const;
|
unsigned getClientUniquePlayerId() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user