Changeset 3083 for code/branches/netp3/src/network
- Timestamp:
- May 26, 2009, 8:11:37 PM (15 years ago)
- Location:
- code/branches/netp3/src/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3/src/network/Client.cc
r3066 r3083 149 149 COUT(4) << "popping partial gamestate: " << std::endl; 150 150 packet::Gamestate *gs = gamestate.getGamestate(); 151 assert(gs);151 //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now 152 152 if(gs){ 153 153 COUT(4) << "client tick: sending gs " << gs << std::endl; -
code/branches/netp3/src/network/TrafficControl.cc
r3043 r3083 121 121 122 122 123 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std:: vector<obj>& list)123 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list) 124 124 { 125 125 currentClientID=clientID; … … 137 137 void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID) 138 138 { 139 std:: vector<obj>::iterator itvec; // iterator to iterate through the acked objects139 std::list<obj>::iterator itvec; // iterator to iterate through the acked objects 140 140 141 141 //assertions to make sure the maps already exist … … 146 146 // shortcut for maps 147 147 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; 148 std::map<unsigned int, std:: vector<obj> >& objectListTemp = clientListTemp_[clientID];148 std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID]; 149 149 150 150 for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++) … … 187 187 * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp 188 188 */ 189 void TrafficControl::updateClientListTemp(std:: vector<obj>& list)190 { 191 clientListTemp_[currentClientID][currentGamestateID] = std:: vector<obj>(list);189 void TrafficControl::updateClientListTemp(std::list<obj>& list) 190 { 191 clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list); 192 192 } 193 193 … … 196 196 *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY) 197 197 */ 198 void TrafficControl::cut(std:: vector<obj>& list, unsigned int targetsize)198 void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize) 199 199 { 200 200 unsigned int size=0; 201 std:: vector<obj>::iterator itvec, ittemp;201 std::list<obj>::iterator itvec, ittemp; 202 202 assert(!list.empty()); 203 203 for(itvec = list.begin(); itvec != list.end();) … … 212 212 { 213 213 clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative 214 list.erase(itvec++); 214 list.erase(itvec, list.end()); 215 break; 215 216 } 216 217 // printList(list, currentClientID); … … 223 224 *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this. 224 225 */ 225 void TrafficControl::evaluateList(unsigned int clientID, std:: vector<obj>& list)226 void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list) 226 227 { 227 228 … … 230 231 //compare listToProcess vs clientListPerm 231 232 //if listToProcess contains new Objects, add them to clientListPerm 232 std:: vector<obj>::iterator itvec;233 std::list<obj>::iterator itvec; 233 234 234 235 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; … … 256 257 //sort copied list according to priorities 257 258 // use boost bind here because we need to pass a memberfunction to stl sort 258 sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 259 // sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 260 list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 261 259 262 // list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 260 263 261 264 //now we check, that the creator of an object always exists on a client 262 std:: vector<obj>::iterator itcreator;265 std::list<obj>::iterator itcreator; 263 266 for(itvec = list.begin(); itvec != list.end(); itvec++) 264 267 { … … 269 272 // printList(list, clientID); 270 273 cut(list, targetSize); 271 272 274 //now sort again after objDataOffset 273 sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 275 // sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 276 list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 274 277 } 275 278 //diese Funktion updateClientList muss noch gemacht werden … … 278 281 } 279 282 280 void TrafficControl::printList(std:: vector<obj>& list, unsigned int clientID)281 { 282 std:: vector<obj>::iterator it;283 void TrafficControl::printList(std::list<obj>& list, unsigned int clientID) 284 { 285 std::list<obj>::iterator it; 283 286 COUT(0) << "=========== Objectlist ===========" << endl; 284 287 for( it=list.begin(); it!=list.end(); it++) … … 286 289 } 287 290 288 void TrafficControl::fixCreatorDependencies(std:: vector<obj>::iterator it1, std::vector<obj>& list, unsigned int clientID)291 void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID) 289 292 { 290 293 if ( (*it1).objCreatorID == OBJECTID_UNKNOWN ) … … 292 295 if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL ) 293 296 return; 294 std:: vector<obj>::iterator it2, it3=it1;297 std::list<obj>::iterator it2, it3=it1; 295 298 for( it2 = ++it3; it2 != list.end(); it2++ ) 296 299 { -
code/branches/netp3/src/network/TrafficControl.h
r3015 r3083 32 32 33 33 #include <string> 34 #include < vector>34 #include <list> 35 35 #include <map> 36 36 #include <utility> … … 91 91 *temporary client list: contains client ids, gamestate ids and object ids (in this order) 92 92 */ 93 std::map<unsigned int, std::map<unsigned int, std:: vector<obj> > > clientListTemp_;93 std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_; 94 94 95 95 /**updateReferenceList … … 103 103 void insertinClientListPerm(unsigned int clientID, obj objinf); 104 104 105 void cut(std:: vector<obj>& list, unsigned int targetsize);106 void updateClientListTemp(std:: vector<obj>& list);//done105 void cut(std::list<obj>& list, unsigned int targetsize); 106 void updateClientListTemp(std::list<obj>& list);//done 107 107 /** 108 108 *evaluates Data given (list) and produces result(->Data to be updated) 109 109 */ 110 void evaluateList(unsigned int clientID, std:: vector<obj>& list);//done110 void evaluateList(unsigned int clientID, std::list<obj>& list);//done 111 111 void ack(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client 112 112 … … 130 130 void setConfigValues(); 131 131 static TrafficControl *getInstance(); 132 void processObjectList(unsigned int clientID, unsigned int gamestateID, std:: vector<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it132 void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it 133 133 static void processAck(unsigned int clientID, unsigned int gamestateID) 134 134 { return instance_->ack(clientID, gamestateID); } … … 137 137 bool prioritySort(uint32_t clientID, obj i, obj j); 138 138 bool dataSort(obj i, obj j); 139 void printList(std:: vector<obj>& list, unsigned int clientID);140 void fixCreatorDependencies(std:: vector<obj>::iterator it, std::vector<obj>& list, unsigned int clientID);139 void printList(std::list<obj>& list, unsigned int clientID); 140 void fixCreatorDependencies(std::list<obj>::iterator it, std::list<obj>& list, unsigned int clientID); 141 141 }; 142 142 -
code/branches/netp3/src/network/packet/Gamestate.cc
r3047 r3083 182 182 #ifndef NDEBUG 183 183 if(this->getID()%1000==0){ 184 std:: vector<uint32_t> v1;184 std::list<uint32_t> v1; 185 185 ObjectList<Synchronisable>::iterator it; 186 186 for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) { … … 194 194 } 195 195 else { 196 std:: vector<uint32_t>::iterator it2;196 std::list<uint32_t>::iterator it2; 197 197 for (it2 = v1.begin(); it2 != v1.end(); ++it2) { 198 198 if (it->getObjectID() == *it2) { … … 412 412 Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){ 413 413 assert(data_); 414 std:: vector<obj>::iterator it;414 std::list<obj>::iterator it; 415 415 416 416 // allocate memory for new data … … 434 434 435 435 //copy in the zeros 436 // std::list<obj>::iterator itt; 437 // COUT(0) << "myvector contains:"; 438 // for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ ) 439 // COUT(0) << " " << (*itt).objID; 440 // COUT(0) << endl; 436 441 for(it=dataVector_.begin(); it!=dataVector_.end();){ 437 442 SynchronisableHeader oldobjectheader(origdata); -
code/branches/netp3/src/network/packet/Gamestate.h
r3047 r3083 129 129 private: 130 130 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 131 std:: vector<obj> dataVector_;131 std::list<obj> dataVector_; 132 132 GamestateHeader* header_; 133 133 };
Note: See TracChangeset
for help on using the changeset viewer.