Changeset 2351 for code/branches/network/src/network/TrafficControl.cc
- Timestamp:
- Dec 7, 2008, 10:57:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/TrafficControl.cc
r2348 r2351 31 31 #include <cassert> 32 32 #include <boost/bind.hpp> 33 #include "Synchronisable.h"34 #include "ClientInformation.h"35 33 36 34 namespace network { … … 86 84 assert(clientListPerm_[clientID].find(j.objID) != clientListPerm_[clientID].end()); // make sure the object j is in the client list 87 85 88 return clientListPerm_[clientID][i.objID].objID < clientListPerm_[clientID][j.objID].objID; 86 int prio1 = clientListPerm_[clientID][i.objID].objValuePerm + clientListPerm_[clientID][i.objID].objValueSched; 87 int prio2 = clientListPerm_[clientID][j.objID].objValuePerm + clientListPerm_[clientID][j.objID].objValueSched; 88 // NOTE: smaller priority is better 89 return prio1 < prio2; 89 90 } 90 91 91 92 92 std::vector<obj>*TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list)93 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list) 93 94 { 94 copiedVector = *list;95 // copiedVector = *list; 95 96 currentClientID=clientID; 96 97 currentGamestateID=gamestateID; 97 98 evaluateList(clientID, list); 98 99 //list hatte vorher ja vielmehr elemente, nach zuweisung nicht mehr... speicherplatz?? 99 *list=copiedVector;100 // *list=copiedVector; 100 101 //später wird copiedVector ja überschrieben, ist das ein problem für list-dh. für gamestatemanager? 101 return list;102 return; 102 103 } 103 104 … … 212 213 std::vector<obj>::iterator itvec; 213 214 itvec = list->begin(); 214 // unsigned int i=0;215 215 for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++) 216 // while(size<targetsize && (itvec!=list.end()))217 216 { 218 size = size + (*itvec).objSize;//objSize is given in bytes!?? 219 // i++; 220 // itvec = list.begin()+i; 217 if ( size + (*itvec).objSize < targetsize ) 218 { 219 size = size + (*itvec).objSize;//objSize is given in bytes 220 } 221 else 222 { 223 clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET; 224 list->erase(itvec++); 225 } 221 226 } 222 list->erase(itvec, list->end());223 227 } 224 228 … … 235 239 //compare listToProcess vs clientListPerm 236 240 //if listToProcess contains new Objects, add them to clientListPerm 237 std::map<unsigned int, objInfo>::iterator itproc;241 // std::map<unsigned int, objInfo>::iterator itproc; 238 242 std::vector<obj>::iterator itvec; 239 std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm;243 // std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm; 240 244 // std::map<unsigned int, objInfo>::iterator itpermobj; 241 unsigned int permprio;242 245 for( itvec=list->begin(); itvec != list->end(); itvec++) 243 246 { 244 itperm = clientListPerm_.find(clientID);247 // itperm = clientListPerm_.find(clientID); 245 248 if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() ) 246 249 { … … 306 309 // use boost bind here because we need to pass a memberfunction to stl sort 307 310 sort(list->begin(), list->end(), boost::bind(&TrafficControl::priodiffer, this, clientID, _1, _2) ); 308 //swappen aufgrund von creator oder ganz rausnehmen!? 311 312 //now we check, that the creator of an object always exists on a client 313 std::vector<obj>::iterator itcreator; 309 314 for(itvec = list->begin(); itvec != list->end(); itvec++) 310 315 { 311 //TODO: TODO TODO TODO 312 itproc = (listToProcess_).find((*itvec).objID); 313 if((*itproc).second.objCreatorID) 314 { 315 //vor dem child in copiedvector einfügen, wie? 316 copiedVector.insert(copiedVector.find((*itproc).first),(*itproc).second.objCreatorID); 317 } 318 else continue; 316 if ( (*itvec).objCreatorID != OBJECTID_UNKNOWN ) 317 { 318 if( clientListPerm_[clientID][(*itvec).objCreatorID].objCurGS != GAMESTATEID_INITIAL ) 319 continue; 320 for( itcreator = list->begin(); itcreator != list->end(); itcreator++) 321 { 322 if ( (*itcreator).objID == (*itvec).objCreatorID ) 323 break; 324 } 325 // if the creator is before the object everything is fine 326 if( itcreator < itvec ) 327 continue; 328 // otherwise insert the creator right before our object and delete it at the old position 329 list->insert(itvec, *itcreator); 330 list->erase(itcreator); 331 } 319 332 } 320 333 //end of sorting 321 334 //now the cutting, work the same obj out in processobjectlist and copiedvector, compression rate muss noch festgelegt werden. 322 cut( copiedVector,targetSize);335 cut(list, targetSize); 323 336 //diese Funktion updateClientList muss noch gemacht werden 324 337 updateClientListTemp(list); 325 338 //end of sorting 326 339 } 327 328 340 329 341
Note: See TracChangeset
for help on using the changeset viewer.