Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r8327 r8706  
    121121        }
    122122
    123         if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
    124             this->gtinfo_->startCountdown_ -= dt;
    125 
    126         if (!this->gtinfo_->bStarted_)
     123        if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
     124            this->gtinfo_->countdownStartCountdown(dt);
     125
     126        if (!this->gtinfo_->hasStarted())
     127        {
     128            for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     129            {
     130                // Inform the GametypeInfo that the player is ready to spawn.
     131                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
     132                    this->gtinfo_->playerReadyToSpawn(it->first);
     133            }
     134                   
    127135            this->checkStart();
    128         else if (!this->gtinfo_->bEnded_)
     136        }
     137        else if (!this->gtinfo_->hasEnded())
    129138            this->spawnDeadPlayersIfRequested();
    130139
     
    136145        this->addBots(this->numberOfBots_);
    137146
    138         this->gtinfo_->bStarted_ = true;
     147        this->gtinfo_->start();
    139148
    140149        this->spawnPlayersIfRequested();
     
    143152    void Gametype::end()
    144153    {
    145         this->gtinfo_->bEnded_ = true;
     154        this->gtinfo_->end();
    146155
    147156        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    173182    {
    174183        this->players_[player].state_ = PlayerState::Joined;
     184        this->gtinfo_->playerEntered(player);
    175185    }
    176186
     
    270280                }
    271281
     282                if(victim->getPlayer()->isHumanPlayer())
     283                    this->gtinfo_->pawnKilled(victim->getPlayer());
     284
    272285                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
    273286                if (victim->getCamera())
     
    306319    SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const
    307320    {
     321        // If there is at least one SpawnPoint.
    308322        if (this->spawnpoints_.size() > 0)
    309323        {
     324            // Fallback spawn point if there is no active one, choose a random one.
    310325            SpawnPoint* fallbackSpawnPoint = NULL;
    311326            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    312327            unsigned int index = 0;
    313             std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;
     328            std::vector<SpawnPoint*> activeSpawnPoints;
    314329            for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
    315330            {
     
    317332                    fallbackSpawnPoint = (*it);
    318333
    319                 if (!(*it)->isActive())
    320                     activeSpawnPoints.erase(*it);
     334                if (*it != NULL && (*it)->isActive())
     335                    activeSpawnPoints.push_back(*it);
    321336
    322337                ++index;
    323338            }
    324339
    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 
     340            if(activeSpawnPoints.size() > 0)
     341            {
     342                randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(activeSpawnPoints.size())));
     343                return activeSpawnPoints[randomspawn];
     344            }
     345
     346            COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl;
    335347            return fallbackSpawnPoint;
    336348        }
     
    346358                it->second.state_ = PlayerState::Dead;
    347359
    348                 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
     360                if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
    349361                {
    350362                    this->spawnPlayerAsDefaultPawn(it->first);
     
    357369    void Gametype::checkStart()
    358370    {
    359         if (!this->gtinfo_->bStarted_)
    360         {
    361             if (this->gtinfo_->bStartCountdownRunning_)
    362             {
    363                 if (this->gtinfo_->startCountdown_ <= 0)
    364                 {
    365                     this->gtinfo_->bStartCountdownRunning_ = false;
    366                     this->gtinfo_->startCountdown_ = 0;
     371        if (!this->gtinfo_->hasStarted())
     372        {
     373            if (this->gtinfo_->isStartCountdownRunning())
     374            {
     375                if (this->gtinfo_->getStartCountdown() <= 0.0f)
     376                {
     377                    this->gtinfo_->stopStartCountdown();
     378                    this->gtinfo_->setStartCountdown(0.0f);;
    367379                    this->start();
    368380                }
     
    389401                        // If in developer's mode, there is no start countdown.
    390402                        if(Core::getInstance().inDevMode())
    391                             this->gtinfo_->startCountdown_ = 0;
     403                            this->start();
    392404                        else
    393                             this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    394                         this->gtinfo_->bStartCountdownRunning_ = true;
     405                            this->gtinfo_->setStartCountdown(this->initialStartCountdown_);
     406                        this->gtinfo_->startStartCountdown();
    395407                    }
    396408                }
     
    402414    {
    403415        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     416        {
    404417            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    405418                this->spawnPlayer(it->first);
     419        }
    406420    }
    407421
     
    422436            player->startControl(spawnpoint->spawn());
    423437            this->players_[player].state_ = PlayerState::Alive;
     438
     439            if(player->isHumanPlayer())
     440                this->gtinfo_->playerSpawned(player);
     441           
    424442            this->playerPostSpawn(player);
    425443        }
Note: See TracChangeset for help on using the changeset viewer.