Changeset 3043 for code/branches/netp3/src/network
- Timestamp:
- May 24, 2009, 10:38:06 PM (16 years ago)
- Location:
- code/branches/netp3/src/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3/src/network/TrafficControl.cc
r3015 r3043 142 142 assert(clientListTemp_.find(clientID) != clientListTemp_.end() ); 143 143 assert(clientListPerm_.find(clientID) != clientListPerm_.end() ); 144 assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() ); 145 146 for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++) 144 assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() ); 145 146 // shortcut for maps 147 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; 148 std::map<unsigned int, std::vector<obj> >& objectListTemp = clientListTemp_[clientID]; 149 150 for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++) 147 151 { 148 if( clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists149 { 150 clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;151 clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back152 if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists 153 { 154 objectListPerm[(*itvec).objID].objCurGS = gamestateID; 155 objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back 152 156 } 153 157 else 154 158 { 155 159 assert(0); 156 clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;157 clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;158 clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;159 clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;160 objectListPerm[(*itvec).objID].objCurGS = gamestateID; 161 objectListPerm[(*itvec).objID].objID = (*itvec).objID; 162 objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID; 163 objectListPerm[(*itvec).objID].objSize = (*itvec).objSize; 160 164 } 161 165 } 162 166 // remove temporary list (with acked objects) from the map 163 clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );167 objectListTemp.erase( objectListTemp.find(gamestateID) ); 164 168 } 165 169 … … 227 231 //if listToProcess contains new Objects, add them to clientListPerm 228 232 std::vector<obj>::iterator itvec; 233 234 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; 235 229 236 for( itvec=list.begin(); itvec != list.end(); itvec++) 230 237 { 231 if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )238 if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() ) 232 239 { 233 240 // we already have the object in our map 234 241 //obj bleibt in liste und permanente prio wird berechnet 235 clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;242 objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS; 236 243 continue;//check next objId 237 244 } -
code/branches/netp3/src/network/packet/Gamestate.cc
r3015 r3043 110 110 111 111 tempsize = it->getData(mem, id, mode); 112 if ( it->doSync( id, mode ))112 if ( tempsize != 0 ) 113 113 dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 114 114 … … 339 339 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 340 340 uint8_t *dest = ndata + GamestateHeader::getSize(); 341 while(of < diffHeader.getDataSize() && of < header_->getDataSize()){ 342 *(dest+of)=*(basep+of)^*(gs+of); // do the xor 343 ++of; 344 } 345 if(diffHeader.getDataSize()!=header_->getDataSize()){ 346 uint8_t n=0; 347 if(diffHeader.getDataSize() < header_->getDataSize()){ 348 while(of<dest_length){ 349 *(dest+of)=n^*(gs+of); 350 of++; 351 } 352 } 341 342 343 // LOOP-UNROLLED DIFFING 344 uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs; 345 // diff in 4-byte steps 346 while( of < (uint32_t)(header_->getDataSize())/4 ){ 347 if( of < (uint32_t)(diffHeader.getDataSize())/4 ) 348 { 349 *(dest32+of)=*(base32+of) ^ *(gs32+of); // do the xor 350 ++of; 351 } else 352 { 353 *(dest32+of)=*(gs32+of); // same as 0 ^ *(gs32+of) 354 ++of; 355 } 356 } 357 uint32_t base_rest = 0; 358 // fill the base_rest first with 0 and then with the remaining bytes in base32 359 switch( diffHeader.getDataSize()%sizeof(uint32_t) ) 360 { 361 case 3: 362 *((uint8_t*)(&base_rest)+2) = *((uint8_t*)(base32+of-1)+2); // save the last byte to the buffer 363 case 2: 364 *((uint16_t*)(&base_rest)) = *((uint16_t*)(base32+of-1)); // xor 2 bytes at once (either 2nd and 3rd last or the 2 last bytes) 365 break; 366 case 1: 367 *((uint8_t*)(&base_rest)) = *((uint8_t*)(base32+of-1)); // xor the last byte 368 case 0: 369 break; // leave 0 370 } 371 // now diff the rest and save it to dest32 in 2- and 1-byte steps 372 switch( header_->getDataSize()%sizeof(uint32_t) ) 373 { 374 case 3: 375 *((uint8_t*)(dest32+of)+2) = *((uint8_t*)&base_rest+2) ^ *((uint8_t*)(gs32+of-1)+2); // save the last byte to the buffer 376 case 2: 377 *((uint16_t*)(dest32+of)) = *((uint16_t*)&base_rest) ^ *((uint16_t*)(gs32+of-1)); // xor 2 bytes at once (either 2nd and 3rd last or the 2 last bytes) 378 break; 379 case 1: 380 *((uint8_t*)(dest32+of)) = *((uint8_t*)&base_rest) ^ *((uint8_t*)(gs32+of-1)); // xor the last byte 381 case 0: 382 break; 353 383 } 354 384
Note: See TracChangeset
for help on using the changeset viewer.