Added additional packet for showing cards when allInCondition is true.
This commit is contained in:
+24
-2
@@ -266,13 +266,35 @@ Server Notification: Deal River Card
|
|||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
Server Notification: End Of Hand Show Cards
|
Server Notification: All In Show Cards
|
||||||
|
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Message Type = 14 | Message Length |
|
| Message Type = 14 | Message Length |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Number Of PlayerCards Records | Reserved |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| \
|
||||||
|
\ PlayerCards Records /
|
||||||
|
/ |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
PlayerCards Record
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Player Id | 1st Card |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| 2nd Card | Reserved |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
|
Server Notification: End Of Hand Show Cards
|
||||||
|
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Message Type = 15 | Message Length |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|Number Of PlayerResult Records | Reserved |
|
|Number Of PlayerResult Records | Reserved |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| \
|
| \
|
||||||
@@ -303,7 +325,7 @@ Server Notification: End Of Hand Hide Cards
|
|||||||
0 1 2 3
|
0 1 2 3
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Message Type = 15 | Message Length = 16 |
|
| Message Type = 16 | Message Length = 16 |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Player Id | Reserved |
|
| Player Id | Reserved |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ using namespace std;
|
|||||||
#define NET_TYPE_DEAL_FLOP_CARDS 0x000B
|
#define NET_TYPE_DEAL_FLOP_CARDS 0x000B
|
||||||
#define NET_TYPE_DEAL_TURN_CARD 0x000C
|
#define NET_TYPE_DEAL_TURN_CARD 0x000C
|
||||||
#define NET_TYPE_DEAL_RIVER_CARD 0x000D
|
#define NET_TYPE_DEAL_RIVER_CARD 0x000D
|
||||||
#define NET_TYPE_END_OF_HAND_SHOW_CARDS 0x000E
|
#define NET_TYPE_ALL_IN_SHOW_CARDS 0x000E
|
||||||
#define NET_TYPE_END_OF_HAND_HIDE_CARDS 0x000F
|
#define NET_TYPE_END_OF_HAND_SHOW_CARDS 0x000F
|
||||||
|
#define NET_TYPE_END_OF_HAND_HIDE_CARDS 0x0010
|
||||||
|
|
||||||
#define NET_TYPE_SEND_CHAT_TEXT 0x0200
|
#define NET_TYPE_SEND_CHAT_TEXT 0x0200
|
||||||
#define NET_TYPE_CHAT_TEXT 0x0201
|
#define NET_TYPE_CHAT_TEXT 0x0201
|
||||||
@@ -196,6 +197,21 @@ struct GCC_PACKED NetPacketDealRiverCardData
|
|||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED NetPacketAllInShowCardsData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int16_t numberOfPlayerCards;
|
||||||
|
u_int16_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED PlayerCardsData
|
||||||
|
{
|
||||||
|
u_int16_t playerId;
|
||||||
|
u_int16_t card1;
|
||||||
|
u_int16_t card2;
|
||||||
|
u_int16_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
struct GCC_PACKED NetPacketEndOfHandShowCardsData
|
struct GCC_PACKED NetPacketEndOfHandShowCardsData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
@@ -314,6 +330,9 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
case NET_TYPE_DEAL_RIVER_CARD:
|
case NET_TYPE_DEAL_RIVER_CARD:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketDealRiverCard);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketDealRiverCard);
|
||||||
break;
|
break;
|
||||||
|
case NET_TYPE_ALL_IN_SHOW_CARDS:
|
||||||
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketAllInShowCards);
|
||||||
|
break;
|
||||||
case NET_TYPE_END_OF_HAND_SHOW_CARDS:
|
case NET_TYPE_END_OF_HAND_SHOW_CARDS:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketEndOfHandShowCards);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketEndOfHandShowCards);
|
||||||
break;
|
break;
|
||||||
@@ -488,6 +507,12 @@ NetPacket::ToNetPacketDealRiverCard() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetPacketAllInShowCards *
|
||||||
|
NetPacket::ToNetPacketAllInShowCards() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const NetPacketEndOfHandShowCards *
|
const NetPacketEndOfHandShowCards *
|
||||||
NetPacket::ToNetPacketEndOfHandShowCards() const
|
NetPacket::ToNetPacketEndOfHandShowCards() const
|
||||||
{
|
{
|
||||||
@@ -1544,6 +1569,118 @@ NetPacketDealRiverCard::Check(const NetPacketHeader* data) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NetPacketAllInShowCards::NetPacketAllInShowCards()
|
||||||
|
: NetPacket(NET_TYPE_ALL_IN_SHOW_CARDS, sizeof(NetPacketAllInShowCardsData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketAllInShowCards::~NetPacketAllInShowCards()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<NetPacket>
|
||||||
|
NetPacketAllInShowCards::Clone() const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> newPacket(new NetPacketAllInShowCards);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket->SetRawData(GetRawData());
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
// Need to return the new packet anyway.
|
||||||
|
}
|
||||||
|
return newPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketAllInShowCards::SetData(const NetPacketAllInShowCards::Data &inData)
|
||||||
|
{
|
||||||
|
u_int16_t numPlayerCards = (u_int16_t)inData.playerCards.size();
|
||||||
|
|
||||||
|
if (!numPlayerCards || numPlayerCards > MAX_NUM_PLAYER_CARDS)
|
||||||
|
throw NetException(ERR_NET_INVALID_PLAYER_CARDS, 0);
|
||||||
|
|
||||||
|
// Resize the packet so that the data fits in.
|
||||||
|
Resize((u_int16_t)
|
||||||
|
(sizeof(NetPacketAllInShowCardsData) + numPlayerCards * sizeof(PlayerCardsData)));
|
||||||
|
|
||||||
|
NetPacketAllInShowCardsData *tmpData = (NetPacketAllInShowCardsData *)GetRawData();
|
||||||
|
assert(tmpData);
|
||||||
|
|
||||||
|
tmpData->numberOfPlayerCards = htons(numPlayerCards);
|
||||||
|
|
||||||
|
PlayerCardsList::const_iterator i = inData.playerCards.begin();
|
||||||
|
PlayerCardsList::const_iterator end = inData.playerCards.end();
|
||||||
|
|
||||||
|
// Copy the player cards data to continous memory
|
||||||
|
PlayerCardsData *curPlayerCardsData =
|
||||||
|
(PlayerCardsData *)((char *)tmpData + sizeof(NetPacketAllInShowCardsData));
|
||||||
|
while (i != end)
|
||||||
|
{
|
||||||
|
curPlayerCardsData->playerId = htons((*i).playerId);
|
||||||
|
curPlayerCardsData->card1 = htons((*i).cards[0]);
|
||||||
|
curPlayerCardsData->card2 = htons((*i).cards[1]);
|
||||||
|
++curPlayerCardsData;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketAllInShowCards::GetData(NetPacketAllInShowCards::Data &outData) const
|
||||||
|
{
|
||||||
|
NetPacketAllInShowCardsData *tmpData = (NetPacketAllInShowCardsData *)GetRawData();
|
||||||
|
assert(tmpData);
|
||||||
|
|
||||||
|
outData.playerCards.clear();
|
||||||
|
|
||||||
|
u_int16_t numPlayerCards = ntohs(tmpData->numberOfPlayerCards);
|
||||||
|
PlayerCardsData *curPlayerCardsData =
|
||||||
|
(PlayerCardsData *)((char *)tmpData + sizeof(NetPacketAllInShowCardsData));
|
||||||
|
|
||||||
|
// Store all available player cards.
|
||||||
|
for (int i = 0; i < numPlayerCards; i++)
|
||||||
|
{
|
||||||
|
PlayerCards tmpPlayerCards;
|
||||||
|
tmpPlayerCards.playerId = ntohs(curPlayerCardsData->playerId);
|
||||||
|
tmpPlayerCards.cards[0] = ntohs(curPlayerCardsData->card1);
|
||||||
|
tmpPlayerCards.cards[1] = ntohs(curPlayerCardsData->card2);
|
||||||
|
|
||||||
|
outData.playerCards.push_back(tmpPlayerCards);
|
||||||
|
++curPlayerCardsData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketAllInShowCards *
|
||||||
|
NetPacketAllInShowCards::ToNetPacketAllInShowCards() const
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketAllInShowCards::Check(const NetPacketHeader* data) const
|
||||||
|
{
|
||||||
|
assert(data);
|
||||||
|
|
||||||
|
u_int16_t dataLen = ntohs(data->length);
|
||||||
|
if (dataLen < sizeof(NetPacketAllInShowCardsData))
|
||||||
|
{
|
||||||
|
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketAllInShowCardsData *tmpData = (NetPacketAllInShowCardsData *)data;
|
||||||
|
int numPlayerCards = ntohs(tmpData->numberOfPlayerCards);
|
||||||
|
|
||||||
|
if (dataLen !=
|
||||||
|
sizeof(NetPacketAllInShowCardsData)
|
||||||
|
+ numPlayerCards * sizeof(PlayerCardsData))
|
||||||
|
{
|
||||||
|
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
||||||
|
}
|
||||||
|
// TODO: semantic checks within PlayerCardsData
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NetPacketEndOfHandShowCards::NetPacketEndOfHandShowCards()
|
NetPacketEndOfHandShowCards::NetPacketEndOfHandShowCards()
|
||||||
: NetPacket(NET_TYPE_END_OF_HAND_SHOW_CARDS, sizeof(NetPacketEndOfHandShowCardsData))
|
: NetPacket(NET_TYPE_END_OF_HAND_SHOW_CARDS, sizeof(NetPacketEndOfHandShowCardsData))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#define MAX_PASSWORD_SIZE 64
|
#define MAX_PASSWORD_SIZE 64
|
||||||
#define MAX_CHAT_TEXT_SIZE 128
|
#define MAX_CHAT_TEXT_SIZE 128
|
||||||
#define MAX_NUM_PLAYER_RESULTS MAX_NUMBER_OF_PLAYERS
|
#define MAX_NUM_PLAYER_RESULTS MAX_NUMBER_OF_PLAYERS
|
||||||
|
#define MAX_NUM_PLAYER_CARDS MAX_NUMBER_OF_PLAYERS
|
||||||
|
|
||||||
|
|
||||||
struct NetPacketHeader;
|
struct NetPacketHeader;
|
||||||
@@ -52,6 +53,7 @@ class NetPacketPlayersActionRejected;
|
|||||||
class NetPacketDealFlopCards;
|
class NetPacketDealFlopCards;
|
||||||
class NetPacketDealTurnCard;
|
class NetPacketDealTurnCard;
|
||||||
class NetPacketDealRiverCard;
|
class NetPacketDealRiverCard;
|
||||||
|
class NetPacketAllInShowCards;
|
||||||
class NetPacketEndOfHandShowCards;
|
class NetPacketEndOfHandShowCards;
|
||||||
class NetPacketEndOfHandHideCards;
|
class NetPacketEndOfHandHideCards;
|
||||||
class NetPacketSendChatText;
|
class NetPacketSendChatText;
|
||||||
@@ -88,6 +90,7 @@ public:
|
|||||||
virtual const NetPacketDealFlopCards *ToNetPacketDealFlopCards() const;
|
virtual const NetPacketDealFlopCards *ToNetPacketDealFlopCards() const;
|
||||||
virtual const NetPacketDealTurnCard *ToNetPacketDealTurnCard() const;
|
virtual const NetPacketDealTurnCard *ToNetPacketDealTurnCard() const;
|
||||||
virtual const NetPacketDealRiverCard *ToNetPacketDealRiverCard() const;
|
virtual const NetPacketDealRiverCard *ToNetPacketDealRiverCard() const;
|
||||||
|
virtual const NetPacketAllInShowCards *ToNetPacketAllInShowCards() const;
|
||||||
virtual const NetPacketEndOfHandShowCards *ToNetPacketEndOfHandShowCards() const;
|
virtual const NetPacketEndOfHandShowCards *ToNetPacketEndOfHandShowCards() const;
|
||||||
virtual const NetPacketEndOfHandHideCards *ToNetPacketEndOfHandHideCards() const;
|
virtual const NetPacketEndOfHandHideCards *ToNetPacketEndOfHandHideCards() const;
|
||||||
virtual const NetPacketSendChatText *ToNetPacketSendChatText() const;
|
virtual const NetPacketSendChatText *ToNetPacketSendChatText() const;
|
||||||
@@ -428,6 +431,37 @@ protected:
|
|||||||
virtual void Check(const NetPacketHeader* data) const;
|
virtual void Check(const NetPacketHeader* data) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NetPacketAllInShowCards : public NetPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct PlayerCards
|
||||||
|
{
|
||||||
|
u_int16_t playerId;
|
||||||
|
u_int16_t cards[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::list<PlayerCards> PlayerCardsList;
|
||||||
|
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
PlayerCardsList playerCards;
|
||||||
|
};
|
||||||
|
|
||||||
|
NetPacketAllInShowCards();
|
||||||
|
virtual ~NetPacketAllInShowCards();
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||||
|
|
||||||
|
void SetData(const Data &inData);
|
||||||
|
void GetData(Data &outData) const;
|
||||||
|
|
||||||
|
virtual const NetPacketAllInShowCards *ToNetPacketAllInShowCards() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void Check(const NetPacketHeader* data) const;
|
||||||
|
};
|
||||||
|
|
||||||
class NetPacketEndOfHandShowCards : public NetPacket
|
class NetPacketEndOfHandShowCards : public NetPacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -48,9 +48,10 @@
|
|||||||
#define ERR_NET_INVALID_PASSWORD_STR 105
|
#define ERR_NET_INVALID_PASSWORD_STR 105
|
||||||
#define ERR_NET_PLAYER_NAME_IN_USE 106
|
#define ERR_NET_PLAYER_NAME_IN_USE 106
|
||||||
#define ERR_NET_INVALID_PLAYER_NAME 107
|
#define ERR_NET_INVALID_PLAYER_NAME 107
|
||||||
#define ERR_NET_INVALID_PLAYER_RESULTS 108
|
#define ERR_NET_INVALID_PLAYER_CARDS 108
|
||||||
#define ERR_NET_INVALID_CHAT_TEXT 109
|
#define ERR_NET_INVALID_PLAYER_RESULTS 109
|
||||||
#define ERR_NET_UNKNOWN_PLAYER_ID 110
|
#define ERR_NET_INVALID_CHAT_TEXT 110
|
||||||
|
#define ERR_NET_UNKNOWN_PLAYER_ID 111
|
||||||
|
|
||||||
// This is an internal message which is not reported.
|
// This is an internal message which is not reported.
|
||||||
#define MSG_SOCK_INTERNAL_PENDING 0
|
#define MSG_SOCK_INTERNAL_PENDING 0
|
||||||
|
|||||||
Reference in New Issue
Block a user