[Orxonox-commit 5917] r10576 - in code/branches/core7/src: libraries/core libraries/core/class orxonox orxonox/infos orxonox/interfaces

landauf at orxonox.net landauf at orxonox.net
Wed Sep 9 14:15:46 CEST 2015


Author: landauf
Date: 2015-09-09 14:15:46 +0200 (Wed, 09 Sep 2015)
New Revision: 10576

Modified:
   code/branches/core7/src/libraries/core/BaseObject.cc
   code/branches/core7/src/libraries/core/BaseObject.h
   code/branches/core7/src/libraries/core/class/Super.h
   code/branches/core7/src/orxonox/Level.cc
   code/branches/core7/src/orxonox/infos/HumanPlayer.cc
   code/branches/core7/src/orxonox/infos/HumanPlayer.h
   code/branches/core7/src/orxonox/infos/PlayerInfo.cc
   code/branches/core7/src/orxonox/infos/PlayerInfo.h
   code/branches/core7/src/orxonox/interfaces/Pickupable.h
Log:
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).

Modified: code/branches/core7/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/core7/src/libraries/core/BaseObject.cc	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/libraries/core/BaseObject.cc	2015-09-09 12:15:46 UTC (rev 10576)
@@ -62,7 +62,6 @@
 
         this->bActive_ = true;
         this->bVisible_ = true;
-        this->oldGametype_ = 0;
         this->bRegisteredEventStates_ = false;
 
         this->lastLoadedXMLElement_ = 0;

Modified: code/branches/core7/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/core7/src/libraries/core/BaseObject.h	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/libraries/core/BaseObject.h	2015-09-09 12:15:46 UTC (rev 10576)
@@ -147,18 +147,8 @@
             inline Scene* getScene() const { return this->scene_; }
             inline virtual uint32_t getSceneID() const { return this->sceneID_; }
 
-            inline void setGametype(const StrongPtr<Gametype>& gametype)
-            {
-                if (gametype != this->gametype_)
-                {
-                    this->oldGametype_ = this->gametype_;
-                    this->gametype_ = gametype;
-                    this->changedGametype();
-                }
-            }
+            inline void setGametype(const StrongPtr<Gametype>& gametype) { this->gametype_ = gametype; }
             inline Gametype* getGametype() const { return this->gametype_; }
-            inline Gametype* getOldGametype() const { return this->oldGametype_; }
-            virtual void changedGametype() {}
 
             inline void setLevel(const StrongPtr<Level>& level) { this->level_ = level; }
             inline Level* getLevel() const { return this->level_; }
@@ -218,7 +208,6 @@
             StrongPtr<Scene>       scene_;
             uint32_t               sceneID_;
             StrongPtr<Gametype>    gametype_;
-            Gametype*              oldGametype_;
             StrongPtr<Level>       level_;
             std::set<Template*>    templates_;
 
@@ -234,7 +223,6 @@
     SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
     SUPER_FUNCTION(4, BaseObject, XMLEventPort, false);
     SUPER_FUNCTION(8, BaseObject, changedName, false);
-    SUPER_FUNCTION(9, BaseObject, changedGametype, false);
 }
 
 #endif /* _BaseObject_H__ */

Modified: code/branches/core7/src/libraries/core/class/Super.h
===================================================================
--- code/branches/core7/src/libraries/core/class/Super.h	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/libraries/core/class/Super.h	2015-09-09 12:15:46 UTC (rev 10576)
@@ -273,9 +273,6 @@
     #define SUPER_changedName(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
 
-    #define SUPER_changedGametype(classname, functionname, ...) \
-        SUPER_NOARGS(classname, functionname)
-
     #define SUPER_changedUsed(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
 
@@ -554,22 +551,18 @@
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedUsed, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedCarrier, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedCarrier, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedPickedUp, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedPickedUp, false)
-            ()
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-
         // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
 
 }
@@ -622,7 +615,6 @@
     SUPER_INTRUSIVE_DECLARATION(changedOwner);
     SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
     SUPER_INTRUSIVE_DECLARATION(changedName);
-    SUPER_INTRUSIVE_DECLARATION(changedGametype);
     SUPER_INTRUSIVE_DECLARATION(changedUsed);
     SUPER_INTRUSIVE_DECLARATION(changedCarrier);
     SUPER_INTRUSIVE_DECLARATION(changedPickedUp);

Modified: code/branches/core7/src/orxonox/Level.cc
===================================================================
--- code/branches/core7/src/orxonox/Level.cc	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/orxonox/Level.cc	2015-09-09 12:15:46 UTC (rev 10576)
@@ -168,12 +168,12 @@
     void Level::playerEntered(PlayerInfo* player)
     {
         orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
-        player->setGametype(this->getGametype());
+        player->switchGametype(this->getGametype());
     }
 
     void Level::playerLeft(PlayerInfo* player)
     {
         orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
-        player->setGametype(0);
+        player->switchGametype(0);
     }
 }

