Changeset 8631
- Timestamp:
- May 27, 2011, 11:09:00 PM (13 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 3 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/spacerace (added) merged: 8182,8250-8251,8428,8494,8548,8552,8571-8573,8616-8617,8624,8630
- Property svn:mergeinfo changed
-
code/branches/presentation/src/modules/CMakeLists.txt
r8564 r8631 27 27 28 28 ADD_SUBDIRECTORY(designtools) 29 ADD_SUBDIRECTORY(gametypes) 29 30 ADD_SUBDIRECTORY(notifications) 30 31 ADD_SUBDIRECTORY(objects) -
code/branches/presentation/src/orxonox/gametypes/Gametype.cc
r8327 r8631 306 306 SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const 307 307 { 308 // If there is at least one SpawnPoint. 308 309 if (this->spawnpoints_.size() > 0) 309 310 { 311 // Fallback spawn point if there is no active one, choose a random one. 310 312 SpawnPoint* fallbackSpawnPoint = NULL; 311 313 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 312 314 unsigned int index = 0; 313 std:: set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;315 std::vector<SpawnPoint*> activeSpawnPoints; 314 316 for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it) 315 317 { … … 317 319 fallbackSpawnPoint = (*it); 318 320 319 if ( !(*it)->isActive())320 activeSpawnPoints. erase(*it);321 if (*it != NULL && (*it)->isActive()) 322 activeSpawnPoints.push_back(*it); 321 323 322 324 ++index; 323 325 } 324 326 325 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 326 index = 0; 327 for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it) 328 { 329 if (index == randomspawn) 330 return (*it); 331 332 ++index; 333 } 334 327 if(activeSpawnPoints.size() > 0) 328 { 329 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(activeSpawnPoints.size()))); 330 return activeSpawnPoints[randomspawn]; 331 } 332 333 COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl; 335 334 return fallbackSpawnPoint; 336 335 }
Note: See TracChangeset
for help on using the changeset viewer.