Changeset 2171 for code/trunk/src/network
- Timestamp:
- Nov 10, 2008, 12:05:03 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/objecthierarchy merged: 2111-2115,2123,2132-2134,2143-2144,2153-2158,2160-2169
- Property svn:mergeinfo changed
-
code/trunk/src/network/ChatListener.cc
r2087 r2171 32 32 #include "core/Core.h" 33 33 34 namespace network34 namespace orxonox 35 35 { 36 36 ChatListener::ChatListener() -
code/trunk/src/network/ChatListener.h
r2087 r2171 35 35 #include "core/OrxonoxClass.h" 36 36 37 namespace network37 namespace orxonox 38 38 { 39 class _NetworkExport ChatListener : virtual public orxonox::OrxonoxClass39 class _NetworkExport ChatListener : virtual public OrxonoxClass 40 40 { 41 41 public: -
code/trunk/src/network/Client.cc
r2087 r2171 49 49 // #include "packet/Acknowledgement.h" 50 50 51 namespace network51 namespace orxonox 52 52 { 53 53 // SetConsoleCommandShortcut(Client, chat); -
code/trunk/src/network/Client.h
r2087 r2171 54 54 55 55 56 namespace network56 namespace orxonox 57 57 { 58 58 /** 59 network::Client *client;59 Client *client; 60 60 * The network/Client class 61 61 * This class implements all necessary function for the network communication -
code/trunk/src/network/ClientConnection.cc
r2087 r2171 48 48 #include "util/Debug.h" 49 49 50 namespace network50 namespace orxonox 51 51 { 52 52 //static boost::thread_group network_threads; -
code/trunk/src/network/ClientConnection.h
r2087 r2171 50 50 namespace boost { class thread; } 51 51 52 namespace network52 namespace orxonox 53 53 { 54 54 -
code/trunk/src/network/ClientConnectionListener.cc
r2087 r2171 3 3 #include "core/Core.h" 4 4 5 namespace network{5 namespace orxonox{ 6 6 7 7 ClientConnectionListener::ClientConnectionListener() … … 11 11 12 12 void ClientConnectionListener::getConnectedClients(){ 13 if( orxonox::Core::showsGraphics())13 if(Core::showsGraphics()) 14 14 this->clientConnected(0); //server client id 15 15 ClientInformation *client = ClientInformation::getBegin(); -
code/trunk/src/network/ClientConnectionListener.h
r2087 r2171 6 6 #include "core/OrxonoxClass.h" 7 7 8 namespace network{8 namespace orxonox{ 9 9 10 class _NetworkExport ClientConnectionListener : virtual public orxonox::OrxonoxClass10 class _NetworkExport ClientConnectionListener : virtual public OrxonoxClass 11 11 { 12 12 friend class Server; -
code/trunk/src/network/ClientInformation.cc
r2087 r2171 43 43 #include <iostream> //debug 44 44 45 namespace network45 namespace orxonox 46 46 { 47 47 -
code/trunk/src/network/ClientInformation.h
r2087 r2171 48 48 // WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE 49 49 50 namespace network50 namespace orxonox 51 51 { 52 52 static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1; -
code/trunk/src/network/ConnectionManager.cc
r2087 r2171 65 65 } 66 66 67 namespace network67 namespace orxonox 68 68 { 69 69 //boost::thread_group network_threads; … … 138 138 139 139 bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) { 140 boost::recursive_mutex::scoped_lock lock( instance_->enet_mutex);140 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 141 141 if(enet_peer_send(peer, NETWORK_DEFAULT_CHANNEL, packet)!=0) 142 142 return false; … … 156 156 if(!instance_) 157 157 return false; 158 boost::recursive_mutex::scoped_lock lock( instance_->enet_mutex);158 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 159 159 for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){ 160 160 COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl; … … 169 169 if(server==NULL || !instance_) 170 170 return false; 171 boost::recursive_mutex::scoped_lock lock( enet_mutex);171 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 172 172 enet_host_flush(server); 173 173 lock.unlock(); … … 180 180 atexit(enet_deinitialize); 181 181 { //scope of the mutex 182 boost::recursive_mutex::scoped_lock lock( enet_mutex);182 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 183 183 enet_initialize(); 184 184 server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0); … … 194 194 while(!quit){ 195 195 { //mutex scope 196 boost::recursive_mutex::scoped_lock lock( enet_mutex);196 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 197 197 if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){ 198 198 // we should never reach this point … … 236 236 // if we're finishied, destroy server 237 237 { 238 boost::recursive_mutex::scoped_lock lock( enet_mutex);238 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 239 239 enet_host_destroy(server); 240 240 lock.unlock(); … … 250 250 while(temp!=0){ 251 251 { 252 boost::recursive_mutex::scoped_lock lock( enet_mutex);252 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 253 253 enet_peer_disconnect(temp->getPeer(), 0); 254 254 lock.unlock(); … … 258 258 //bugfix: might be the reason why server crashes when clients disconnects 259 259 temp = ClientInformation::getBegin()->next(); 260 boost::recursive_mutex::scoped_lock lock( enet_mutex);260 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 261 261 while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) >= 0){ 262 262 switch (event.type) … … 306 306 unsigned int network_id=0, failures=0; 307 307 std::string classname; 308 orxonox::Identifier *id;309 std::map<std::string, orxonox::Identifier*>::const_iterator it = orxonox::Factory::getFactoryMapBegin();310 while(it != orxonox::Factory::getFactoryMapEnd()){308 Identifier *id; 309 std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin(); 310 while(it != Factory::getFactoryMapEnd()){ 311 311 id = (*it).second; 312 312 if(id == NULL) … … 332 332 void ConnectionManager::disconnectClient(ClientInformation *client){ 333 333 { 334 boost::recursive_mutex::scoped_lock lock( enet_mutex);334 boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex); 335 335 enet_peer_disconnect(client->getPeer(), 0); 336 336 lock.unlock(); -
code/trunk/src/network/ConnectionManager.h
r2087 r2171 59 59 } 60 60 61 namespace network61 namespace orxonox 62 62 { 63 63 const int NETWORK_PORT = 55556; -
code/trunk/src/network/GamestateClient.cc
r2087 r2171 39 39 40 40 41 namespace network41 namespace orxonox 42 42 { 43 43 struct _NetworkExport GameStateItem{ … … 94 94 * @return iterator pointing to the next object in the list 95 95 */ 96 void GamestateClient::removeObject( orxonox::ObjectList<Synchronisable>::iterator &it) {97 orxonox::ObjectList<Synchronisable>::iterator temp=it;96 void GamestateClient::removeObject(ObjectList<Synchronisable>::iterator &it) { 97 ObjectList<Synchronisable>::iterator temp=it; 98 98 ++it; 99 99 delete *temp; -
code/trunk/src/network/GamestateClient.h
r2087 r2171 50 50 const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1; 51 51 52 namespace network52 namespace orxonox 53 53 { 54 54 class _NetworkExport GamestateClient: public GamestateHandler … … 66 66 private: 67 67 packet::Gamestate *processGamestate(packet::Gamestate *gs); 68 void removeObject( orxonox::ObjectListIterator<Synchronisable> &it);68 void removeObject(ObjectListIterator<Synchronisable> &it); 69 69 void printGamestateMap(); 70 70 bool sendAck(unsigned int gamestateID); -
code/trunk/src/network/GamestateHandler.cc
r1763 r2171 4 4 #include "packet/Packet.h" 5 5 6 namespace network{6 namespace orxonox { 7 7 8 8 GamestateHandler *GamestateHandler::instance_=0; … … 22 22 23 23 24 }//namespace network24 }//namespace orxonox -
code/trunk/src/network/GamestateHandler.h
r2087 r2171 34 34 #include "packet/Chat.h" 35 35 36 namespace network{36 namespace orxonox { 37 37 38 38 /** -
code/trunk/src/network/GamestateManager.cc
r2087 r2171 51 51 #include "Synchronisable.h" 52 52 53 namespace network53 namespace orxonox 54 54 { 55 55 GamestateManager::GamestateManager() { -
code/trunk/src/network/GamestateManager.h
r2087 r2171 47 47 #include "packet/Gamestate.h" 48 48 49 namespace network49 namespace orxonox 50 50 { 51 51 -
code/trunk/src/network/Host.cc
r2087 r2171 34 34 #include "ChatListener.h" 35 35 36 namespace network{36 namespace orxonox { 37 37 38 38 SetConsoleCommandShortcut(Host, Chat); … … 80 80 // } 81 81 82 // bool Host::receiveChat( network::packet::Chat *message, unsigned int clientID){82 // bool Host::receiveChat(packet::Chat *message, unsigned int clientID){ 83 83 // if(instance_) 84 84 // return instance_->processChat(message, clientID); … … 110 110 111 111 bool Host::incomingChat(const std::string& message, unsigned int playerID){ 112 for ( orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it)112 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 113 113 it->incomingChat(message, playerID); 114 114 … … 116 116 } 117 117 118 }//namespace network118 }//namespace orxonox -
code/trunk/src/network/Host.h
r2087 r2171 34 34 #include "packet/Chat.h" 35 35 36 namespace network{36 namespace orxonox { 37 37 38 38 /** -
code/trunk/src/network/NetworkCallback.h
r2087 r2171 4 4 #include "NetworkPrereqs.h" 5 5 6 namespace network{6 namespace orxonox{ 7 7 class _NetworkExport NetworkCallbackBase 8 8 { -
code/trunk/src/network/NetworkPrereqs.h
r2087 r2171 59 59 // Forward declarations 60 60 //----------------------------------------------------------------------- 61 namespace network61 namespace orxonox 62 62 { 63 63 class Client; -
code/trunk/src/network/PacketBuffer.cc
r1505 r2171 39 39 #include <boost/thread/mutex.hpp> 40 40 41 namespace network41 namespace orxonox 42 42 { 43 43 boost::recursive_mutex PacketBuffer::mutex_; … … 147 147 } 148 148 149 } // namespace network149 } // namespace orxonox -
code/trunk/src/network/PacketBuffer.h
r2087 r2171 47 47 #include <boost/thread/recursive_mutex.hpp> 48 48 49 namespace network49 namespace orxonox 50 50 { 51 51 struct _NetworkExport PacketEnvelope{ -
code/trunk/src/network/Server.cc
r2087 r2171 60 60 #include "ChatListener.h" 61 61 62 namespace network62 namespace orxonox 63 63 { 64 64 const unsigned int MAX_FAILURES = 20; … … 317 317 318 318 // inform all the listeners 319 orxonox::ObjectList<ClientConnectionListener>::iterator listener = orxonox::ObjectList<ClientConnectionListener>::begin();319 ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin(); 320 320 while(listener){ 321 321 listener->clientConnected(newid); … … 366 366 367 367 // inform all the listeners 368 orxonox::ObjectList<ClientConnectionListener>::iterator listener = orxonox::ObjectList<ClientConnectionListener>::begin();368 ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin(); 369 369 while(listener){ 370 370 listener->clientDisconnected(client->getID()); … … 404 404 } 405 405 // COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl; 406 for ( orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it)406 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 407 407 it->incomingChat(message, clientID); 408 408 -
code/trunk/src/network/Server.h
r2087 r2171 49 49 #include "GamestateManager.h" 50 50 51 namespace network51 namespace orxonox 52 52 { 53 53 const int CLIENTID_SERVER = 0; -
code/trunk/src/network/Synchronisable.cc
r2087 r2171 50 50 // #include "core/Identifier.h" 51 51 52 namespace network 52 #include "Host.h" 53 namespace orxonox 53 54 { 54 55 … … 57 58 std::queue<unsigned int> Synchronisable::deletedObjects_; 58 59 59 int Synchronisable::state_=0x1; // detemines wheter we are server (default) or client60 uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client 60 61 61 62 /** … … 63 64 * Initializes all Variables and sets the right objectID 64 65 */ 65 Synchronisable::Synchronisable( orxonox::BaseObject* creator){66 Synchronisable::Synchronisable(BaseObject* creator){ 66 67 RegisterRootObject(Synchronisable); 67 68 static uint32_t idCounter=0; 68 69 objectFrequency_=1; 69 70 objectMode_=0x1; // by default do not send data to server 70 objectID=idCounter++; 71 if ( !Host::running() || ( Host::running() && Host::isServer() ) ) 72 { 73 this->objectID = idCounter++; //this is only needed when running a server 74 //add synchronisable to the objectMap 75 objectMap_[this->objectID] = this; 76 } 77 else 78 objectID=OBJECTID_UNKNOWN; 71 79 classID = (unsigned int)-1; 72 80 syncList = new std::list<synchronisableVariable *>; 81 82 83 #ifndef NDEBUG 84 ObjectList<Synchronisable>::iterator it; 85 for(it = ObjectList<Synchronisable>::begin(); it!=ObjectList<Synchronisable>::end(); ++it){ 86 if( it->getObjectID()==this->objectID ) 87 assert(*it==this || (it->objectID==OBJECTID_UNKNOWN && it->objectMode_==0x0)); 88 } 89 #endif 73 90 74 91 this->creatorID = OBJECTID_UNKNOWN; … … 96 113 Synchronisable::~Synchronisable(){ 97 114 // delete callback function objects 98 if(! orxonox::Identifier::isCreatingHierarchy()){115 if(!Identifier::isCreatingHierarchy()){ 99 116 for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++) 100 117 delete (*it)->callback; 101 if (this->objectMode_ != 0x0 )118 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer())) 102 119 deletedObjects_.push(objectID); 103 120 // COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl; … … 106 123 // objectMap_.erase(objectID); 107 124 } 125 std::map<unsigned int, Synchronisable*>::iterator it; 126 it = objectMap_.find(objectID); 127 if (it != objectMap_.end()) 128 objectMap_.erase(it); 108 129 } 109 130 … … 143 164 * @return pointer to the newly created synchronisable 144 165 */ 145 Synchronisable *Synchronisable::fabricate(uint8_t*& mem, int mode)166 Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode) 146 167 { 147 168 synchronisableHeader *header = (synchronisableHeader *)mem; … … 152 173 return 0; 153 174 } 154 175 155 176 COUT(4) << "fabricating object with id: " << header->objectID << std::endl; 156 177 157 orxonox::Identifier* id = ClassByID(header->classID);178 Identifier* id = ClassByID(header->classID); 158 179 assert(id); 159 orxonox::BaseObject* creator = 0;180 BaseObject* creator = 0; 160 181 if (header->creatorID != OBJECTID_UNKNOWN) 161 182 { … … 167 188 } 168 189 else 169 creator = dynamic_cast<orxonox::BaseObject*>(synchronisable_creator); 170 } 171 orxonox::BaseObject *bo = id->fabricate(creator); 190 creator = dynamic_cast<BaseObject*>(synchronisable_creator); 191 } 192 assert(getSynchronisable(header->objectID)==0); //make sure no object with this id exists 193 BaseObject *bo = id->fabricate(creator); 172 194 assert(bo); 173 195 Synchronisable *no = dynamic_cast<Synchronisable *>(bo); … … 214 236 */ 215 237 Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){ 216 orxonox::ObjectList<Synchronisable>::iterator it; 217 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){ 218 if( it->getObjectID()==objectID ) 219 return *it; 238 std::map<unsigned int, Synchronisable*>::iterator it1; 239 it1 = objectMap_.find(objectID); 240 if (it1 != objectMap_.end()) 241 return it1->second; 242 243 ObjectList<Synchronisable>::iterator it; 244 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ 245 if( it->getObjectID()==objectID ){ 246 objectMap_[objectID] = *it; 247 return *it; 248 } 220 249 } 221 250 return NULL; 222 223 // std::map<unsigned int, Synchronisable *>::iterator i = objectMap_.find(objectID);224 // if(i==objectMap_.end())225 // return NULL;226 // assert(i->second->objectID==objectID);227 // return (*i).second;228 251 } 229 252 … … 234 257 * @param var pointer to the variable 235 258 * @param size size of the datatype the variable consists of 236 * @param t the type of the variable ( network::DATA or network::STRING259 * @param t the type of the variable (DATA or STRING 237 260 * @param mode same as in getData 238 261 * @param cb callback object that should get called, if the value of the variable changes 239 262 */ 240 void Synchronisable::registerVar (void *var, int size, variableType t, int mode, NetworkCallbackBase *cb){263 void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){ 241 264 assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster); 242 265 // create temporary synch.Var struct … … 249 272 if( ( mode & direction::bidirectional ) ) 250 273 { 251 temp->varBuffer = new uint8_t[size]; 252 memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time 274 if(t!=STRING) 275 { 276 temp->varBuffer = new uint8_t[size]; 277 memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time 278 } 279 else 280 { 281 temp->varBuffer=new std::string( *static_cast<std::string*>(var) ); 282 } 253 283 temp->varReference = 0; 254 284 } … … 265 295 #endif 266 296 } 297 298 void Synchronisable::unregisterVariable(void *var){ 299 std::list<synchronisableVariable *>::iterator it = syncList->begin(); 300 while(it!=syncList->end()){ 301 if( (*it)->var == var ){ 302 delete *it; 303 syncList->erase(it); 304 return; 305 } 306 else 307 it++; 308 } 309 bool unregistered_nonexistent_variable = false; 310 assert(unregistered_nonexistent_variable); //if we reach this point something went wrong: 311 // the variable has not been registered before 312 } 313 267 314 268 315 /** … … 280 327 * @return true: if !doSync or if everything was successfully saved 281 328 */ 282 bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){ 329 bool Synchronisable::getData(uint8_t*& mem, unsigned int id, uint8_t mode){ 330 if(mode==0x0) 331 mode=state_; 283 332 //if this tick is we dont synchronise, then abort now 284 if(!doSync(id ))333 if(!doSync(id, mode)) 285 334 return true; 286 335 //std::cout << "inside getData" << std::endl; 287 336 unsigned int tempsize = 0; 288 if(mode==0x0)289 mode=state_;290 337 if(classID==0) 291 338 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl; … … 307 354 header->classID = this->classID; 308 355 header->dataAvailable = true; 309 tempsize +=sizeof(synchronisableHeader);310 mem +=sizeof(synchronisableHeader);356 tempsize += sizeof(synchronisableHeader); 357 mem += sizeof(synchronisableHeader); 311 358 // end copy header 312 359 … … 319 366 continue; // this variable should only be received 320 367 } 368 369 // =========== start bidirectional stuff ============= 321 370 // if the variable gets synchronised bidirectional, then add the reference to the bytestream 322 371 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 323 372 { 373 if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \ 374 ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) ) 375 { 376 // MASTER 377 if((*i)->type==DATA){ 378 if( memcmp((*i)->var,(*i)->varBuffer,(*i)->size) != 0 ) //check whether the variable changed during the last tick 379 { 380 ((*i)->varReference)++; //the variable changed so increase the refnr 381 memcpy((*i)->varBuffer, (*i)->var, (*i)->size); //set the buffer to the new value 382 } 383 } 384 else //STRING 385 { 386 if( *static_cast<std::string*>((*i)->var) != *static_cast<std::string*>((*i)->varBuffer) ) //the string changed 387 { 388 ((*i)->varReference)++; //the variable changed 389 *static_cast<std::string*>((*i)->varBuffer) = *static_cast<std::string*>((*i)->var); //now set the buffer to the new value 390 } 391 } 392 } 393 // copy the reference number to the stream 324 394 *(uint8_t*)mem = (*i)->varReference; 325 395 mem += sizeof( (*i)->varReference ); 326 396 tempsize += sizeof( (*i)->varReference ); 327 397 } 398 // ================== end bidirectional stuff 399 328 400 switch((*i)->type){ 329 401 case DATA: 330 402 memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size); 331 mem +=(*i)->size;332 tempsize +=(*i)->size;403 mem += (*i)->size; 404 tempsize += (*i)->size; 333 405 break; 334 406 case STRING: 335 407 memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) ); 336 mem +=sizeof(size_t);408 mem += sizeof(size_t); 337 409 const char *data = ( ( *(std::string *) (*i)->var).c_str()); 338 410 memcpy( mem, (void*)data, (*i)->size); 339 411 COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl; 340 mem +=(*i)->size;341 tempsize +=(*i)->size + sizeof(size_t);412 mem += (*i)->size; 413 tempsize += (*i)->size + sizeof(size_t); 342 414 break; 343 415 } … … 354 426 * @return true/false 355 427 */ 356 bool Synchronisable::updateData(uint8_t*& mem, int mode, bool forceCallback){428 bool Synchronisable::updateData(uint8_t*& mem, uint8_t mode, bool forceCallback){ 357 429 if(mode==0x0) 358 430 mode=state_; 359 431 std::list<synchronisableVariable *>::iterator i; 432 //assert(objectMode_!=0x0); 433 //assert( (mode ^ objectMode_) != 0); 360 434 if(syncList->empty()){ 361 435 COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl; … … 367 441 synchronisableHeader *syncHeader = (synchronisableHeader *)mem; 368 442 assert(syncHeader->objectID==this->objectID); 369 // assert(syncHeader->creatorID==this->creatorID); 443 assert(syncHeader->creatorID==this->creatorID); 444 assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ? 370 445 if(syncHeader->dataAvailable==false){ 371 mem +=syncHeader->size;446 mem += syncHeader->size; 372 447 return true; 373 448 } 374 449 375 mem +=sizeof(synchronisableHeader);450 mem += sizeof(synchronisableHeader); 376 451 // stop extract header 377 assert(this->objectID==syncHeader->objectID);378 // assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?379 452 380 453 COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl; … … 382 455 if( ((*i)->mode ^ mode) == 0 ){ 383 456 COUT(5) << "synchronisable: not updating variable " << std::endl; 457 // if we have a forcecallback then do the callback 384 458 continue; // this variable should only be set 385 459 } 386 460 COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl; 387 461 bool callback=false; 462 bool master=false; 463 464 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 465 { 466 uint8_t refNr = *(uint8_t *)mem; 467 if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \ 468 ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) ) 469 { // MASTER 470 master=true; 471 if( refNr != (*i)->varReference || ( memcmp((*i)->var, (*i)->varBuffer, (*i)->size) != 0 ) ) 472 { // DISCARD data 473 if( (*i)->type == DATA ) 474 { 475 mem += sizeof((*i)->varReference) + (*i)->size; 476 } 477 else //STRING 478 { 479 mem += sizeof(size_t) + *(size_t *)mem; 480 } 481 if( forceCallback && (*i)->callback) 482 (*i)->callback->call(); 483 continue; 484 }//otherwise everything is ok and we update the value 485 } 486 else // SLAVE 487 { 488 if( (*i)->varReference == refNr ){ 489 //discard data because it's outdated or not different to what we've got 490 if( (*i)->type == DATA ) 491 { 492 mem += sizeof((*i)->varReference) + (*i)->size; 493 } 494 else //STRING 495 { 496 mem += sizeof(size_t) + *(size_t *)mem; 497 } 498 if( forceCallback && (*i)->callback) 499 (*i)->callback->call(); 500 continue; 501 } 502 else 503 (*i)->varReference = refNr; //copy the reference value for this variable 504 } 505 mem += sizeof((*i)->varReference); 506 } 507 388 508 switch((*i)->type){ 389 509 case DATA: 390 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional)510 if((*i)->callback) // check whether this variable changed (but only if callback was set) 391 511 { 392 if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \ 393 ( mode == 0x2 && (*i)->mode == direction::clientMaster ) ) // if true we are master on this variable 394 { 395 uint8_t refNr = *(uint8_t *)mem; 396 if( refNr != (*i)->varReference ) 397 { 398 mem += sizeof((*i)->varReference) + (*i)->size; // the reference for this variable is not recent, discard data 399 break; 400 } 401 } 402 else //we are slave for this variable 403 { 404 (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable 405 } 406 mem += sizeof((*i)->varReference); 512 if(memcmp((*i)->var, mem, (*i)->size) != 0) 513 callback=true; 407 514 } 408 if((*i)->callback) // check whether this variable changed (but only if callback was set) 409 if(strncmp((char *)(*i)->var, (char *)mem, (*i)->size)!=0) 410 callback=true; 411 memcpy((void*)(*i)->var, mem, (*i)->size); 412 mem+=(*i)->size; 515 if( master ) 516 { 517 if( callback || memcmp((*i)->var, mem, (*i)->size) != 0 ) 518 //value changed, so set the buffer to the new value 519 memcpy((*i)->varBuffer, mem, (*i)->size); 520 } 521 memcpy((*i)->var, mem, (*i)->size); 522 mem += (*i)->size; 413 523 break; 414 524 case STRING: 415 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 525 (*i)->size = *(size_t *)mem; 526 mem += sizeof(size_t); 527 528 if( (*i)->callback) // check whether this string changed 529 if( *static_cast<std::string*>((*i)->var) != std::string((char *)mem) ) 530 callback=true; 531 if( master ) 416 532 { 417 if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \ 418 ( mode == 0x2 && (*i)->mode == direction::clientMaster ) ) // if true we are master for this variable 419 { 420 uint8_t refNr = *(uint8_t *)mem; 421 mem += sizeof( (*i)->varReference ); 422 if( refNr != (*i)->varReference ){ 423 mem += sizeof(size_t) + *(size_t *)mem; // the reference for this variable is not recent, discard data 424 break; 425 } 426 } 427 else //we are slave for this variable 428 { 429 (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable 430 } 431 mem += sizeof( (*i)->varReference ); 533 if( callback || *static_cast<std::string*>((*i)->var) != std::string((char *)mem) ) 534 //string changed. set the buffer to the new one 535 *static_cast<std::string*>((*i)->varBuffer)=*static_cast<std::string*>( (void*)(mem+sizeof(size_t)) ); 432 536 } 433 (*i)->size = *(size_t *)mem; 434 COUT(5) << "string size: " << (*i)->size << std::endl; 435 mem += sizeof(size_t); 436 if((*i)->callback) // check whether this string changed 437 if( *(std::string *)((*i)->var) != std::string((char *)mem) ) 438 callback=true; 537 439 538 *((std::string *)((*i)->var)) = std::string((const char*)mem); 440 539 COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl; … … 446 545 (*i)->callback->call(); 447 546 } 547 assert(mem == data+syncHeader->size); 448 548 return true; 449 549 } … … 455 555 * @return amount of bytes 456 556 */ 457 uint32_t Synchronisable::getSize(unsigned int id, int mode){ 458 if(!doSync(id)) 459 return 0; 557 uint32_t Synchronisable::getSize(unsigned int id, uint8_t mode){ 460 558 int tsize=sizeof(synchronisableHeader); 461 559 if(mode==0x0) 462 560 mode=state_; 561 if(!doSync(id, mode)) 562 return 0; 463 563 std::list<synchronisableVariable *>::iterator i; 464 564 for(i=syncList->begin(); i!=syncList->end(); i++){ … … 489 589 * @return true/false 490 590 */ 491 bool Synchronisable::doSync(unsigned int id){ 492 return ( (objectMode_&state_)!=0 && (!syncList->empty() ) ); 591 bool Synchronisable::doSync(unsigned int id, uint8_t mode){ 592 if(mode==0x0) 593 mode=state_; 594 return ( (objectMode_&mode)!=0 && (!syncList->empty() ) ); 493 595 } 494 596 495 597 bool Synchronisable::doSelection(unsigned int id){ 496 return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0); 598 return true; //TODO: change this 599 //return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0); 497 600 } 498 601 … … 510 613 /** 511 614 * This function sets the synchronisation mode of the object 615 * If set to 0x0 variables will not be synchronised at all 512 616 * If set to 0x1 variables will only be synchronised to the client 513 617 * If set to 0x2 variables will only be synchronised to the server … … 515 619 * @param mode same as in registerVar 516 620 */ 517 void Synchronisable::setObjectMode( int mode){621 void Synchronisable::setObjectMode(uint8_t mode){ 518 622 assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3); 519 623 objectMode_=mode; -
code/trunk/src/network/Synchronisable.h
r2087 r2171 42 42 43 43 #define REGISTERDATA(varname, ...) \ 44 registerVar ((void*)&varname, sizeof(varname), network::DATA, __VA_ARGS__)44 registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__) 45 45 #define REGISTERSTRING(stringname, ...) \ 46 registerVar (&stringname, stringname.length()+1, network::STRING, __VA_ARGS__)46 registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__) 47 47 48 namespace network48 namespace orxonox 49 49 { 50 50 static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1; … … 62 62 namespace syncmode{ 63 63 enum mode{ 64 on e=0,64 once=0, 65 65 always=1 66 66 }; … … 81 81 82 82 struct _NetworkExport synchronisableVariable{ 83 unsigned int size;84 int mode; // this determines in which direction the variable gets synchronised83 size_t size; 84 uint8_t mode; // this determines in which direction the variable gets synchronised 85 85 void *var; 86 86 variableType type; … … 95 95 * @author Oliver Scheuss 96 96 */ 97 class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{97 class _NetworkExport Synchronisable : virtual public OrxonoxClass{ 98 98 public: 99 99 friend class packet::Gamestate; 100 friend class GamestateClient; 101 friend class Server; 100 // friend class Server; 102 101 virtual ~Synchronisable(); 103 102 … … 106 105 static void setClient(bool b); 107 106 108 static Synchronisable *fabricate(uint8_t*& mem, int mode=0x0);107 static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0); 109 108 static bool deleteObject(unsigned int objectID); 110 109 static Synchronisable *getSynchronisable(unsigned int objectID); … … 115 114 inline unsigned int getClassID(){return classID;} 116 115 protected: 117 Synchronisable(orxonox::BaseObject* creator); 118 void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0); 119 void setObjectMode(int mode); 116 Synchronisable(BaseObject* creator); 117 void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0); 118 void unregisterVariable(void *var); 119 void setObjectMode(uint8_t mode); 120 120 void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; } 121 121 122 122 123 123 private: 124 bool getData(uint8_t*& men, unsigned int id, int mode=0x0);125 uint32_t getSize(unsigned int id, int mode=0x0);126 bool updateData(uint8_t*& mem, int mode=0x0, bool forceCallback=false);124 bool getData(uint8_t*& men, unsigned int id, uint8_t mode=0x0); 125 uint32_t getSize(unsigned int id, uint8_t mode=0x0); 126 bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false); 127 127 bool isMyData(uint8_t* mem); 128 128 bool doSelection(unsigned int id); 129 bool doSync(unsigned int id );129 bool doSync(unsigned int id, uint8_t mode=0x0); 130 130 131 131 unsigned int objectID; … … 134 134 135 135 std::list<synchronisableVariable *> *syncList; 136 static int state_; // detemines wheter we are server (default) or client136 static uint8_t state_; // detemines wheter we are server (default) or client 137 137 bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server) 138 138 unsigned int objectFrequency_; -
code/trunk/src/network/packet/Acknowledgement.cc
r1907 r2171 33 33 #include "core/CoreIncludes.h" 34 34 35 namespace network{35 namespace orxonox { 36 36 namespace packet { 37 37 38 38 #define PACKET_FLAGS_ACK 0 39 39 #define _PACKETID 0 40 #define _ACKID _PACKETID + sizeof( network::packet::ENUM::Type)40 #define _ACKID _PACKETID + sizeof(packet::ENUM::Type) 41 41 42 42 Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID ) … … 74 74 75 75 } //namespace packet 76 } //namespace network76 } //namespace orxonox -
code/trunk/src/network/packet/Acknowledgement.h
r2087 r2171 33 33 34 34 35 namespace network{35 namespace orxonox { 36 36 namespace packet { 37 37 /** … … 53 53 54 54 } //namespace packet 55 } //namespace network55 } //namespace orxonox 56 56 57 57 #endif -
code/trunk/src/network/packet/Chat.cc
r1907 r2171 31 31 #include "network/Host.h" 32 32 33 namespace network{33 namespace orxonox { 34 34 namespace packet { 35 35 … … 77 77 78 78 } //namespace packet 79 } //namespace network79 } //namespace orxonox -
code/trunk/src/network/packet/Chat.h
r2087 r2171 10 10 #include "Packet.h" 11 11 12 namespace network{12 namespace orxonox { 13 13 namespace packet { 14 14 /** … … 33 33 34 34 } //namespace packet 35 } //namespace network35 } //namespace orxonox 36 36 37 37 #endif -
code/trunk/src/network/packet/ClassID.cc
r1907 r2171 34 34 #include <assert.h> 35 35 36 namespace network{36 namespace orxonox { 37 37 namespace packet { 38 38 … … 68 68 69 69 unsigned int ClassID::getSize() const{ 70 return sizeof( network::packet::ENUM::Type) + 2*sizeof(uint32_t) + classNameLength_;70 return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t) + classNameLength_; 71 71 } 72 72 73 73 bool ClassID::process(){ 74 74 COUT(3) << "processing classid: " << getClassID() << " name: " << (const char*)(data_+_CLASSNAME) << std::endl; 75 orxonox::Identifier *id=ClassByID( std::string((const char*)(data_+_CLASSNAME) ));75 Identifier *id=ClassByID( std::string((const char*)(data_+_CLASSNAME) )); 76 76 if(id==NULL) 77 77 return false; … … 86 86 87 87 } //namespace packet 88 }//namespace network88 }//namespace orxonox -
code/trunk/src/network/packet/ClassID.h
r2087 r2171 35 35 #include "Packet.h" 36 36 37 namespace network{37 namespace orxonox { 38 38 namespace packet { 39 39 … … 59 59 60 60 } //namespace packet 61 } //namespace network61 } //namespace orxonox 62 62 63 63 #endif -
code/trunk/src/network/packet/DeleteObjects.cc
r1907 r2171 34 34 #include <assert.h> 35 35 36 namespace network{36 namespace orxonox { 37 37 namespace packet { 38 38 … … 95 95 96 96 } //namespace packet 97 } //namespace network97 } //namespace orxonox -
code/trunk/src/network/packet/DeleteObjects.h
r2087 r2171 34 34 35 35 36 namespace network{36 namespace orxonox { 37 37 namespace packet { 38 38 /** … … 55 55 56 56 } //namespace packet 57 } //namespace network57 } //namespace orxonox 58 58 59 59 #endif -
code/trunk/src/network/packet/Gamestate.cc
r2087 r2171 38 38 39 39 40 namespace network{40 namespace orxonox { 41 41 42 42 namespace packet { … … 71 71 } 72 72 73 bool Gamestate::collectData(int id, int mode)74 { 75 int tempsize=0, currentsize=0;73 bool Gamestate::collectData(int id, uint8_t mode) 74 { 75 unsigned int tempsize=0, currentsize=0; 76 76 assert(data_==0); 77 int size = calcGamestateSize(id, mode);77 unsigned int size = calcGamestateSize(id, mode); 78 78 79 79 COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl; … … 86 86 } 87 87 88 #ifndef NDEBUG89 std::list<Synchronisable*> slist;90 std::list<Synchronisable*>::iterator iit;91 #endif92 88 //start collect data synchronisable by synchronisable 93 89 uint8_t *mem=data_; 94 90 mem+=sizeof(GamestateHeader); 95 orxonox::ObjectList<Synchronisable>::iterator it;96 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){91 ObjectList<Synchronisable>::iterator it; 92 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ 97 93 tempsize=it->getSize(id, mode); 98 94 99 95 if(currentsize+tempsize > size){ 96 assert(0); // if we don't use multithreading this part shouldn't be neccessary 100 97 // start allocate additional memory 101 98 COUT(3) << "G.St.Man: need additional memory" << std::endl; 102 orxonox::ObjectList<Synchronisable>::iterator temp = it;99 ObjectList<Synchronisable>::iterator temp = it; 103 100 int addsize=tempsize; 104 101 while(++temp) … … 110 107 }// stop allocate additional memory 111 108 112 #ifndef NDEBUG113 for(iit=slist.begin(); iit!=slist.end(); iit++)114 assert((*iit)!=*it);115 slist.push_back(*it);116 #endif117 109 118 110 //if(it->doSelection(id)) … … 127 119 //start write gamestate header 128 120 HEADER->packetType = ENUM::Gamestate; 129 assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);130 121 HEADER->datasize = currentsize; 131 122 HEADER->id = id; … … 140 131 } 141 132 142 bool Gamestate::spreadData( int mode)133 bool Gamestate::spreadData(uint8_t mode) 143 134 { 144 135 assert(data_); … … 147 138 uint8_t *mem=data_+sizeof(GamestateHeader); 148 139 // get the start of the Synchronisable list 149 // orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();140 //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin(); 150 141 Synchronisable *s; 151 142 … … 163 154 bool b = s->updateData(mem, mode); 164 155 assert(b); 165 //if(!s->updateData(mem, mode))166 //return false;167 156 } 168 157 } … … 367 356 assert(it->second->objectID==oldobjectheader->objectID); 368 357 *newobjectheader = *oldobjectheader; 369 objectOffset=sizeof( uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader358 objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader 370 359 if(it->second->doSelection(HEADER->id)){ 371 newobjectheader->dataAvailable=true; //TODO: probably not neccessary 372 while(objectOffset<objectsize){ 373 *(newdata + objectOffset)=*(origdata + objectOffset); // copy the data 374 objectOffset++; 375 } 360 assert(newobjectheader->dataAvailable==true); 361 memcpy(newdata+objectOffset, origdata+objectOffset, objectsize-objectOffset); 376 362 }else{ 377 363 newobjectheader->dataAvailable=false; 378 while(objectOffset<objectsize){ 379 *(newdata+objectOffset)=0; // set to 0 380 objectOffset++; 381 } 364 memset(newdata+objectOffset, 0, objectsize-objectOffset); 382 365 assert(objectOffset==objectsize); 383 366 } … … 565 548 566 549 567 unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)568 { 569 int size=0;550 unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode) 551 { 552 unsigned int size=0; 570 553 // get the start of the Synchronisable list 571 orxonox::ObjectList<Synchronisable>::iterator it;554 ObjectList<Synchronisable>::iterator it; 572 555 // get total size of gamestate 573 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it)556 for(it = ObjectList<Synchronisable>::begin(); it; ++it) 574 557 size+=it->getSize(id, mode); // size of the actual data of the synchronisable 575 558 // size+=sizeof(GamestateHeader); … … 582 565 * @return iterator pointing to the next object in the list 583 566 */ 584 void Gamestate::removeObject( orxonox::ObjectList<Synchronisable>::iterator &it) {585 orxonox::ObjectList<Synchronisable>::iterator temp=it;567 void Gamestate::removeObject(ObjectList<Synchronisable>::iterator &it) { 568 ObjectList<Synchronisable>::iterator temp=it; 586 569 ++it; 587 570 delete *temp; -
code/trunk/src/network/packet/Gamestate.h
r2087 r2171 40 40 #endif 41 41 42 namespace network{42 namespace orxonox { 43 43 44 44 namespace packet { … … 69 69 ~Gamestate(); 70 70 71 bool collectData(int id, int mode=0x0);72 bool spreadData( int mode=0x0);71 bool collectData(int id, uint8_t mode=0x0); 72 bool spreadData( uint8_t mode=0x0); 73 73 int getID(); 74 74 bool isDiffed(); … … 90 90 bool operator ==(packet::Gamestate gs); 91 91 private: 92 unsigned int calcGamestateSize(unsigned int id, int mode=0x0);93 void removeObject( orxonox::ObjectListIterator<Synchronisable> &it);92 unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0); 93 void removeObject(ObjectListIterator<Synchronisable> &it); 94 94 std::map<unsigned int, Synchronisable*> dataMap_; 95 95 }; -
code/trunk/src/network/packet/Packet.cc
r2087 r2171 46 46 #include "core/CoreIncludes.h" 47 47 48 namespace network{48 namespace orxonox{ 49 49 50 50 namespace packet{ … … 53 53 #define _PACKETID 0 54 54 55 std::map<ENetPacket *, Packet *> Packet::packetMap_; 55 std::map<size_t, Packet *> Packet::packetMap_; 56 boost::recursive_mutex Packet::packetMap_mutex; 56 57 57 58 Packet::Packet(){ … … 128 129 return false; 129 130 } 131 // Assures we don't create a packet and destroy it right after in another thread 132 // without having a reference in the packetMap_ 133 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex); 130 134 // We deliver ENet the data address so that it doesn't memcpy everything again. 131 135 // --> We have to delete data_ ourselves! … … 134 138 // Add the packet to a global list so we can access it again once enet calls our 135 139 // deletePacket method. We can of course only give a one argument function to the ENet C library. 136 packetMap_[ enetPacket_] = this;140 packetMap_[(size_t)(void*)enetPacket_] = this; 137 141 } 138 142 #ifndef NDEBUG … … 153 157 // ENetPacket *temp = enetPacket_; 154 158 // enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet 155 network::Host::addPacket( enetPacket_, clientID_);159 Host::addPacket( enetPacket_, clientID_); 156 160 return true; 157 161 } … … 207 211 */ 208 212 void Packet::deletePacket(ENetPacket *enetPacket){ 213 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex); 209 214 // Get our Packet from a gloabal map with all Packets created in the send() method of Packet. 210 std::map< ENetPacket*, Packet*>::iterator it = packetMap_.find(enetPacket);215 std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket); 211 216 assert(it != packetMap_.end()); 212 217 // Make sure we don't delete it again in the destructor 213 218 it->second->enetPacket_ = 0; 214 219 delete it->second; 215 //packetMap_.erase(it);220 packetMap_.erase(it); 216 221 COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl; 217 222 } … … 219 224 } // namespace packet 220 225 221 } // namespace network222 226 } // namespace orxonox 227 -
code/trunk/src/network/packet/Packet.h
r2087 r2171 29 29 #define NETWORKPACKET_H 30 30 31 #include " ../NetworkPrereqs.h"31 #include "network/NetworkPrereqs.h" 32 32 33 33 #include <map> 34 34 #include <enet/enet.h> 35 #include <boost/thread/recursive_mutex.hpp> 35 36 36 37 #include "util/Integers.h" 37 38 38 namespace network{39 namespace orxonox { 39 40 40 41 namespace packet{ … … 92 93 bool bDataENetAllocated_; 93 94 private: 94 static std::map<ENetPacket *, Packet *> packetMap_; 95 static std::map<size_t, Packet *> packetMap_; 96 //! Static mutex for any packetMap_ access 97 static boost::recursive_mutex packetMap_mutex; 95 98 ENetPacket *enetPacket_; 96 99 }; … … 98 101 } //namespace packet 99 102 100 } //namespace network103 } //namespace orxonox 101 104 102 105 #endif -
code/trunk/src/network/packet/Welcome.cc
r1907 r2171 36 36 #include <assert.h> 37 37 38 namespace network{38 namespace orxonox { 39 39 namespace packet { 40 40 … … 70 70 71 71 unsigned int Welcome::getSize() const{ 72 return sizeof( network::packet::ENUM::Type) + 2*sizeof(uint32_t);72 return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t); 73 73 } 74 74 … … 87 87 88 88 } //namespace packet 89 }//namespace network89 }//namespace orxonox -
code/trunk/src/network/packet/Welcome.h
r2087 r2171 33 33 #include "Packet.h" 34 34 35 namespace network{35 namespace orxonox { 36 36 namespace packet { 37 37 … … 54 54 55 55 } //namespace packet 56 } //namespace network56 } //namespace orxonox 57 57 58 58 #endif
Note: See TracChangeset
for help on using the changeset viewer.