Rewrote the code which handles leaving of players during the network game. Some bug is still remaining.

This commit is contained in:
lotodore
2007-06-15 10:38:41 +00:00
parent a7598a20eb
commit e19f6c7471
8 changed files with 110 additions and 50 deletions
+3 -19
View File
@@ -403,26 +403,8 @@ AbstractClientStateReceiving::Process(ClientThread &client)
NetPacketPlayerLeft::Data playerLeftData;
tmpPacket->ToNetPacketPlayerLeft()->GetData(playerLeftData);
// Signal to GUI.
// Signal to GUI and remove from data list.
client.RemovePlayerData(playerLeftData.playerId);
// If the game is running, deactivate player.
boost::shared_ptr<Game> curGame = client.GetGame();
if (curGame.get())
{
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(playerLeftData.playerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
// Reset his action and his cash.
tmpPlayer->setMyAction(PLAYER_ACTION_FOLD);
tmpPlayer->setMyCash(0);
// Player is now inactive.
tmpPlayer->setMyActiveStatus(false);
client.GetGui().refreshAction();
client.GetGui().refreshCash();
}
}
else
retVal = InternalProcess(client, tmpPacket);
@@ -551,6 +533,8 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
if (packet->ToNetPacketHandStart())
{
// Remove all players which left the server.
client.RemoveDisconnectedPlayers();
// Hand was started.
// These are the cards. Good luck.
NetPacketHandStart::Data tmpData;