Changeset 2485 for code/branches/presentation/src/network
- Timestamp:
- Dec 16, 2008, 6:01:13 PM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/src/network/GamestateClient.cc
r2371 r2485 82 82 NetworkCallbackManager::callCallbacks(); 83 83 84 if (!processed) 85 return false; 84 if (!processed){ 85 sendAck(0); 86 return false; 87 } 86 88 //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs 87 89 tempGamestate_=NULL; -
code/branches/presentation/src/network/GamestateManager.cc
r2382 r2485 51 51 #include "synchronisable/Synchronisable.h" 52 52 #include "synchronisable/NetworkCallbackManager.h" 53 #include "packet/Acknowledgement.h" 53 54 54 55 namespace orxonox … … 172 173 unsigned int curid = temp->getGamestateID(); 173 174 174 if(gamestateID == 0){175 if(gamestateID == ACKID_NACK){ 175 176 temp->setGamestateID(GAMESTATEID_INITIAL); 176 177 return true; -
code/branches/presentation/src/network/TrafficControl.cc
r2436 r2485 36 36 37 37 namespace orxonox { 38 39 static const unsigned int SCHED_PRIORITY_OFFSET = -1;38 39 static const unsigned int SCHED_PRIORITY_OFFSET = (unsigned int)-1; 40 40 41 41 objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched) 42 { 43 objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched; 44 } 45 42 { 43 objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched; 44 } 45 46 46 objInfo::objInfo() 47 { 48 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0; 49 } 50 51 52 47 { 48 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0; 49 } 50 51 52 53 53 obj::obj() 54 { 55 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0; 54 { 55 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0; 56 56 } 57 57 obj::obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset ) … … 59 59 objID = ID; objCreatorID = creatorID; objSize = size; objDataOffset = offset; 60 60 } 61 61 62 62 /** 63 63 *Initializing protected members 64 64 */ 65 65 TrafficControl *TrafficControl::instance_=0; 66 66 67 67 /** 68 68 * @brief Constructor: assures that only one reference will be created and sets the pointer … … 75 75 this->setConfigValues(); 76 76 } 77 77 78 78 /** 79 79 * @brief Destructor: resets the instance pointer to 0 … … 93 93 SetConfigValue ( targetSize, 5000 ); 94 94 } 95 95 96 96 /** 97 97 * sort-algorithm for sorting the objectlist after priorities … … 102 102 assert(clientListPerm_[clientID].find(i.objID) != clientListPerm_[clientID].end()); // make sure the object i is in the client list 103 103 assert(clientListPerm_[clientID].find(j.objID) != clientListPerm_[clientID].end()); // make sure the object j is in the client list 104 104 105 105 int prio1 = clientListPerm_[clientID][i.objID].objValuePerm + clientListPerm_[clientID][i.objID].objValueSched; 106 106 int prio2 = clientListPerm_[clientID][j.objID].objValuePerm + clientListPerm_[clientID][j.objID].objValueSched; … … 118 118 } 119 119 120 120 121 121 122 122 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list) … … 128 128 return; 129 129 } 130 130 131 131 TrafficControl *TrafficControl::getInstance() 132 132 { … … 134 134 return instance_; 135 135 } 136 136 137 137 void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID) 138 138 { 139 139 std::list<obj>::iterator itvec; // iterator to iterate through the acked objects 140 140 141 141 //assertions to make sure the maps already exist 142 142 assert(clientListTemp_.find(clientID) != clientListTemp_.end() ); 143 143 assert(clientListPerm_.find(clientID) != clientListPerm_.end() ); 144 144 assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() ); 145 145 146 146 for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++) 147 147 { … … 173 173 */ 174 174 void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf) 175 { 175 { 176 176 std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs 177 177 // itperm = (clientListPerm_).find(clientID); … … 182 182 // permObjPrio_.insert(objid, objinf.objValuePerm); 183 183 } 184 184 185 185 /** 186 186 * updateClientListTemp 187 187 * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp 188 */ 188 */ 189 189 void TrafficControl::updateClientListTemp(std::list<obj> *list) 190 190 { … … 225 225 void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list) 226 226 { 227 227 228 228 //now the sorting 229 229 230 230 //compare listToProcess vs clientListPerm 231 231 //if listToProcess contains new Objects, add them to clientListPerm … … 248 248 } 249 249 //end compare listToProcess vs clientListPerm 250 250 251 251 if( bActive_ ) 252 252 { … … 254 254 // use boost bind here because we need to pass a memberfunction to stl sort 255 255 list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 256 256 257 257 //now we check, that the creator of an object always exists on a client 258 258 std::list<obj>::iterator itcreator; 259 259 for(itvec = list->begin(); itvec != list->end(); itvec++) 260 { 260 { 261 261 fixCreatorDependencies(itvec, list, clientID); 262 262 } 263 263 //end of sorting 264 //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 264 //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 265 265 // printList(list, clientID); 266 266 cut(list, targetSize); 267 267 268 268 //now sort again after objDataOffset 269 269 list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) ); … … 281 281 COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl; 282 282 } 283 283 284 284 void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID) 285 285 { … … 301 301 } 302 302 } 303 303 304 304 void TrafficControl::clientDisconnected(unsigned int clientID) 305 305 { -
code/branches/presentation/src/network/packet/Acknowledgement.h
r2171 r2485 32 32 #include "Packet.h" 33 33 34 const unsigned int ACKID_NACK = 0; 34 35 35 36 namespace orxonox { -
code/branches/presentation/src/network/packet/Gamestate.cc
r2476 r2485 31 31 #include "../synchronisable/Synchronisable.h" 32 32 #include "../TrafficControl.h" 33 #include "core/Core.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/Iterator.h" … … 151 152 if(!s) 152 153 { 153 Synchronisable::fabricate(mem, mode); 154 if (!Core::isMaster()) 155 Synchronisable::fabricate(mem, mode); 156 else 157 mem += objectheader->size; 154 158 // COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl; 155 159 // else … … 170 174 if (it->objectMode_ != 0x0) { 171 175 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl; 176 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl; 172 177 assert(false); 173 178 } … … 384 389 //call TrafficControl 385 390 TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ ); 386 391 387 392 //copy in the zeros 388 393 for(it=dataMap_.begin(); it!=dataMap_.end();){ 389 394 // if((*it).objSize==0) 390 395 // continue; 396 // if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this 397 // continue; // merged from objecthierarchy2, doesn't work anymore; TODO: change this 391 398 oldobjectheader = (synchronisableHeader*)origdata; 392 399 newobjectheader = (synchronisableHeader*)newdata; -
code/branches/presentation/src/network/packet/Packet.cc
r2171 r2485 129 129 return false; 130 130 } 131 // Assures we don't create a packet and destroy it right after in another thread132 // without having a reference in the packetMap_133 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);134 131 // We deliver ENet the data address so that it doesn't memcpy everything again. 135 132 // --> We have to delete data_ ourselves! … … 138 135 // Add the packet to a global list so we can access it again once enet calls our 139 136 // deletePacket method. We can of course only give a one argument function to the ENet C library. 140 packetMap_[(size_t)(void*)enetPacket_] = this; 137 { 138 // Assures we don't create a packet and destroy it right after in another thread 139 // without having a reference in the packetMap_ 140 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex); 141 packetMap_[(size_t)(void*)enetPacket_] = this; 142 } 141 143 } 142 144 #ifndef NDEBUG -
code/branches/presentation/src/network/packet/Welcome.cc
r2483 r2485 43 43 #define _CLIENTID _PACKETID + sizeof(ENUM::Type) 44 44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 45 45 46 46 Welcome::Welcome( uint32_t clientID, uint32_t shipID ) 47 47 : Packet() … … 74 74 75 75 bool Welcome::process(){ 76 uint32_t shipID,clientID;76 uint32_t clientID; 77 77 clientID = *(uint32_t *)(data_ + _CLIENTID ); 78 78 assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321); -
code/branches/presentation/src/network/synchronisable/Synchronisable.cc
r2482 r2485 119 119 if (it != objectMap_.end()) 120 120 objectMap_.erase(it); 121 121 122 122 //HACK HACK HACK HACK HACK HACK 123 123 // this hack ensures that childs of this object also get destroyed … … 166 166 167 167 Identifier* id = ClassByID(header->classID); 168 if (!id) 169 { 170 COUT(0) << "Assertion failed: id" << std::endl; 171 COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl; 172 abort(); 173 } 168 174 assert(id); 169 175 BaseObject* creator = 0; … … 253 259 254 260 /* void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){ 255 assert( mode== direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);261 assert( mode==variableDirection::toclient || mode==variableDirection::toserver || mode==variableDirection::serverMaster || mode==variableDirection::clientMaster); 256 262 // create temporary synch.Var struct 257 263 synchronisableVariable *temp = new synchronisableVariable; … … 261 267 temp->type = t; 262 268 temp->callback = cb; 263 if( ( mode & direction::bidirectional ) )269 if( ( mode & variableDirection::bidirectional ) ) 264 270 { 265 271 if(t!=STRING) … … 286 292 #endif 287 293 }*/ 288 294 289 295 290 296 /** … … 444 450 objectMode_=mode; 445 451 } 446 452 447 453 448 454 } -
code/branches/presentation/src/network/synchronisable/Synchronisable.h
r2459 r2485 61 61 }; 62 62 } 63 63 64 64 namespace priority{ 65 65 enum prio{ … … 100 100 static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; } 101 101 102 inline uint32_t getObjectID() {return objectID;}103 inline unsigned int getCreatorID() {return creatorID;}104 inline uint32_t getClassID() {return classID;}105 inline unsigned int getPriority() { return objectFrequency_;}102 inline uint32_t getObjectID() const {return objectID;} 103 inline unsigned int getCreatorID() const {return creatorID;} 104 inline uint32_t getClassID() const {return classID;} 105 inline unsigned int getPriority() const { return objectFrequency_;} 106 106 107 107 protected: … … 134 134 static std::queue<uint32_t> deletedObjects_; 135 135 }; 136 136 137 137 template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 138 138 { … … 158 158 // the variable has not been registered before 159 159 } 160 160 161 161 // ================= Specialisation declarations 162 162 template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
Note: See TracChangeset
for help on using the changeset viewer.