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:
lotodore
2009-08-03 20:42:32 +00:00
parent 82ebd318d0
commit 9a8f2ae01a
6 changed files with 32 additions and 13 deletions
+6 -6
View File
@@ -30,27 +30,27 @@ void internal_log_err(const std::string &msg);
void internal_log_msg(const std::string &msg);
void internal_log_level(const std::string &msg, int logLevel);
#define LOG_ERROR(e) \
#define LOG_ERROR(_e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
outStream << _e << std::endl; \
internal_log_err(outStream.str()); \
} \
while(false)
#define LOG_MSG(e) \
#define LOG_MSG(_e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
outStream << _e << std::endl; \
internal_log_msg(outStream.str()); \
} \
while(false)
#define LOG_VERBOSE(e) \
#define LOG_VERBOSE(_e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
outStream << _e << std::endl; \
internal_log_level(outStream.str(), 2); \
} \
while(false)
+2 -6
View File
@@ -830,7 +830,6 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
client->RequestPlayerInfo(playerId);
}
tmpInfo.players.push_back(playerId);
++i;
}
tmpInfo.adminPlayerId = netListNew->adminPlayerId;
tmpInfo.isPasswordProtected = netListNew->isPrivate ? true : false;
@@ -941,8 +940,8 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
// Show the error.
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())
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
tmpPlayer->SetNumber(i);
++i;
}
}
else
@@ -1602,7 +1599,6 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
tmpCards[0] = static_cast<int>(p->allInCard1);
tmpCards[1] = static_cast<int>(p->allInCard2);
tmpPlayer->setMyCards(tmpCards);
++i;
}
client->GetGui().flipHolecardsAllIn();
}
+16
View File
@@ -87,6 +87,22 @@ NetPacket::IsClientActivity() const
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
NetPacket::SetGameData(const GameData &inData, NetGameInfo_t *outData)
{
+4 -1
View File
@@ -61,8 +61,11 @@ ReceiverHelper::ScanPackets(ReceiveBuffer &buf)
LOG_ERROR(e.what());
}
}
if (tmpPacket.get())
if (tmpPacket)
{
//cerr << "IN:" << endl << tmpPacket->ToString() << endl;
buf.receivedPackets.push_back(tmpPacket);
}
else
dataAvailable = false;
} while(dataAvailable);
+1
View File
@@ -236,6 +236,7 @@ SenderHelper::InternalStorePacket(SendDataManager &tmpManager, boost::shared_ptr
unsigned char buf[MAX_PACKET_SIZE];
asn_enc_rval_t e;
e = der_encode_to_buffer(&asn_DEF_PokerTHMessage, packet->GetMsg(), buf, MAX_PACKET_SIZE);
//cerr << "OUT:" << endl << packet->ToString() << endl;
if (e.encoded == -1)
LOG_ERROR("Failed to encode NetPacket: " << packet->GetMsg()->present);
else
+3
View File
@@ -21,6 +21,7 @@
#ifndef _NETPACKET_H_
#define _NETPACKET_H_
#include <string>
#include <list>
#include <third_party/asn1/PokerTHMessage.h>
@@ -57,6 +58,8 @@ public:
bool IsClientActivity() const;
std::string ToString() const;
static void SetGameData(const GameData &inData, NetGameInfo_t *outData);
static void GetGameData(const NetGameInfo_t *inData, GameData &outData);