Changeset 11071 for code/trunk/src/orxonox/gametypes/LastTeamStanding.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/LastTeamStanding.cc
r9941 r11071 145 145 void LastTeamStanding::spawnDeadPlayersIfRequested() 146 146 { 147 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)148 if ( it->second.state_ == PlayerState::Dead)149 { 150 bool alive = (0 < playerLives_[ it->first]&&(inGame_[it->first]));151 if (alive&&( it->first->isReadyToSpawn() || this->bForceSpawn_))152 { 153 this->spawnPlayer( it->first);147 for (const auto& mapEntry : this->players_) 148 if (mapEntry.second.state_ == PlayerState::Dead) 149 { 150 bool alive = (0 < playerLives_[mapEntry.first]&&(inGame_[mapEntry.first])); 151 if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 152 { 153 this->spawnPlayer(mapEntry.first); 154 154 } 155 155 } … … 184 184 this->end(); 185 185 } 186 for ( std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)187 { 188 if (playerGetLives( it->first) <= 0)//Players without lives shouldn't be affected by time.186 for (auto& mapEntry : this->timeToAct_) 187 { 188 if (playerGetLives(mapEntry.first) <= 0)//Players without lives shouldn't be affected by time. 189 189 continue; 190 it->second -= dt;//Decreases punishment time.191 if (!inGame_[ it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.192 { 193 playerDelayTime_[ it->first] -= dt;194 if (playerDelayTime_[ it->first] <= 0)195 this->inGame_[ it->first] = true;196 197 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)190 mapEntry.second -= dt;//Decreases punishment time. 191 if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 192 { 193 playerDelayTime_[mapEntry.first] -= dt; 194 if (playerDelayTime_[mapEntry.first] <= 0) 195 this->inGame_[mapEntry.first] = true; 196 197 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 198 198 continue; 199 int output = 1 + (int)playerDelayTime_[ it->first];199 int output = 1 + (int)playerDelayTime_[mapEntry.first]; 200 200 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 201 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());202 } 203 else if ( it->second < 0.0f)204 { 205 it->second = timeRemaining + 3.0f;//reset punishment-timer206 if (playerGetLives( it->first) > 0)201 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 202 } 203 else if (mapEntry.second < 0.0f) 204 { 205 mapEntry.second = timeRemaining + 3.0f;//reset punishment-timer 206 if (playerGetLives(mapEntry.first) > 0) 207 207 { 208 this->punishPlayer( it->first);209 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)208 this->punishPlayer(mapEntry.first); 209 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 210 210 return; 211 211 const std::string& message = ""; // resets Camper-Warning-message 212 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());212 this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID()); 213 213 } 214 214 } 215 else if ( it->second < timeRemaining/5)//Warning message216 { 217 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)215 else if (mapEntry.second < timeRemaining/5)//Warning message 216 { 217 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 218 218 continue; 219 219 const std::string& message = "Camper Warning! Don't forget to shoot."; 220 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());220 this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID()); 221 221 } 222 222 } … … 229 229 int party = -1; 230 230 //find a player who survived 231 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)232 { 233 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)231 for (const auto& mapEntry : this->playerLives_) 232 { 233 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 234 234 continue; 235 235 236 if ( it->second > 0)//a player that is alive236 if (mapEntry.second > 0)//a player that is alive 237 237 { 238 238 //which party has survived? 239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find( it->first);239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(mapEntry.first); 240 240 if (it2 != this->teamnumbers_.end()) 241 241 { … … 255 255 { 256 256 int min = lives; 257 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)258 { 259 if ( it->second <= 0)257 for (const auto& mapEntry : this->playerLives_) 258 { 259 if (mapEntry.second <= 0) 260 260 continue; 261 if ( it->second < lives)262 min = it->second;261 if (mapEntry.second < lives) 262 min = mapEntry.second; 263 263 } 264 264 return min;
Note: See TracChangeset
for help on using the changeset viewer.