- Timestamp:
- Dec 5, 2015, 10:47:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/network/GamestateManager.cc
r10769 r10919 70 70 { 71 71 if( this->currentGamestate_ ) 72 delete this->currentGamestate_;std::map<unsigned int, packet::Gamestate*>::iterator it; 73 for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it ) 74 delete it->second; 75 std::map<uint32_t, peerInfo>::iterator peerIt; 76 std::map<uint32_t, packet::Gamestate*>::iterator gamestateIt; 77 for( peerIt = peerMap_.begin(); peerIt != peerMap_.end(); ++peerIt ) 78 { 79 for( gamestateIt = peerIt->second.gamestates.begin(); gamestateIt != peerIt->second.gamestates.end(); ++gamestateIt ) 80 delete gamestateIt->second; 72 delete this->currentGamestate_; 73 for( const auto& mapEntry : gamestateQueue ) 74 delete mapEntry.second; 75 for( const auto& mapEntryPeer : peerMap_ ) 76 { 77 for( const auto& mapEntryGamestate : mapEntryPeer.second.gamestates ) 78 delete mapEntryGamestate.second; 81 79 } 82 80 // this->trafficControl_->destroy(); … … 107 105 if( this->gamestateQueue.empty() ) 108 106 return true; 109 std::map<unsigned int, packet::Gamestate*>::iterator it;110 107 // now push only the most recent gamestates we received (ignore obsolete ones) 111 for( it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++)112 { 113 OrxVerify(processGamestate( it->second), "ERROR: could not process Gamestate");114 sendAck( it->second->getID(), it->second->getPeerID() );115 delete it->second;108 for(const auto& mapEntry : gamestateQueue) 109 { 110 OrxVerify(processGamestate(mapEntry.second), "ERROR: could not process Gamestate"); 111 sendAck( mapEntry.second->getID(), mapEntry.second->getPeerID() ); 112 delete mapEntry.second; 116 113 } 117 114 // now clear the queue … … 177 174 std::vector<packet::Gamestate*> peerGamestates; 178 175 179 std::map<uint32_t, peerInfo>::iterator peerIt; 180 for( peerIt=peerMap_.begin(); peerIt!=peerMap_.end(); ++peerIt ) 181 { 182 if( !peerIt->second.isSynched ) 176 for( const auto& mapEntry : peerMap_ ) 177 { 178 if( !mapEntry.second.isSynched ) 183 179 { 184 180 orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl; 185 181 continue; 186 182 } 187 orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl;183 orxout(verbose_more, context::network) << "client id: " << mapEntry.first << endl; 188 184 orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl; 189 int peerID = peerIt->first; //get client id190 191 unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID;185 int peerID = mapEntry.first; //get client id 186 187 unsigned int lastAckedGamestateID = mapEntry.second.lastAckedGamestateID; 192 188 193 189 packet::Gamestate* baseGamestate=nullptr; … … 340 336 { 341 337 assert(peerMap_.find(peerID)!=peerMap_.end()); 342 std::map<uint32_t, packet::Gamestate*>::iterator peerIt; 343 for( peerIt = peerMap_[peerID].gamestates.begin(); peerIt!=peerMap_[peerID].gamestates.end(); ++peerIt ) 344 { 345 delete peerIt->second; 338 for( const auto& mapEntry : peerMap_[peerID].gamestates ) 339 { 340 delete mapEntry.second; 346 341 } 347 342 peerMap_.erase(peerMap_.find(peerID));
Note: See TracChangeset
for help on using the changeset viewer.