Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 30, 2015, 11:34:25 PM (8 years ago)
Author:
landauf
Message:

made some enums in network library strongly typed. for most other enums in network this isn't possible because they are often used like flags (converted to int and compared with binary operators).
packet::Type now uses uint8_t as underlying type which reduces the network traffic (by default the type was int)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/network/packet/Welcome.cc

    r8858 r11006  
    4141#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4242#define _PACKETID             0
    43 #define _CLIENTID             _PACKETID + sizeof(Type::Value)
     43#define _CLIENTID             _PACKETID + sizeof(Type)
    4444#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
    4545
     
    5151  data_=new uint8_t[ getSize() ];
    5252  assert(data_);
    53   *(packet::Type::Value *)(data_ + _PACKETID ) = packet::Type::Welcome;
     53  *(packet::Type *)(data_ + _PACKETID ) = packet::Type::Welcome;
    5454  *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID);
    5555  *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
     
    7070
    7171unsigned int Welcome::getSize() const{
    72   return sizeof(packet::Type::Value) + 2*sizeof(uint32_t);
     72  return sizeof(packet::Type) + 2*sizeof(uint32_t);
    7373}
    7474
Note: See TracChangeset for help on using the changeset viewer.