Changeset 1907 for code/trunk/src/network/packet/Welcome.cc
- Timestamp:
- Oct 12, 2008, 7:40:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/packet/Welcome.cc
r1763 r1907 42 42 #define _PACKETID 0 43 43 #define _CLIENTID _PACKETID + sizeof(ENUM::Type) 44 #define _SHIPID _CLIENTID + sizeof(u nsigned int)44 #define _SHIPID _CLIENTID + sizeof(uint32_t) 45 45 46 46 Welcome::Welcome( unsigned int clientID, unsigned int shipID ) … … 49 49 flags_ = flags_ | PACKET_FLAGS_CLASSID; 50 50 assert(getSize()); 51 data_=new u nsigned char[ getSize() ];51 data_=new uint8_t[ getSize() ]; 52 52 assert(data_); 53 53 *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome; 54 *(u nsigned int *)&data_[ _CLIENTID ] = clientID;55 *(u nsigned int *)&data_[ _SHIPID ] = shipID;54 *(uint32_t *)&data_[ _CLIENTID ] = clientID; 55 *(uint32_t *)&data_[ _SHIPID ] = shipID; 56 56 } 57 57 58 Welcome::Welcome( u nsigned char *data,int clientID )58 Welcome::Welcome( uint8_t* data, unsigned int clientID ) 59 59 : Packet(data, clientID) 60 60 { … … 65 65 } 66 66 67 u nsigned char*Welcome::getData(){67 uint8_t *Welcome::getData(){ 68 68 return data_; 69 69 } 70 70 71 71 unsigned int Welcome::getSize() const{ 72 return sizeof(network::packet::ENUM::Type) + 2*sizeof(u nsigned int);72 return sizeof(network::packet::ENUM::Type) + 2*sizeof(uint32_t); 73 73 } 74 74 75 75 bool Welcome::process(){ 76 76 unsigned int shipID, clientID; 77 clientID = *(u nsigned int *)&data_[ _CLIENTID ];78 shipID = *(u nsigned int *)&data_[ _SHIPID ];77 clientID = *(uint32_t *)&data_[ _CLIENTID ]; 78 shipID = *(uint32_t *)&data_[ _SHIPID ]; 79 79 Host::setClientID(clientID); 80 80 Host::setShipID(shipID);
Note: See TracChangeset
for help on using the changeset viewer.