diff --git a/docs/pokerth.asn1 b/docs/pokerth.asn1 index 857b96b5..b7f77391 100644 --- a/docs/pokerth.asn1 +++ b/docs/pokerth.asn1 @@ -812,7 +812,8 @@ NetPlayerAction ::= ENUMERATED { NetPlayerState ::= ENUMERATED { playerStateNormal (0), - playerStateSessionInactive (1) + playerStateSessionInactive (1), + playerStateNoMoney (2) } NonZeroId ::= INTEGER(1..4294967295) diff --git a/src/net/clientthread.h b/src/net/clientthread.h index 990ca75e..2a8373c2 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -183,8 +183,6 @@ protected: boost::shared_ptr GetPlayerDataByUniqueId(unsigned id); boost::shared_ptr GetPlayerDataByName(const std::string &name); - void RemoveDisconnectedPlayers(); - void AddServerInfo(unsigned serverId, const ServerInfo &info); void ClearServerInfoMap(); bool GetSelectedServer(unsigned &serverId) const; diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 83388d06..79baead0 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -1609,9 +1609,6 @@ void ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_handStartMessage) { - // Remove all players which left the server. - client->RemoveDisconnectedPlayers(); - // Hand was started. // These are the cards. Good luck. HandStartMessage_t *netHandStart = &tmpPacket->GetMsg()->choice.handStartMessage; @@ -1657,7 +1654,18 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client boost::shared_ptr tmpPlayer = client->GetGame()->getPlayerByNumber((i + client->GetOrigGuiPlayerNum()) % client->GetStartData().numberOfPlayers); if (!tmpPlayer) throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0); - tmpPlayer->setIsSessionActive(*seatState == NetPlayerState_playerStateNormal); + switch (*seatState) + { + case NetPlayerState_playerStateNormal : + tmpPlayer->setIsSessionActive(true); + break; + case NetPlayerState_playerStateSessionInactive : + tmpPlayer->setIsSessionActive(false); + break; + case NetPlayerState_playerStateNoMoney : + tmpPlayer->setMyCash(0); + break; + } } } diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 18c9abd0..4081eea0 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -1161,29 +1161,6 @@ ClientThread::GetPlayerDataByName(const std::string &name) return tmpPlayer; } -void -ClientThread::RemoveDisconnectedPlayers() -{ - // This should only be called between hands. - if (m_game) { - PlayerList tmpList(m_game->getSeatsList()); - PlayerListIterator i = tmpList->begin(); - PlayerListIterator end = tmpList->end(); - while (i != end) { - boost::shared_ptr tmpPlayer = *i; - if (tmpPlayer->getMyActiveStatus()) { - // If a player is not in the player data list, it was disconnected. - if (!GetPlayerDataByUniqueId(tmpPlayer->getMyUniqueID()).get()) { - if (tmpPlayer->isKicked()) { - tmpPlayer->setMyCash(0); - } - } - } - ++i; - } - } -} - void ClientThread::AddServerInfo(unsigned serverId, const ServerInfo &info) { diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 305c832c..a8cf104c 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -1199,7 +1199,13 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr server) PlayerListIterator player_end = curGame.getSeatsList()->end(); while (player_i != player_end) { NetPlayerState_t *seatState = (NetPlayerState_t *)calloc(1, sizeof(NetPlayerState_t)); - *seatState = (*player_i)->isSessionActive() ? NetPlayerState_playerStateNormal : NetPlayerState_playerStateSessionInactive; + if ((*player_i)->getMyCash() <= 0) { + *seatState = NetPlayerState_playerStateNoMoney; + } else if (!(*player_i)->isSessionActive()) { + *seatState = NetPlayerState_playerStateSessionInactive; + } else { + *seatState = NetPlayerState_playerStateNormal; + } ASN_SEQUENCE_ADD(&netHandStart->seatStates.list, seatState); ++player_i; } diff --git a/src/third_party/asn1/NetPlayerState.c b/src/third_party/asn1/NetPlayerState.c index 5d7a052f..713a6570 100644 --- a/src/third_party/asn1/NetPlayerState.c +++ b/src/third_party/asn1/NetPlayerState.c @@ -82,16 +82,18 @@ NetPlayerState_encode_xer(asn_TYPE_descriptor_t *td, void *structure, static asn_INTEGER_enum_map_t asn_MAP_NetPlayerState_value2enum_1[] = { { 0, 17, "playerStateNormal" }, - { 1, 26, "playerStateSessionInactive" } + { 1, 26, "playerStateSessionInactive" }, + { 2, 18, "playerStateNoMoney" } }; static unsigned int asn_MAP_NetPlayerState_enum2value_1[] = { + 2, /* playerStateNoMoney(2) */ 0, /* playerStateNormal(0) */ 1 /* playerStateSessionInactive(1) */ }; static asn_INTEGER_specifics_t asn_SPC_NetPlayerState_specs_1 = { asn_MAP_NetPlayerState_value2enum_1, /* "tag" => N; sorted by tag */ asn_MAP_NetPlayerState_enum2value_1, /* N => "tag"; sorted by N */ - 2, /* Number of elements in the maps */ + 3, /* Number of elements in the maps */ 0, /* Enumeration is not extensible */ 1, /* Strict enumeration */ 0, /* Native long size */ diff --git a/src/third_party/asn1/NetPlayerState.h b/src/third_party/asn1/NetPlayerState.h index 1a8974fe..6fb3e0a0 100644 --- a/src/third_party/asn1/NetPlayerState.h +++ b/src/third_party/asn1/NetPlayerState.h @@ -21,9 +21,10 @@ extern "C" { /* Dependencies */ typedef enum NetPlayerState { NetPlayerState_playerStateNormal = 0, - NetPlayerState_playerStateSessionInactive = 1 + NetPlayerState_playerStateSessionInactive = 1, + NetPlayerState_playerStateNoMoney = 2 } - e_NetPlayerState; + e_NetPlayerState; /* NetPlayerState */ typedef long NetPlayerState_t; diff --git a/tests/src/pokerth_protocol/NetPlayerState.java b/tests/src/pokerth_protocol/NetPlayerState.java index bd318533..387440e7 100644 --- a/tests/src/pokerth_protocol/NetPlayerState.java +++ b/tests/src/pokerth_protocol/NetPlayerState.java @@ -26,6 +26,8 @@ import org.bn.types.*; playerStateNormal , @ASN1EnumItem ( name = "playerStateSessionInactive", hasTag = true , tag = 1 ) playerStateSessionInactive , + @ASN1EnumItem ( name = "playerStateNoMoney", hasTag = true , tag = 2 ) + playerStateNoMoney , } private EnumType value;