Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (10 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/infos/PlayerInfo.cc

    r9945 r10624  
    4040namespace orxonox
    4141{
    42     RegisterAbstractClass(PlayerInfo).inheritsFrom(Class(Info));
     42    RegisterAbstractClass(PlayerInfo).inheritsFrom<Info>();
    4343
    4444    PlayerInfo::PlayerInfo(Context* context) : Info(context)
     
    5757        this->gtinfo_ = 0;
    5858        this->gtinfoID_ = OBJECTID_UNKNOWN;
    59         this->updateGametypeInfo();
     59        this->updateGametypeInfo(this->getGametype());
    6060
    6161        this->registerVariables();
     
    9595    }
    9696
    97     void PlayerInfo::changedGametype()
    98     {
    99         this->updateGametypeInfo();
     97    void PlayerInfo::switchGametype(Gametype* gametype)
     98    {
     99        Gametype* oldGametype = this->getGametype();
     100        this->setGametype(StrongPtr<Gametype>(gametype));
     101        Gametype* newGametype = this->getGametype();
     102
     103
     104        this->updateGametypeInfo(newGametype);
    100105
    101106        if (this->isInitialized())
    102107        {
    103             if (this->getOldGametype())
     108            if (oldGametype)
    104109            {
    105                 if (this->getGametype())
    106                     this->getOldGametype()->playerSwitched(this, this->getGametype());
     110                if (newGametype)
     111                    oldGametype->playerSwitched(this, newGametype);
    107112                else
    108                     this->getOldGametype()->playerLeft(this);
     113                    oldGametype->playerLeft(this);
    109114            }
    110115
    111             if (this->getGametype())
     116            if (newGametype)
    112117            {
    113                 if (this->getOldGametype())
    114                     this->getGametype()->playerSwitchedBack(this, this->getOldGametype());
     118                if (oldGametype)
     119                    newGametype->playerSwitchedBack(this, oldGametype);
    115120                else
    116                     this->getGametype()->playerEntered(this);
     121                    newGametype->playerEntered(this);
    117122            }
    118123        }
    119124    }
    120125
    121     void PlayerInfo::updateGametypeInfo()
     126    void PlayerInfo::updateGametypeInfo(Gametype* gametype)
    122127    {
    123128        this->gtinfo_ = 0;
    124129        this->gtinfoID_ = OBJECTID_UNKNOWN;
    125130
    126         if (this->getGametype() && this->getGametype()->getGametypeInfo())
    127         {
    128             this->gtinfo_ = this->getGametype()->getGametypeInfo();
     131        if (gametype && gametype->getGametypeInfo())
     132        {
     133            this->gtinfo_ = gametype->getGametypeInfo();
    129134            this->gtinfoID_ = this->gtinfo_->getObjectID();
    130135        }
     
    186191
    187192        this->controllableEntity_->destroyHud(); // HACK-ish
    188         this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_));
     193        this->previousControllableEntity_.push_back(this->controllableEntity_);
    189194        this->controllableEntity_ = entity;
    190195        this->controllableEntityID_ = entity->getObjectID();
Note: See TracChangeset for help on using the changeset viewer.