Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8631


Ignore:
Timestamp:
May 27, 2011, 11:09:00 PM (14 years ago)
Author:
dafrick
Message:

Merging spacerace branch into presentation branch.

Location:
code/branches/presentation
Files:
3 edited
9 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/modules/CMakeLists.txt

    r8564 r8631  
    2727
    2828ADD_SUBDIRECTORY(designtools)
     29ADD_SUBDIRECTORY(gametypes)
    2930ADD_SUBDIRECTORY(notifications)
    3031ADD_SUBDIRECTORY(objects)
  • code/branches/presentation/src/orxonox/gametypes/Gametype.cc

    r8327 r8631  
    306306    SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const
    307307    {
     308        // If there is at least one SpawnPoint.
    308309        if (this->spawnpoints_.size() > 0)
    309310        {
     311            // Fallback spawn point if there is no active one, choose a random one.
    310312            SpawnPoint* fallbackSpawnPoint = NULL;
    311313            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    312314            unsigned int index = 0;
    313             std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;
     315            std::vector<SpawnPoint*> activeSpawnPoints;
    314316            for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
    315317            {
     
    317319                    fallbackSpawnPoint = (*it);
    318320
    319                 if (!(*it)->isActive())
    320                     activeSpawnPoints.erase(*it);
     321                if (*it != NULL && (*it)->isActive())
     322                    activeSpawnPoints.push_back(*it);
    321323
    322324                ++index;
    323325            }
    324326
    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;
    335334            return fallbackSpawnPoint;
    336335        }
Note: See TracChangeset for help on using the changeset viewer.