Rev | Line | |
---|
[1705] | 1 | #include "Welcome.h" |
---|
| 2 | #include "Packet.h" |
---|
[1709] | 3 | #include <assert.h> |
---|
[1705] | 4 | |
---|
| 5 | namespace network { |
---|
| 6 | namespace 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; |
---|
[1709] | 17 | assert(getSize()); |
---|
[1705] | 18 | data_=new unsigned char[ getSize() ]; |
---|
[1709] | 19 | assert(data_); |
---|
[1705] | 20 | *(packet::ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::Welcome; |
---|
| 21 | *(unsigned int *)&data_[ _CLIENTID ] = clientID; |
---|
| 22 | *(unsigned int *)&data_[ _SHIPID ] = shipID; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | Welcome::Welcome( unsigned char *data, int clientID ) |
---|
| 26 | : PacketContent(data, clientID) |
---|
| 27 | { |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | Welcome::~Welcome() |
---|
| 31 | { |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | unsigned char *Welcome::getData(){ |
---|
| 35 | return data_; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | unsigned int Welcome::getSize() const{ |
---|
| 39 | return sizeof(network::packet::ENUM::Type) + 2*sizeof(unsigned int); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | bool 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.