Synchronize on network game start, so that everyone has received all avatars and player names before the game starts. Store all computer players in a separate list on the server for name retrieval.

This commit is contained in:
lotodore
2007-10-07 21:23:37 +00:00
parent d16312111f
commit 0d0d8dc810
18 changed files with 452 additions and 64 deletions
+21
View File
@@ -176,6 +176,20 @@ ServerLobbyThread::HandleGameRetrieveAvatar(SessionWrapper session, const NetPac
HandleNetPacketRetrieveAvatar(session, tmpPacket);
}
void
ServerLobbyThread::AddComputerPlayer(boost::shared_ptr<PlayerData> player)
{
boost::mutex::scoped_lock lock(m_computerPlayersMutex);
m_computerPlayers.insert(PlayerDataMap::value_type(player->GetUniqueId(), player));
}
void
ServerLobbyThread::RemoveComputerPlayer(boost::shared_ptr<PlayerData> player)
{
boost::mutex::scoped_lock lock(m_computerPlayersMutex);
m_computerPlayers.erase(player->GetUniqueId());
}
void
ServerLobbyThread::RemoveGame(unsigned id)
{
@@ -446,6 +460,13 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con
boost::shared_ptr<PlayerData> tmpPlayer = m_sessionManager.GetSessionByUniquePlayerId(request.playerId).playerData;
if (!tmpPlayer.get())
tmpPlayer = m_gameSessionManager.GetSessionByUniquePlayerId(request.playerId).playerData;
if (!tmpPlayer.get())
{
boost::mutex::scoped_lock lock(m_computerPlayersMutex);
PlayerDataMap::const_iterator pos = m_computerPlayers.find(request.playerId);
if (pos != m_computerPlayers.end())
tmpPlayer = pos->second;
}
if (tmpPlayer.get())
{