Changeset 11071 for code/trunk/src/orxonox/gametypes/LastManStanding.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gametypes/LastManStanding.cc
r9667 r11071 56 56 void LastManStanding::spawnDeadPlayersIfRequested() 57 57 { 58 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)59 if ( it->second.state_ == PlayerState::Dead)60 { 61 bool alive = (0<playerLives_[ it->first]&&(inGame_[it->first]));62 if (alive&&( it->first->isReadyToSpawn() || this->bForceSpawn_))63 { 64 this->spawnPlayer( it->first);58 for (const auto& mapEntry : this->players_) 59 if (mapEntry.second.state_ == PlayerState::Dead) 60 { 61 bool alive = (0<playerLives_[mapEntry.first]&&(inGame_[mapEntry.first])); 62 if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 63 { 64 this->spawnPlayer(mapEntry.first); 65 65 } 66 66 } … … 114 114 { 115 115 int min=lives; 116 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)117 { 118 if ( it->second<=0)116 for (const auto& mapEntry : this->playerLives_) 117 { 118 if (mapEntry.second<=0) 119 119 continue; 120 if ( it->second<lives)121 min= it->second;120 if (mapEntry.second<lives) 121 min=mapEntry.second; 122 122 } 123 123 return min; … … 128 128 Gametype::end(); 129 129 130 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)131 { 132 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)130 for (const auto& mapEntry : this->playerLives_) 131 { 132 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 133 133 continue; 134 134 135 if ( it->second > 0)136 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());135 if (mapEntry.second > 0) 136 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 137 137 else 138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 139 139 } 140 140 } … … 237 237 this->end(); 238 238 } 239 for ( std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)240 { 241 if (playerGetLives( it->first)<=0)//Players without lives shouldn't be affected by time.239 for (auto& mapEntry : this->timeToAct_) 240 { 241 if (playerGetLives(mapEntry.first)<=0)//Players without lives shouldn't be affected by time. 242 242 continue; 243 it->second-=dt;//Decreases punishment time.244 if (!inGame_[ it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.245 { 246 playerDelayTime_[ it->first]-=dt;247 if (playerDelayTime_[ it->first]<=0)248 this->inGame_[ it->first]=true;249 250 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)243 mapEntry.second-=dt;//Decreases punishment time. 244 if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 245 { 246 playerDelayTime_[mapEntry.first]-=dt; 247 if (playerDelayTime_[mapEntry.first]<=0) 248 this->inGame_[mapEntry.first]=true; 249 250 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 251 251 continue; 252 int output=1+(int)playerDelayTime_[ it->first];252 int output=1+(int)playerDelayTime_[mapEntry.first]; 253 253 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 254 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());255 } 256 else if ( it->second<0.0f)257 { 258 it->second=timeRemaining+3.0f;//reset punishment-timer259 if (playerGetLives( it->first)>0)254 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 255 } 256 else if (mapEntry.second<0.0f) 257 { 258 mapEntry.second=timeRemaining+3.0f;//reset punishment-timer 259 if (playerGetLives(mapEntry.first)>0) 260 260 { 261 this->punishPlayer( it->first);262 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)261 this->punishPlayer(mapEntry.first); 262 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 263 263 return; 264 264 const std::string& message = ""; // resets Camper-Warning-message 265 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());265 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 266 266 } 267 267 } 268 else if ( it->second<timeRemaining/5)//Warning message269 { 270 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)268 else if (mapEntry.second<timeRemaining/5)//Warning message 269 { 270 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 271 271 continue; 272 272 const std::string& message = "Camper Warning! Don't forget to shoot."; 273 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());273 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 274 274 } 275 275 }
Note: See TracChangeset
for help on using the changeset viewer.