Modified: code/branches/core7/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/branches/core7/src/orxonox/infos/HumanPlayer.cc	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/orxonox/infos/HumanPlayer.cc	2015-09-09 12:15:46 UTC (rev 10576)
@@ -159,9 +159,9 @@
         this->networkcallback_clientIDchanged();
     }
 
-    void HumanPlayer::changedGametype()
+    void HumanPlayer::switchGametype(Gametype* gametype)
     {
-        PlayerInfo::changedGametype();
+        PlayerInfo::switchGametype(gametype);
 
         if (this->isInitialized() && this->isLocalPlayer())
         {

Modified: code/branches/core7/src/orxonox/infos/HumanPlayer.h
===================================================================
--- code/branches/core7/src/orxonox/infos/HumanPlayer.h	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/orxonox/infos/HumanPlayer.h	2015-09-09 12:15:46 UTC (rev 10576)
@@ -50,7 +50,7 @@
 
             void setClientID(unsigned int clientID);
 
-            virtual void changedGametype();
+            virtual void switchGametype(Gametype* gametype);
 
             inline void setHumanHUDTemplate(const std::string& name)
             {

Modified: code/branches/core7/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/core7/src/orxonox/infos/PlayerInfo.cc	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/orxonox/infos/PlayerInfo.cc	2015-09-09 12:15:46 UTC (rev 10576)
@@ -56,7 +56,7 @@
 
         this->gtinfo_ = 0;
         this->gtinfoID_ = OBJECTID_UNKNOWN;
-        this->updateGametypeInfo();
+        this->updateGametypeInfo(this->getGametype());
 
         this->registerVariables();
 
@@ -94,38 +94,43 @@
             this->getGametype()->playerChangedName(this);
     }
 
-    void PlayerInfo::changedGametype()
+    void PlayerInfo::switchGametype(Gametype* gametype)
     {
-        this->updateGametypeInfo();
+        Gametype* oldGametype = this->getGametype();
+        this->setGametype(gametype);
+        Gametype* newGametype = this->getGametype();
 
+
+        this->updateGametypeInfo(newGametype);
+
         if (this->isInitialized())
         {
-            if (this->getOldGametype())
+            if (oldGametype)
             {
-                if (this->getGametype())
-                    this->getOldGametype()->playerSwitched(this, this->getGametype());
+                if (newGametype)
+                    oldGametype->playerSwitched(this, newGametype);
                 else
-                    this->getOldGametype()->playerLeft(this);
+                    oldGametype->playerLeft(this);
             }
 
-            if (this->getGametype())
+            if (newGametype)
             {
-                if (this->getOldGametype())
-                    this->getGametype()->playerSwitchedBack(this, this->getOldGametype());
+                if (oldGametype)
+                    newGametype->playerSwitchedBack(this, oldGametype);
                 else
-                    this->getGametype()->playerEntered(this);
+                    newGametype->playerEntered(this);
             }
         }
     }
 
-    void PlayerInfo::updateGametypeInfo()
+    void PlayerInfo::updateGametypeInfo(Gametype* gametype)
     {
         this->gtinfo_ = 0;
         this->gtinfoID_ = OBJECTID_UNKNOWN;
 
-        if (this->getGametype() && this->getGametype()->getGametypeInfo())
+        if (gametype && gametype->getGametypeInfo())
         {
-            this->gtinfo_ = this->getGametype()->getGametypeInfo();
+            this->gtinfo_ = gametype->getGametypeInfo();
             this->gtinfoID_ = this->gtinfo_->getObjectID();
         }
     }

Modified: code/branches/core7/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/branches/core7/src/orxonox/infos/PlayerInfo.h	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/orxonox/infos/PlayerInfo.h	2015-09-09 12:15:46 UTC (rev 10576)
@@ -44,7 +44,7 @@
             virtual ~PlayerInfo();
 
             virtual void changedName();
-            virtual void changedGametype();
+            virtual void switchGametype(Gametype* gametype);
 
             virtual void changedController() {}
             virtual void changedControllableEntity() {}
@@ -93,7 +93,7 @@
             void registerVariables();
             void networkcallback_changedcontrollableentityID();
             void networkcallback_changedgtinfoID();
-            void updateGametypeInfo();
+            void updateGametypeInfo(Gametype* gametype);
 
             bool bReadyToSpawn_;
             Controller* controller_;

Modified: code/branches/core7/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/branches/core7/src/orxonox/interfaces/Pickupable.h	2015-09-09 12:02:01 UTC (rev 10575)
+++ code/branches/core7/src/orxonox/interfaces/Pickupable.h	2015-09-09 12:15:46 UTC (rev 10576)
@@ -186,9 +186,9 @@
     };
 
     //! SUPER functions.
-    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
-    SUPER_FUNCTION(11, Pickupable, changedCarrier, false);
-    SUPER_FUNCTION(12, Pickupable, changedPickedUp, false);
+    SUPER_FUNCTION(9, Pickupable, changedUsed, false);
+    SUPER_FUNCTION(10, Pickupable, changedCarrier, false);
+    SUPER_FUNCTION(11, Pickupable, changedPickedUp, false);
 }
 
 #endif /* _Pickupable_H__ */




More information about the Orxonox-commit mailing list