Changeset 3257 for code/branches/core4/src/network
- Timestamp:
- Jun 30, 2009, 3:14:45 PM (15 years ago)
- Location:
- code/branches/core4/src/network
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/network/NetworkPrereqs.h
r3214 r3257 132 132 namespace PacketFlag 133 133 { 134 enum Enum134 enum Value 135 135 { 136 136 Reliable = 1, -
code/branches/core4/src/network/packet/Acknowledgement.cc
r3214 r3257 37 37 #define PACKET_FLAGS_ACK 0 38 38 #define _PACKETID 0 39 #define _ACKID _PACKETID + sizeof(packet:: ENUM::Type)39 #define _ACKID _PACKETID + sizeof(packet::Type::Value) 40 40 41 41 Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID ) … … 44 44 flags_ = flags_ | PACKET_FLAGS_ACK; 45 45 data_=new uint8_t[ getSize() ]; 46 *( ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;46 *(Type::Value *)(data_ + _PACKETID ) = Type::Acknowledgement; 47 47 *(uint32_t *)(data_ + _ACKID ) = id; 48 48 clientID_=clientID; -
code/branches/core4/src/network/packet/Chat.cc
r3214 r3257 38 38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 39 #define _PACKETID 0 40 const int _PLAYERID = _PACKETID + sizeof( ENUM::Type);40 const int _PLAYERID = _PACKETID + sizeof(Type::Value); 41 41 #define _MESSAGELENGTH _PLAYERID + sizeof(uint32_t) 42 42 #define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t) … … 48 48 messageLength_ = message.length()+1; 49 49 data_=new unsigned char[ getSize() ]; 50 *( ENUM::Type *)(data_ + _PACKETID ) = ENUM::Chat;50 *(Type::Value *)(data_ + _PACKETID ) = Type::Chat; 51 51 *(unsigned int *)(data_ + _PLAYERID ) = playerID; 52 52 *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_; -
code/branches/core4/src/network/packet/ClassID.cc
r3214 r3257 74 74 //set the appropriate packet id 75 75 assert(this->data_); 76 *( ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::ClassID;76 *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID; 77 77 78 78 uint8_t *temp=data_+sizeof(uint32_t); -
code/branches/core4/src/network/packet/DeleteObjects.cc
r3214 r3257 39 39 #define PACKET_FLAG_DELETE PacketFlag::Reliable 40 40 #define _PACKETID 0 41 #define _QUANTITY _PACKETID + sizeof( ENUM::Type)41 #define _QUANTITY _PACKETID + sizeof(Type::Value) 42 42 #define _OBJECTIDS _QUANTITY + sizeof(uint32_t) 43 43 … … 62 62 return false; 63 63 COUT(4) << "sending DeleteObjects: "; 64 unsigned int size = sizeof( ENUM::Type) + sizeof(uint32_t)*(number+1);64 unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1); 65 65 data_ = new uint8_t[size]; 66 66 uint8_t *tdata = data_; 67 *reinterpret_cast< ENUM::Type*>(tdata) = ENUM::DeleteObjects;68 tdata += sizeof( ENUM::Type);67 *reinterpret_cast<Type::Value*>(tdata) = Type::DeleteObjects; 68 tdata += sizeof(Type::Value); 69 69 *(uint32_t *)tdata = number; 70 70 tdata += sizeof(uint32_t); -
code/branches/core4/src/network/packet/FunctionCalls.cc
r3214 r3257 49 49 currentMemBlocks_ = 1; 50 50 data_=new uint8_t[ FUNCTIONCALLS_MEM_ALLOCATION ]; 51 *( ENUM::Type *)(data_ + _PACKETID ) = ENUM::FunctionCalls;51 *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls; 52 52 *(uint32_t*)(data_+sizeof(uint32_t)) = 0; // set nrOfCalls to 0 53 53 } -
code/branches/core4/src/network/packet/FunctionIDs.cc
r3214 r3257 68 68 //set the appropriate packet id 69 69 assert(this->data_); 70 *( ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::FunctionIDs;70 *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs; 71 71 72 72 uint8_t *temp=data_+sizeof(uint32_t); -
code/branches/core4/src/network/packet/Gamestate.h
r3214 r3257 47 47 class _NetworkExport GamestateHeader{ 48 48 public: 49 GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }49 GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; } 50 50 GamestateHeader(uint8_t *data, GamestateHeader* h) 51 51 { assert(data); data_=data; memcpy(data_, h->data_, getSize()); } -
code/branches/core4/src/network/packet/Packet.cc
r3214 r3257 63 63 Packet::Packet(){ 64 64 flags_ = PACKET_FLAG_DEFAULT; 65 packetDirection_ = ENUM::Outgoing;65 packetDirection_ = Direction::Outgoing; 66 66 clientID_=0; 67 67 data_=0; … … 76 76 Packet::Packet(uint8_t *data, unsigned int clientID){ 77 77 flags_ = PACKET_FLAG_DEFAULT; 78 packetDirection_ = ENUM::Incoming;78 packetDirection_ = Direction::Incoming; 79 79 clientID_=clientID; 80 80 data_=data; … … 125 125 126 126 bool Packet::send(){ 127 if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){127 if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){ 128 128 assert(0); 129 129 return false; … … 147 147 } 148 148 #ifndef NDEBUG 149 switch( *( ENUM::Type *)(data_ + _PACKETID) )149 switch( *(Type::Value *)(data_ + _PACKETID) ) 150 150 { 151 case ENUM::Acknowledgement:152 case ENUM::Chat:153 case ENUM::ClassID:154 case ENUM::Gamestate:155 case ENUM::Welcome:156 case ENUM::DeleteObjects:157 case ENUM::FunctionIDs:158 case ENUM::FunctionCalls:151 case Type::Acknowledgement: 152 case Type::Chat: 153 case Type::ClassID: 154 case Type::Gamestate: 155 case Type::Welcome: 156 case Type::DeleteObjects: 157 case Type::FunctionIDs: 158 case Type::FunctionCalls: 159 159 break; 160 160 default: … … 175 175 unsigned int clientID = ClientInformation::findClient(&peer->address)->getID(); 176 176 Packet *p = 0; 177 COUT(6) << "packet type: " << *( ENUM::Type *)&data[_PACKETID] << std::endl;178 switch( *( ENUM::Type *)(data + _PACKETID) )177 COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl; 178 switch( *(Type::Value *)(data + _PACKETID) ) 179 179 { 180 case ENUM::Acknowledgement:180 case Type::Acknowledgement: 181 181 COUT(5) << "ack" << std::endl; 182 182 p = new Acknowledgement( data, clientID ); 183 183 break; 184 case ENUM::Chat:184 case Type::Chat: 185 185 COUT(5) << "chat" << std::endl; 186 186 p = new Chat( data, clientID ); 187 187 break; 188 case ENUM::ClassID:188 case Type::ClassID: 189 189 COUT(5) << "classid" << std::endl; 190 190 p = new ClassID( data, clientID ); 191 191 break; 192 case ENUM::Gamestate:192 case Type::Gamestate: 193 193 COUT(5) << "gamestate" << std::endl; 194 194 // TODO: remove brackets 195 195 p = new Gamestate( data, clientID ); 196 196 break; 197 case ENUM::Welcome:197 case Type::Welcome: 198 198 COUT(5) << "welcome" << std::endl; 199 199 p = new Welcome( data, clientID ); 200 200 break; 201 case ENUM::DeleteObjects:201 case Type::DeleteObjects: 202 202 COUT(5) << "deleteobjects" << std::endl; 203 203 p = new DeleteObjects( data, clientID ); 204 204 break; 205 case ENUM::FunctionCalls:205 case Type::FunctionCalls: 206 206 COUT(5) << "functionCalls" << std::endl; 207 207 p = new FunctionCalls( data, clientID ); 208 208 break; 209 case ENUM::FunctionIDs:209 case Type::FunctionIDs: 210 210 COUT(5) << "functionIDs" << std::endl; 211 211 p = new FunctionIDs( data, clientID ); -
code/branches/core4/src/network/packet/Packet.h
r3214 r3257 36 36 namespace packet{ 37 37 38 namespace ENUM{39 enum Direction{38 namespace Direction{ 39 enum Value{ 40 40 Incoming, 41 41 Outgoing, 42 42 Bidirectional 43 43 }; 44 enum Type{ 44 } 45 namespace Type{ 46 enum Value{ 45 47 Acknowledgement, 46 48 Chat, … … 84 86 uint32_t flags_; 85 87 unsigned int clientID_; 86 ENUM::DirectionpacketDirection_;88 Direction::Value packetDirection_; 87 89 /** Pointer to the data. Be careful when deleting it because it might 88 90 point to a location that was allocated by ENet. -
code/branches/core4/src/network/packet/Welcome.cc
r3214 r3257 41 41 #define PACKET_FLAGS_CLASSID PacketFlag::Reliable 42 42 #define _PACKETID 0 43 #define _CLIENTID _PACKETID + sizeof( ENUM::Type)43 #define _CLIENTID _PACKETID + sizeof(Type::Value) 44 44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 45 45 … … 51 51 data_=new uint8_t[ getSize() ]; 52 52 assert(data_); 53 *(packet:: ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;53 *(packet::Type::Value *)(data_ + _PACKETID ) = packet::Type::Welcome; 54 54 *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID); 55 55 *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321; … … 70 70 71 71 unsigned int Welcome::getSize() const{ 72 return sizeof(packet:: ENUM::Type) + 2*sizeof(uint32_t);72 return sizeof(packet::Type::Value) + 2*sizeof(uint32_t); 73 73 } 74 74 -
code/branches/core4/src/network/synchronisable/Synchronisable.cc
r3239 r3257 65 65 this->dataSize_ = 0; 66 66 // set standard priority 67 this->setPriority( priority::normal );67 this->setPriority( Priority::Normal ); 68 68 69 69 // get creator id -
code/branches/core4/src/network/synchronisable/Synchronisable.h
r3214 r3257 51 51 { 52 52 53 namespace objectDirection{54 enum objectdirection{55 toclient=0x1,56 toserver=0x2,57 bidirectional=0x353 namespace ObjectDirection{ 54 enum Value{ 55 ToClient=0x1, 56 ToServer=0x2, 57 Bidirectional=0x3 58 58 }; 59 59 } 60 60 61 namespace priority{62 enum prio{63 very_high= -100,64 high = -15,65 normal = 0,66 low = 15,67 very_low= 10061 namespace Priority{ 62 enum Value{ 63 VeryHigh = -100, 64 High = -15, 65 Normal = 0, 66 Low = 15, 67 VeryLow = 100 68 68 }; 69 69 } -
code/branches/core4/src/network/synchronisable/SynchronisableVariable.h
r3214 r3257 41 41 namespace orxonox{ 42 42 43 namespace variableDirection{44 enum syncdirection{45 toclient=0x1,46 toserver=0x243 namespace VariableDirection{ 44 enum Value{ 45 ToClient=0x1, 46 ToServer=0x2 47 47 }; 48 enum bidirectional{ 49 serverMaster=0x1, 50 clientMaster=0x2 48 } 49 namespace Bidirectionality{ 50 enum Value{ 51 ServerMaster=0x1, 52 ClientMaster=0x2 51 53 }; 52 54 } … … 69 71 { 70 72 public: 71 SynchronisableVariable(T& variable, uint8_t syncDirection= variableDirection::toclient, NetworkCallbackBase *cb=0);73 SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=0); 72 74 virtual ~SynchronisableVariable(); 73 75 … … 88 90 { 89 91 public: 90 SynchronisableVariableBidirectional(T& variable, uint8_t master= variableDirection::serverMaster, NetworkCallbackBase *cb=0);92 SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0); 91 93 virtual ~SynchronisableVariableBidirectional(); 92 94
Note: See TracChangeset
for help on using the changeset viewer.