Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 9, 2015, 2:15:46 PM (9 years ago)
Author:
landauf
Message:

removed changedGametype and getOldGametype from BaseObject. the gametype is never supposed to change anyway. the only exception is PlayerInfo which may change a gametype. but this happens in a completely controlled manner and can be done with a separate new function (switchGametype).

Location:
code/branches/core7/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/BaseObject.cc

    r10571 r10576  
    6363        this->bActive_ = true;
    6464        this->bVisible_ = true;
    65         this->oldGametype_ = 0;
    6665        this->bRegisteredEventStates_ = false;
    6766
  • code/branches/core7/src/libraries/core/BaseObject.h

    r10571 r10576  
    148148            inline virtual uint32_t getSceneID() const { return this->sceneID_; }
    149149
    150             inline void setGametype(const StrongPtr<Gametype>& gametype)
    151             {
    152                 if (gametype != this->gametype_)
    153                 {
    154                     this->oldGametype_ = this->gametype_;
    155                     this->gametype_ = gametype;
    156                     this->changedGametype();
    157                 }
    158             }
     150            inline void setGametype(const StrongPtr<Gametype>& gametype) { this->gametype_ = gametype; }
    159151            inline Gametype* getGametype() const { return this->gametype_; }
    160             inline Gametype* getOldGametype() const { return this->oldGametype_; }
    161             virtual void changedGametype() {}
    162152
    163153            inline void setLevel(const StrongPtr<Level>& level) { this->level_ = level; }
     
    219209            uint32_t               sceneID_;
    220210            StrongPtr<Gametype>    gametype_;
    221             Gametype*              oldGametype_;
    222211            StrongPtr<Level>       level_;
    223212            std::set<Template*>    templates_;
     
    235224    SUPER_FUNCTION(4, BaseObject, XMLEventPort, false);
    236225    SUPER_FUNCTION(8, BaseObject, changedName, false);
    237     SUPER_FUNCTION(9, BaseObject, changedGametype, false);
    238226}
    239227
  • code/branches/core7/src/libraries/core/class/Super.h

    r9667 r10576  
    274274        SUPER_NOARGS(classname, functionname)
    275275
    276     #define SUPER_changedGametype(classname, functionname, ...) \
    277         SUPER_NOARGS(classname, functionname)
    278 
    279276    #define SUPER_changedUsed(classname, functionname, ...) \
    280277        SUPER_NOARGS(classname, functionname)
     
    555552        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    556553
    557         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
    558             ()
    559         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    560 
    561         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
    562             ()
    563         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    564 
    565         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedCarrier, false)
    566             ()
    567         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    568 
    569         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedPickedUp, false)
     554        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedUsed, false)
     555            ()
     556        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     557
     558        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedCarrier, false)
     559            ()
     560        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     561
     562        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedPickedUp, false)
    570563            ()
    571564        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     
    623616    SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
    624617    SUPER_INTRUSIVE_DECLARATION(changedName);
    625     SUPER_INTRUSIVE_DECLARATION(changedGametype);
    626618    SUPER_INTRUSIVE_DECLARATION(changedUsed);
    627619    SUPER_INTRUSIVE_DECLARATION(changedCarrier);
  • code/branches/core7/src/orxonox/Level.cc

    r10575 r10576  
    169169    {
    170170        orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
    171         player->setGametype(this->getGametype());
     171        player->switchGametype(this->getGametype());
    172172    }
    173173
     
    175175    {
    176176        orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
    177         player->setGametype(0);
     177        player->switchGametype(0);
    178178    }
    179179}
  • code/branches/core7/src/orxonox/infos/HumanPlayer.cc

    r9667 r10576  
    160160    }
    161161
    162     void HumanPlayer::changedGametype()
    163     {
    164         PlayerInfo::changedGametype();
     162    void HumanPlayer::switchGametype(Gametype* gametype)
     163    {
     164        PlayerInfo::switchGametype(gametype);
    165165
    166166        if (this->isInitialized() && this->isLocalPlayer())
  • code/branches/core7/src/orxonox/infos/HumanPlayer.h

    r9667 r10576  
    5151            void setClientID(unsigned int clientID);
    5252
    53             virtual void changedGametype();
     53            virtual void switchGametype(Gametype* gametype);
    5454
    5555            inline void setHumanHUDTemplate(const std::string& name)
  • code/branches/core7/src/orxonox/infos/PlayerInfo.cc

    r10557 r10576  
    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(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        }
  • code/branches/core7/src/orxonox/infos/PlayerInfo.h

    r9667 r10576  
    4545
    4646            virtual void changedName();
    47             virtual void changedGametype();
     47            virtual void switchGametype(Gametype* gametype);
    4848
    4949            virtual void changedController() {}
     
    9494            void networkcallback_changedcontrollableentityID();
    9595            void networkcallback_changedgtinfoID();
    96             void updateGametypeInfo();
     96            void updateGametypeInfo(Gametype* gametype);
    9797
    9898            bool bReadyToSpawn_;
  • code/branches/core7/src/orxonox/interfaces/Pickupable.h

    r9667 r10576  
    187187
    188188    //! SUPER functions.
    189     SUPER_FUNCTION(10, Pickupable, changedUsed, false);
    190     SUPER_FUNCTION(11, Pickupable, changedCarrier, false);
    191     SUPER_FUNCTION(12, Pickupable, changedPickedUp, false);
     189    SUPER_FUNCTION(9, Pickupable, changedUsed, false);
     190    SUPER_FUNCTION(10, Pickupable, changedCarrier, false);
     191    SUPER_FUNCTION(11, Pickupable, changedPickedUp, false);
    192192}
    193193
Note: See TracChangeset for help on using the changeset viewer.