Changeset 2483
- Timestamp:
- Dec 16, 2008, 3:31:22 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/network/packet/Welcome.cc
r2371 r2483 42 42 #define _PACKETID 0 43 43 #define _CLIENTID _PACKETID + sizeof(ENUM::Type) 44 #define _SHIPID _CLIENTID + sizeof(uint32_t) 45 #define _ENDIANTEST _SHIPID + sizeof(uint32_t) 44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 46 45 47 Welcome::Welcome( u nsigned int clientID, unsigned int shipID )46 Welcome::Welcome( uint32_t clientID, uint32_t shipID ) 48 47 : Packet() 49 48 { … … 53 52 assert(data_); 54 53 *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome; 55 *(uint32_t *)(data_ + _CLIENTID ) = clientID; 56 *(uint32_t *)(data_ + _SHIPID ) = shipID; 54 *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID); 57 55 *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321; 58 56 } 59 57 60 Welcome::Welcome( uint8_t* data, u nsigned int clientID )58 Welcome::Welcome( uint8_t* data, uint32_t clientID ) 61 59 : Packet(data, clientID) 62 60 { … … 72 70 73 71 unsigned int Welcome::getSize() const{ 74 return sizeof(packet::ENUM::Type) + 3*sizeof(uint32_t);72 return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t); 75 73 } 76 74 77 75 bool Welcome::process(){ 78 unsigned int shipID, clientID; 79 clientID = *(uint32_t *)&data_[ _CLIENTID ]; 80 shipID = *(uint32_t *)&data_[ _SHIPID ]; 76 uint32_t shipID, clientID; 77 clientID = *(uint32_t *)(data_ + _CLIENTID ); 81 78 assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321); 82 79 Host::setClientID(clientID); 83 Host::setShipID(shipID); 84 COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl; 80 COUT(3) << "Welcome set clientId: " << clientID << endl; 85 81 Synchronisable::setClient(true); 86 82 delete this;
Note: See TracChangeset
for help on using the changeset viewer.