Changeset 7163 for code/trunk/src/orxonox/gametypes
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gametypes/CMakeLists.txt
r5781 r7163 6 6 UnderAttack.cc 7 7 Asteroids.cc 8 Dynamicmatch.cc 8 9 ) -
code/trunk/src/orxonox/gametypes/Gametype.cc
r6417 r7163 309 309 if (this->spawnpoints_.size() > 0) 310 310 { 311 SpawnPoint* fallbackSpawnPoint = NULL; 311 312 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 312 313 unsigned int index = 0; 314 std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_; 313 315 for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it) 316 { 317 if (index == randomspawn) 318 fallbackSpawnPoint = (*it); 319 320 if (!(*it)->isActive()) 321 activeSpawnPoints.erase(*it); 322 323 ++index; 324 } 325 326 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 327 index = 0; 328 for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it) 314 329 { 315 330 if (index == randomspawn) … … 318 333 ++index; 319 334 } 335 336 return fallbackSpawnPoint; 320 337 } 321 338 return 0; -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r6417 r7163 137 137 } 138 138 139 SpawnPoint* fallbackSpawnPoint = NULL; 139 140 if (teamSpawnPoints.size() > 0) 140 141 { 141 142 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 142 143 unsigned int index = 0; 144 // Get random fallback spawnpoint in case there is no active SpawnPoint. 145 for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it) 146 { 147 if (index == randomspawn) 148 { 149 fallbackSpawnPoint = (*it); 150 break; 151 } 152 153 ++index; 154 } 155 156 // Remove all inactive SpawnPoints from the list. 157 for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ) 158 { 159 if(!(*it)->isActive()) 160 { 161 teamSpawnPoints.erase(it++); 162 continue; 163 } 164 165 ++it; 166 } 167 168 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 169 index = 0; 143 170 for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it) 144 171 { … … 148 175 ++index; 149 176 } 177 178 return fallbackSpawnPoint; 150 179 } 151 180
Note: See TracChangeset
for help on using the changeset viewer.