Changeset 2230
- Timestamp:
- Nov 19, 2008, 5:15:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/TrafficControl.cc
r2052 r2230 33 33 namespace network { 34 34 35 /** 36 *Initializing protected members 37 */ 35 38 TrafficControl *TraffiControl::instance_=0; 36 39 … … 42 45 assert(instance_=0); 43 46 instance_=this; 44 45 47 clientListPerm_=new std::map<unsigned int,std::map<unsigned int, unsigned int>>; 48 referenceList_=new std::map<unsigned int, Synchronisable*>; 46 49 } 47 48 50 49 51 /** … … 53 55 { 54 56 instance_=0; 57 } 58 59 /** 60 *Definition of public members 61 */ 62 63 TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<unsigned> *list) 64 { 65 currentClientID=clientID; 66 currentGamestateID=gamestateID; 67 list = evaluateList(list); 68 return list; 69 } 70 71 /** 72 *Definition of private members 73 */ 74 75 //brauch ich die noch?? 76 TrafficControl::createReferenceList(Synchronisable *list) 77 { 78 map<unsigned int, Synchronisable*>::iterator itref; 79 itref=referenceList_->begin(); 80 referenceList_->insert(itref,pair<unsigned int, Synchronisable*>(itref->getObjectID,itref->getSynchronisable)); 81 } 82 //end brauch ich die noch 83 84 /** 85 *copyList gets vector of Gamestate Manager and turns it to *listToProcess 86 */ 87 TrafficControl::copyList(std::map<obj> *list) 88 { 89 listToProcess_=new std::map<unsigned int,std::map<unsigned int, unsigned int>>; 90 vector<obj>::iterator itvec; 91 for(itvec = list->begin(); itvec < list->end(); itvec++) 92 { 93 objInfo * objectA = new objInfo; 94 objectA.objCreatorID=*itvec.objCreatorID; 95 objectA.objSize = *itvec.objSize; 96 listToProcess_->insert(pair<currentClientID, map<*itvec.objID,objectA>)//unsicher: ob map<...> so richtig ist 97 } 98 } 99 /** 100 *updateReferenceList compares the sent list by GSmanager with *the current reference list and updates it. 101 *returns void 102 */ 103 TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list) 104 { 105 map<unsigned int, Synchronisable*>::iterator itref; 106 map<unsigned int, objInfo>::iterator itproc; 107 for(itproc=listToProcess_->begin();itproc != listToProcess_->.end(); itproc++) 108 { 109 //itproc->first=objectid that is looked for 110 if(referenceList_->find(itproc->first)) 111 { 112 continue; 113 } 114 else 115 { 116 referenceList_->insert(pair<unsigned int, Synchronisable*>(itproc->first,Synchronisable::getSynchronisable(itproc->first)); 117 insertinClientListPerm(itproc->first,itproc->second); 118 } 119 } 120 } 121 /** 122 *updateClientListPerm 123 *returns void 124 */ 125 TrafficControl::insertinClientListPerm(unsigned int objid, objInfo objinf) 126 { 127 clientListPerm_->insert(pair<unsigned int,objInfo>(objid,objinf)); 128 } 129 130 131 /** 132 *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this. 133 */ 134 TrafficControl::evaluateList(std::map<obj> *list) 135 { 136 copyList(list); 137 updateReferenceList(listToProcess_); 138 139 //now the sorting 140 141 //end of sorting 142 return evaluatedList_; 55 143 } 56 144
Note: See TracChangeset
for help on using the changeset viewer.