Changeset 2532
- Timestamp:
- Dec 23, 2008, 11:15:09 PM (16 years ago)
- Location:
- code/branches/bugger/src/network
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/bugger/src/network/GamestateManager.cc
r2531 r2532 57 57 GamestateManager::GamestateManager() { 58 58 id_=0; 59 trafficControl_ = new TrafficControl(); 59 60 } 60 61 61 62 GamestateManager::~GamestateManager() { 63 delete trafficControl_; 62 64 } 63 65 … … 185 187 } 186 188 temp->setGamestateID(gamestateID); 189 TrafficControl::processAck(clientID, gamestateID); 187 190 return true; 188 191 } -
code/branches/bugger/src/network/GamestateManager.h
r2171 r2532 43 43 #include "NetworkPrereqs.h" 44 44 #include "GamestateHandler.h" 45 #include "TrafficControl.h" 45 46 #include <map> 46 47 … … 89 90 std::map<unsigned int, packet::Gamestate*> gamestateQueue; 90 91 packet::Gamestate *reference; 92 TrafficControl *trafficControl_; 91 93 unsigned int id_; 92 94 }; -
code/branches/bugger/src/network/TrafficControl.cc
r2531 r2532 30 30 31 31 #include "synchronisable/Synchronisable.h" 32 #include "core/ConfigValueIncludes.h" 32 33 33 34 #include <cassert> … … 67 68 TrafficControl::TrafficControl() 68 69 { 70 RegisterRootObject(TrafficControl); 69 71 assert(instance_==0); 70 72 instance_=this; 71 targetSize = 1000;//5000bytes 73 // targetSize = 2500;//5000bytes 74 SetConfigValue ( targetSize, 28000./25. ); 72 75 } 73 76 … … 127 130 return; 128 131 } 129 130 void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID) 132 133 TrafficControl *TrafficControl::getInstance() 134 { 135 assert(instance_); 136 return instance_; 137 } 138 139 void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID) 131 140 { 132 141 std::list<obj>::iterator itvec; // iterator to iterate through the acked objects … … 141 150 if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists 142 151 { 143 clientListPerm_[clientID][(*itvec).objID].objID = gamestateID; 152 clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID; 153 clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back 144 154 } 145 155 else 146 156 { 157 assert(0); 147 158 clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID; 148 159 clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID; … … 225 236 // for(itvec = list.begin(); itvec!=list.end(), itvec++) 226 237 // { 227 // ittempgs.insert(itvec); 238 // ittempgs.insert(itvec);static 228 239 // } 229 240 } … … 236 247 { 237 248 unsigned int size=0; 238 std::list<obj>::iterator itvec ;249 std::list<obj>::iterator itvec, ittemp; 239 250 assert(!list->empty()); 240 itvec = list->begin(); 241 for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++) 251 for(itvec = list->begin(); itvec != list->end();) 242 252 { 243 253 assert( (*itvec).objSize < 1000); 244 if ( size + (*itvec).objSize < targetsize ) 245 { 254 // COUT(0) << "==targetsize== " << targetsize << endl; 255 if ( ( size + (*itvec).objSize ) < targetsize ) 256 { 257 // COUT(0) << "no cut" << endl; 246 258 size += (*itvec).objSize;//objSize is given in bytes 259 ++itvec; 247 260 } 248 261 else 249 262 { 250 clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET; 263 // COUT(0) << "cut" << endl; 264 clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative 265 // ittemp = itvec; 251 266 list->erase(itvec++); 252 } 267 // itvec = ittemp; 268 } 269 // printList(list, currentClientID); 253 270 } 254 271 assert(!list->empty()); … … 339 356 340 357 //now we check, that the creator of an object always exists on a client 341 printList(list, clientID);358 // printList(list, clientID); 342 359 std::list<obj>::iterator itcreator; 343 360 for(itvec = list->begin(); itvec != list->end(); itvec++) … … 348 365 //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 349 366 cut(list, targetSize); 350 printList(list, clientID);367 // printList(list, clientID); 351 368 //diese Funktion updateClientList muss noch gemacht werden 352 369 updateClientListTemp(list); … … 359 376 COUT(0) << "=========== Objectlist ===========" << endl; 360 377 for( it=list->begin(); it!=list->end(); it++) 361 COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << endl;378 COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl; 362 379 } 363 380 -
code/branches/bugger/src/network/TrafficControl.h
r2531 r2532 37 37 #include <algorithm> 38 38 #include "util/Integers.h" 39 #include "core/OrxonoxClass.h" 39 40 40 41 namespace orxonox { … … 52 53 uint32_t objDiffGS;//difference between current and latest GameState 53 54 uint32_t objSize; 54 unsignedint objValuePerm;55 unsignedint objValueSched;55 int objValuePerm; 56 int objValueSched; 56 57 objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched); 57 58 objInfo(); … … 78 79 * 79 80 */ 80 class TrafficControl {81 class TrafficControl : public OrxonoxClass{ 81 82 private: 82 83 … … 139 140 */ 140 141 void evaluateList(unsigned int clientID, std::list<obj> *list);//done 142 void ack(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client 141 143 142 144 protected: … … 152 154 *Elements of struct i are therefore: *list[i].objID 153 155 */ 156 static TrafficControl *getInstance(); 154 157 void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>* list); //gets a pointer to the list (containing objectIDs) and sorts it 155 158 //done 156 void processAck(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client 159 static void processAck(unsigned int clientID, unsigned int gamestateID) 160 { return instance_->ack(clientID, gamestateID); } 157 161 //done 158 162 void deleteObject(unsigned int objectID); // this function gets called when an object has been deleted (in order to clean up lists and maps) -
code/branches/bugger/src/network/packet/Gamestate.cc
r2531 r2532 50 50 51 51 #define PACKET_FLAG_GAMESTATE ENET_PACKET_FLAG_RELIABLE 52 53 TrafficControl Gamestate::trafficControl_;54 52 55 53 Gamestate::Gamestate() … … 362 360 363 361 //call TrafficControl 364 trafficControl_.processObjectList( clientID, HEADER->id, &dataMap_ );362 TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ ); 365 363 366 364 //copy in the zeros -
code/branches/bugger/src/network/packet/Gamestate.h
r2531 r2532 95 95 void removeObject(ObjectListIterator<Synchronisable> &it); 96 96 std::list<obj> dataMap_; 97 static TrafficControltrafficControl_;97 // static TrafficControl *trafficControl_; 98 98 }; 99 99
Note: See TracChangeset
for help on using the changeset viewer.