Fixing some ASN.1 related bugs. Playing a game works now, but there is still an issue when the lobby is started after the game.
This commit is contained in:
@@ -30,27 +30,27 @@ void internal_log_err(const std::string &msg);
|
|||||||
void internal_log_msg(const std::string &msg);
|
void internal_log_msg(const std::string &msg);
|
||||||
void internal_log_level(const std::string &msg, int logLevel);
|
void internal_log_level(const std::string &msg, int logLevel);
|
||||||
|
|
||||||
#define LOG_ERROR(e) \
|
#define LOG_ERROR(_e) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream outStream; \
|
std::ostringstream outStream; \
|
||||||
outStream << e << std::endl; \
|
outStream << _e << std::endl; \
|
||||||
internal_log_err(outStream.str()); \
|
internal_log_err(outStream.str()); \
|
||||||
} \
|
} \
|
||||||
while(false)
|
while(false)
|
||||||
#define LOG_MSG(e) \
|
#define LOG_MSG(_e) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream outStream; \
|
std::ostringstream outStream; \
|
||||||
outStream << e << std::endl; \
|
outStream << _e << std::endl; \
|
||||||
internal_log_msg(outStream.str()); \
|
internal_log_msg(outStream.str()); \
|
||||||
} \
|
} \
|
||||||
while(false)
|
while(false)
|
||||||
#define LOG_VERBOSE(e) \
|
#define LOG_VERBOSE(_e) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream outStream; \
|
std::ostringstream outStream; \
|
||||||
outStream << e << std::endl; \
|
outStream << _e << std::endl; \
|
||||||
internal_log_level(outStream.str(), 2); \
|
internal_log_level(outStream.str(), 2); \
|
||||||
} \
|
} \
|
||||||
while(false)
|
while(false)
|
||||||
|
|||||||
@@ -830,7 +830,6 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
client->RequestPlayerInfo(playerId);
|
client->RequestPlayerInfo(playerId);
|
||||||
}
|
}
|
||||||
tmpInfo.players.push_back(playerId);
|
tmpInfo.players.push_back(playerId);
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
tmpInfo.adminPlayerId = netListNew->adminPlayerId;
|
tmpInfo.adminPlayerId = netListNew->adminPlayerId;
|
||||||
tmpInfo.isPasswordProtected = netListNew->isPrivate ? true : false;
|
tmpInfo.isPasswordProtected = netListNew->isPrivate ? true : false;
|
||||||
@@ -941,8 +940,8 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
// Show the error.
|
// Show the error.
|
||||||
throw ClientException(__FILE__, __LINE__, NetPacket::NetErrorToGameError(netError->errorReason), 0);
|
throw ClientException(__FILE__, __LINE__, NetPacket::NetErrorToGameError(netError->errorReason), 0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
InternalHandlePacket(client, tmpPacket);
|
InternalHandlePacket(client, tmpPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -1302,8 +1301,6 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
if (!tmpPlayer.get())
|
if (!tmpPlayer.get())
|
||||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
tmpPlayer->SetNumber(i);
|
tmpPlayer->SetNumber(i);
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1602,7 +1599,6 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
tmpCards[0] = static_cast<int>(p->allInCard1);
|
tmpCards[0] = static_cast<int>(p->allInCard1);
|
||||||
tmpCards[1] = static_cast<int>(p->allInCard2);
|
tmpCards[1] = static_cast<int>(p->allInCard2);
|
||||||
tmpPlayer->setMyCards(tmpCards);
|
tmpPlayer->setMyCards(tmpCards);
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
client->GetGui().flipHolecardsAllIn();
|
client->GetGui().flipHolecardsAllIn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,22 @@ NetPacket::IsClientActivity() const
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
net_packet_print_to_string(const void *buffer, size_t size, void *packetStr)
|
||||||
|
{
|
||||||
|
string *tmpString = (string *)packetStr;
|
||||||
|
*tmpString += string((const char *)buffer, size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
NetPacket::ToString() const
|
||||||
|
{
|
||||||
|
string packetString;
|
||||||
|
xer_encode(&asn_DEF_PokerTHMessage, m_msg, XER_F_BASIC, &net_packet_print_to_string, &packetString);
|
||||||
|
return packetString;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NetPacket::SetGameData(const GameData &inData, NetGameInfo_t *outData)
|
NetPacket::SetGameData(const GameData &inData, NetGameInfo_t *outData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,8 +61,11 @@ ReceiverHelper::ScanPackets(ReceiveBuffer &buf)
|
|||||||
LOG_ERROR(e.what());
|
LOG_ERROR(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tmpPacket.get())
|
if (tmpPacket)
|
||||||
|
{
|
||||||
|
//cerr << "IN:" << endl << tmpPacket->ToString() << endl;
|
||||||
buf.receivedPackets.push_back(tmpPacket);
|
buf.receivedPackets.push_back(tmpPacket);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
dataAvailable = false;
|
dataAvailable = false;
|
||||||
} while(dataAvailable);
|
} while(dataAvailable);
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ SenderHelper::InternalStorePacket(SendDataManager &tmpManager, boost::shared_ptr
|
|||||||
unsigned char buf[MAX_PACKET_SIZE];
|
unsigned char buf[MAX_PACKET_SIZE];
|
||||||
asn_enc_rval_t e;
|
asn_enc_rval_t e;
|
||||||
e = der_encode_to_buffer(&asn_DEF_PokerTHMessage, packet->GetMsg(), buf, MAX_PACKET_SIZE);
|
e = der_encode_to_buffer(&asn_DEF_PokerTHMessage, packet->GetMsg(), buf, MAX_PACKET_SIZE);
|
||||||
|
//cerr << "OUT:" << endl << packet->ToString() << endl;
|
||||||
if (e.encoded == -1)
|
if (e.encoded == -1)
|
||||||
LOG_ERROR("Failed to encode NetPacket: " << packet->GetMsg()->present);
|
LOG_ERROR("Failed to encode NetPacket: " << packet->GetMsg()->present);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#ifndef _NETPACKET_H_
|
#ifndef _NETPACKET_H_
|
||||||
#define _NETPACKET_H_
|
#define _NETPACKET_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <third_party/asn1/PokerTHMessage.h>
|
#include <third_party/asn1/PokerTHMessage.h>
|
||||||
@@ -57,6 +58,8 @@ public:
|
|||||||
|
|
||||||
bool IsClientActivity() const;
|
bool IsClientActivity() const;
|
||||||
|
|
||||||
|
std::string ToString() const;
|
||||||
|
|
||||||
static void SetGameData(const GameData &inData, NetGameInfo_t *outData);
|
static void SetGameData(const GameData &inData, NetGameInfo_t *outData);
|
||||||
static void GetGameData(const NetGameInfo_t *inData, GameData &outData);
|
static void GetGameData(const NetGameInfo_t *inData, GameData &outData);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user