2007-11-16 15:24:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2007 by Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
/* PokerTH network packet. */
|
|
|
|
|
|
|
|
|
|
#ifndef _NETPACKET_H_
|
|
|
|
|
#define _NETPACKET_H_
|
|
|
|
|
|
2009-08-03 20:42:32 +00:00
|
|
|
#include <string>
|
2009-05-07 22:36:51 +00:00
|
|
|
#include <list>
|
|
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
#include <third_party/asn1/PokerTHMessage.h>
|
2007-11-16 15:24:25 +00:00
|
|
|
#include <gamedata.h>
|
|
|
|
|
|
2011-02-06 13:17:07 +00:00
|
|
|
#define NET_VERSION_MAJOR 2
|
2010-09-04 11:56:40 +00:00
|
|
|
#define NET_VERSION_MINOR 0
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
#define MAX_FILE_DATA_SIZE 256
|
|
|
|
|
#define MAX_PACKET_SIZE 384
|
|
|
|
|
#define MAX_CHAT_TEXT_SIZE 128
|
|
|
|
|
|
|
|
|
|
/*#define MIN_PACKET_SIZE 4
|
2007-11-16 15:24:25 +00:00
|
|
|
#define MAX_NAME_SIZE 64
|
|
|
|
|
#define MAX_PASSWORD_SIZE 64
|
|
|
|
|
#define MAX_NUM_MANUAL_BLINDS 30
|
|
|
|
|
#define MAX_NUM_PLAYER_RESULTS MAX_NUMBER_OF_PLAYERS
|
2009-08-02 15:11:40 +00:00
|
|
|
#define MAX_NUM_PLAYER_CARDS MAX_NUMBER_OF_PLAYERS*/
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2010-04-01 17:44:20 +00:00
|
|
|
#define STL_STRING_FROM_OCTET_STRING(_a) (string((const char *)(_a).buf, (_a).size))
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
// This is just a wrapper class for the ASN.1 structure.
|
2007-11-16 15:24:25 +00:00
|
|
|
class NetPacket
|
|
|
|
|
{
|
|
|
|
|
public:
|
2009-08-02 15:11:40 +00:00
|
|
|
enum MemAllocType { NoAlloc = 0, Alloc };
|
|
|
|
|
NetPacket(MemAllocType alloc = NoAlloc);
|
|
|
|
|
~NetPacket();
|
|
|
|
|
|
2007-11-16 15:24:25 +00:00
|
|
|
static boost::shared_ptr<NetPacket> Create(char *data, unsigned &dataSize);
|
|
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
const PokerTHMessage_t *GetMsg() const {return m_msg;}
|
|
|
|
|
PokerTHMessage_t *GetMsg() {return m_msg;}
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
bool IsClientActivity() const;
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-08-03 20:42:32 +00:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
static void SetGameData(const GameData &inData, NetGameInfo_t *outData);
|
|
|
|
|
static void GetGameData(const NetGameInfo_t *inData, GameData &outData);
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
static int NetErrorToGameError(long netErrorReason);
|
|
|
|
|
static long GameErrorToNetError(int gameErrorReason);
|
2007-11-16 15:24:25 +00:00
|
|
|
|
|
|
|
|
private:
|
2009-08-02 15:11:40 +00:00
|
|
|
PokerTHMessage_t *m_msg;
|
2007-11-16 15:24:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef std::list<boost::shared_ptr<NetPacket> > NetPacketList;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|