Players should now be able to leave a network game, the other players can continue the game (if it wasn't the server who left).

This commit is contained in:
lotodore
2007-06-03 14:57:33 +00:00
parent 1fcb0c80fd
commit f932e39983
4 changed files with 125 additions and 56 deletions
+13 -1
View File
@@ -346,7 +346,17 @@ ServerRecvThread::CloseSessionDelayed(SessionWrapper session)
boost::shared_ptr<PlayerData> tmpPlayerData = session.playerData;
if (tmpPlayerData.get() && !tmpPlayerData->GetName().empty())
{
GetCallback().SignalNetServerPlayerLeft(tmpPlayerData->GetName());
// Set player inactive.
if (m_game.get())
{
PlayerInterface *player = GetGame().getPlayerByUniqueId(tmpPlayerData->GetUniqueId());
if (player)
{
player->setMyAction(PLAYER_ACTION_FOLD);
player->setMyCash(0);
player->setMyActiveStatus(false);
}
}
// Send "Player Left" to clients.
boost::shared_ptr<NetPacket> thisPlayerLeft(new NetPacketPlayerLeft);
@@ -354,6 +364,8 @@ ServerRecvThread::CloseSessionDelayed(SessionWrapper session)
thisPlayerLeftData.playerId = tmpPlayerData->GetUniqueId();
static_cast<NetPacketPlayerLeft *>(thisPlayerLeft.get())->SetData(thisPlayerLeftData);
SendToAllPlayers(thisPlayerLeft);
GetCallback().SignalNetServerPlayerLeft(tmpPlayerData->GetName());
}
boost::microsec_timer closeTimer;