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