Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/packet/Welcome.cc @ 1709

Last change on this file since 1709 was 1709, checked in by scheusso, 16 years ago

fixed messing up with enet

File size: 1.2 KB
Line 
1#include "Welcome.h"
2#include "Packet.h"
3#include <assert.h>
4
5namespace network {
6namespace packet {
7
8#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
9#define _PACKETID             0
10#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
11#define _SHIPID               _CLIENTID + sizeof(unsigned int)
12 
13  Welcome::Welcome( unsigned int clientID, unsigned int shipID )
14 : PacketContent()
15{
16  flags_ = flags_ | PACKET_FLAGS_CLASSID;
17  assert(getSize());
18  data_=new unsigned char[ getSize() ];
19  assert(data_);
20  *(packet::ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::Welcome;
21  *(unsigned int *)&data_[ _CLIENTID ] = clientID;
22  *(unsigned int *)&data_[ _SHIPID ] = shipID;
23}
24
25Welcome::Welcome( unsigned char *data, int clientID )
26  : PacketContent(data, clientID)
27{
28}
29
30Welcome::~Welcome()
31{
32}
33
34unsigned char *Welcome::getData(){
35  return data_;
36}
37
38unsigned int Welcome::getSize() const{
39  return sizeof(network::packet::ENUM::Type) + 2*sizeof(unsigned int);
40}
41
42bool Welcome::process(){
43  unsigned int shipID, clientID;
44  clientID = *(unsigned int *)&data_[ _CLIENTID ];
45  shipID = *(unsigned int *)&data_[ _SHIPID ];
46  return true;
47}
48
49
50} //namespace packet
51}//namespace network
Note: See TracBrowser for help on using the repository browser.