Add spectator list during the game (when lobby messages are disabled).

This commit is contained in:
lotodore
2013-09-29 13:15:37 +02:00
parent 8baecdf9e0
commit d82c9a510d
5 changed files with 63 additions and 8 deletions
+42
View File
@@ -1454,6 +1454,48 @@ ClientThread::ModifyGameInfoRemoveSpectator(unsigned gameId, unsigned playerId)
GetCallback().SignalNetClientGameListSpectatorLeft(gameId, playerId);
}
void
ClientThread::ModifyGameInfoClearSpectatorsDuringGame()
{
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
GameInfoMap::iterator pos = m_gameInfoMap.find(GetGameId());
if (pos != m_gameInfoMap.end()) {
pos->second.spectatorsDuringGame.clear();
}
}
void
ClientThread::ModifyGameInfoAddSpectatorDuringGame(unsigned playerId)
{
bool spectatorAdded = false;
{
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
GameInfoMap::iterator pos = m_gameInfoMap.find(GetGameId());
if (pos != m_gameInfoMap.end()) {
pos->second.spectatorsDuringGame.push_back(playerId);
spectatorAdded = true;
}
}
if (spectatorAdded)
GetCallback().SignalNetClientSpectatorJoined(playerId, GetPlayerName(playerId));
}
void
ClientThread::ModifyGameInfoRemoveSpectatorDuringGame(unsigned playerId, int removeReason)
{
bool spectatorRemoved = false;
{
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
GameInfoMap::iterator pos = m_gameInfoMap.find(GetGameId());
if (pos != m_gameInfoMap.end()) {
pos->second.spectatorsDuringGame.remove(playerId);
spectatorRemoved = true;
}
}
if (spectatorRemoved)
GetCallback().SignalNetClientSpectatorLeft(playerId, GetPlayerName(playerId), removeReason);
}
void
ClientThread::ClearGameInfoMap()
{