Changeset 2341 for code/branches/network
- Timestamp:
- Dec 4, 2008, 12:03:25 AM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/GamestateManager.cc
r2035 r2341 135 135 return 0; 136 136 gs = reference->doSelection(clientID); 137 // gs = new packet::Gamestate(*reference);138 // gs = new packet::Gamestate(*reference);139 137 // save the (undiffed) gamestate in the clients gamestate map 140 138 gamestateMap_[clientID].insert(std::pair<int, packet::Gamestate*>(gs->getID(), gs)); -
code/branches/network/src/network/TrafficControl.cc
r2340 r2341 46 46 assert(instance_=0); 47 47 instance_=this; 48 listToProcess_ = new std::map<unsigned int, objInfo>; 49 clientListPerm_ = new std::map<unsigned int,std::map<unsigned int, objInfo>>; 50 clientListTemp_ = new std::map std::map<unsigned int, std::map<unsigned int, std::vector<obj>>>; 51 permObjPrio_ = new std::map<unsigned int, unsigned int> ; 52 schedObjPrio_ = new std::map<unsigned int, unsigned int> schedObjPrio_; 53 copiedVector = new std::vector<obj>; 54 targetSize = 5000;//5000bytes 48 targetSize = 5000;//5000bytes 55 49 } 56 50 … … 74 68 bool TrafficControl::priodiffer(obj i, obj j) 75 69 { 76 map<unsigned int, objInfo>::iterator iti;77 map<unsigned int, objInfo>::iterator itj;78 iti=listToProcess_ ->find(i.objID);79 itj=listToProcess_ ->find(j.objID);70 std::map<unsigned int, objInfo>::iterator iti; 71 std::map<unsigned int, objInfo>::iterator itj; 72 iti=listToProcess_.find(i.objID); 73 itj=listToProcess_.find(j.objID); 80 74 return iti->second.objValuePerm < itj->second.objValuePerm; 81 75 } … … 90 84 evaluateList(list); 91 85 //list hatte vorher ja vielmehr elemente, nach zuweisung nicht mehr... speicherplatz?? 92 list=copiedVector;86 *list=copiedVector; 93 87 //später wird copiedVector ja überschrieben, ist das ein problem für list-dh. für gamestatemanager? 94 88 return list; … … 97 91 void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID) 98 92 { 99 map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm 100 map<unsigned int, objInfo>::iterator itpermoid;//iterator over objectid 101 map<unsigned int, std::map<unsigned int, obj>>::iterator ittemp;//iterator clientListTemp, iterates over clientIDs 102 map<unsigned int, unsigned int>::iterator ittempgs;//iterator that iterates over gsIDs of a client 103 vector<obj>::iterator itvec; 93 std::map<unsigned int, std::map<unsigned int, std::vector<objInfo> > >::iterator itperm;//iterator clientListPerm 94 std::map<unsigned int, std::vector<objInfo> >::iterator itpermObjectIDList;//iterator over objectid 95 std::vector<objInfo>::iterator itpermObjectID; 96 std::map<unsigned int, std::map<unsigned int, std::vector<obj> > >::iterator ittemp;//iterator clientListTemp, iterates over clientIDs 97 std::map<unsigned int, std::vector<obj> >::iterator ittempgs;//iterator that iterates over gsIDs of a client 98 std::vector<obj>::iterator itvec; 104 99 //following code helps to put clientListTemp infos into clientListPerm infos 105 ittemp = (clientListTemp_).find(clientID);106 assert(ittemp != clientListTemp_.end() ); //muss da nicht was anderes überprüft werden? 107 itperm = (clientListPerm_).find(clientID);100 ittemp = clientListTemp_.find(clientID); 101 assert(ittemp != clientListTemp_.end() ); //muss da nicht was anderes überprüft werden? -> nein 102 itperm = clientListPerm_.find(clientID); 108 103 assert(itperm != clientListPerm_.end() ); 109 ittempgs = (*ittemp).find(gamestateID); 110 assert( ittempgs != (*ittemp).end() );//gleiche frage wie vorher 111 for(itvec = *ittempgs.begin(); itvec = *ittempgs.end(); itvec++) 112 { 113 if(itpermoid = (*itperm).find(itvec.objID)) 114 { 115 if(gamestateID>(*itpermoid).second.objCurGS) 116 { 117 (*itpermoid).second.objCurGS = gamestateID; 118 } 119 else continue; 120 } 121 else 122 { 123 objInfo objinf = new objInfo; 124 objinf.objCurGS = gamestateID; 125 insertinClientListPerm(clientID, itvec.objID, objinf); 126 } 127 //entferne objekt aus temporärer liste 128 ittempgs.erase(itvec); 129 } 130 104 ittempgs = ittemp->second.find(gamestateID); 105 assert( ittempgs != ittemp->second.end() );//gleiche frage wie vorher -> nein 106 for(itvec = ittempgs->second.begin(); itvec != ittempgs->second.end(); itvec++) 107 { 108 bool alreadyExisting = false; 109 itpermObjectIDList = itperm->second.find(gamestateID); 110 assert(itpermObjectIDList != itperm->second.end()); 111 for (itpermObjectID = itpermObjectIDList->second.begin(); itpermObjectID != itpermObjectIDList->second.end(); itpermObjectID++ ) 112 { 113 if ( (*itpermObjectID).objID == (*itvec).objID) 114 { 115 (*itpermObjectID).objCurGS = gamestateID; 116 alreadyExisting = true; 117 break; 118 } 119 if ( !alreadyExisting ) 120 { 121 objInfo objinf; // TODO: is this initialisation complete ? 122 objinf.objCurGS = gamestateID; 123 objinf.objID = (*itvec).objID; 124 insertinClientListPerm(clientID, (*itvec).objID, objinf); 125 } 126 } 127 } 128 // remove temporary vector (with acked objects) from the map 129 ittemp->second.erase(ittempgs); 131 130 } 132 131 … … 139 138 *copyList gets vector of Gamestate Manager and turns it to *listToProcess 140 139 */ 141 void TrafficControl::copyList(std:: map<obj> *list)142 { 143 vector<obj>::iterator itvec;144 for(itvec = (*list).begin(); itvec <(*list).end(); itvec++)145 { 146 objInfo objectA = new objInfo;147 (*objectA).objCreatorID=(*itvec).objCreatorID;148 (*objectA).objSize = (*itvec).objSize;149 (*listToProcess_).insert(pair<currentClientID, map<(*itvec).objID,objectA>>);//unsicher: ob map<...> so richtig ist140 void TrafficControl::copyList(std::vector<obj> *list) 141 { 142 std::vector<obj>::iterator itvec; 143 for(itvec = (*list).begin(); itvec != (*list).end(); itvec++) 144 { 145 objInfo objectA; 146 objectA.objCreatorID=(*itvec).objCreatorID; 147 objectA.objSize = (*itvec).objSize; 148 listToProcess_.insert(pair<currentClientID, map<(*itvec).objID,objectA>>);//unsicher: ob map<...> so richtig ist 150 149 } 151 150 } … … 228 227 { 229 228 copyList(list); 230 updateReferenceList(listToProcess_);231 229 232 230 //now the sorting … … 235 233 //if listToProcess contains new Objects, add them to clientListPerm 236 234 std::map<unsigned int, objInfo>::iterator itproc; 237 std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm;235 std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm; 238 236 std::map<unsigned int, objInfo>::iterator itpermobj; 239 237 std::map<unsigned int, unsigned int>::iterator itpermprio; … … 269 267 270 268 //listToProc vs clientListTemp 271 map<unsigned int, std::map<unsigned int, unsigned int> >::iterator ittemp;269 map<unsigned int, std::map<unsigned int, unsigned int> >::iterator ittemp; 272 270 map<unsigned int, unsigned int>::iterator ittempgs; 273 271 for((itproc=listToProcess_).begin(); itproc != (listToProcess_).end();itproc++) -
code/branches/network/src/network/TrafficControl.h
r2340 r2341 37 37 #include "NetworkPrereqs.h" 38 38 #include "Synchronisable.h" 39 #include "util/Integers.h" 39 40 40 41 namespace network { … … 45 46 struct objInfo 46 47 { 47 unsigned int objCreatorID; 48 unsigned int objCurGS;//current GameState ID 49 unsigned int objDiffGS;//difference between current and latest GameState 50 unsigned int objSize; 48 uint32_t objID; 49 uint32_t objCreatorID; 50 int32_t objCurGS;//current GameState ID 51 int32_t objDiffGS;//difference between current and latest GameState 52 uint32_t objSize; 51 53 unsigned int objValuePerm; 52 54 unsigned int objValueSched; … … 88 90 *permanent client list: contains client ids, object ids and objectInfos (in this order) 89 91 */ 90 std::map<unsigned int, std::map<unsigned int, objInfo>> clientListPerm_;92 std::map<unsigned int, std::map<unsigned int, std::vector<objInfo> > > clientListPerm_; 91 93 //has to be created with constructor and then needs to be updated by evaluateList(). 92 94 … … 94 96 *temporary client list: contains client ids, gamestate ids and object ids (in this order) 95 97 */ 96 std::map<unsigned int, std::map<unsigned int, std::vector<obj> >> clientListTemp_;98 std::map<unsigned int, std::map<unsigned int, std::vector<obj> > > clientListTemp_; 97 99 /** 98 100 *static priority list: contains obj id, basic priority (in this order) … … 105 107 //end: lists to be used 106 108 107 /** 109 /**updateReferenceList 108 110 *currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server 109 111 */
Note: See TracChangeset
for help on using the changeset viewer.