Inform players when another player is no longer allowed to rejoin.

This commit is contained in:
lotodore
2011-12-22 20:10:18 +00:00
parent bc37ac69fd
commit f8c1cdf56e
8 changed files with 30 additions and 35 deletions
+2 -1
View File
@@ -812,7 +812,8 @@ NetPlayerAction ::= ENUMERATED {
NetPlayerState ::= ENUMERATED {
playerStateNormal (0),
playerStateSessionInactive (1)
playerStateSessionInactive (1),
playerStateNoMoney (2)
}
NonZeroId ::= INTEGER(1..4294967295)
-2
View File
@@ -183,8 +183,6 @@ protected:
boost::shared_ptr<PlayerData> GetPlayerDataByUniqueId(unsigned id);
boost::shared_ptr<PlayerData> GetPlayerDataByName(const std::string &name);
void RemoveDisconnectedPlayers();
void AddServerInfo(unsigned serverId, const ServerInfo &info);
void ClearServerInfoMap();
bool GetSelectedServer(unsigned &serverId) const;
+12 -4
View File
@@ -1609,9 +1609,6 @@ void
ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> 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<ClientThread> client
boost::shared_ptr<PlayerInterface> 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;
}
}
}
-23
View File
@@ -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<PlayerInterface> 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)
{
+7 -1
View File
@@ -1199,7 +1199,13 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr<ServerGame> 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;
}
+4 -2
View File
@@ -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 */
+3 -2
View File
@@ -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;
@@ -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;