[Orxonox-commit 371] r2973 - in trunk/src/orxonox: objects/infos objects/worldentities overlays/hud

landauf at orxonox.net landauf at orxonox.net
Tue May 12 21:24:59 CEST 2009


Author: landauf
Date: 2009-05-12 21:24:58 +0200 (Tue, 12 May 2009)
New Revision: 2973

Modified:
   trunk/src/orxonox/objects/infos/HumanPlayer.cc
   trunk/src/orxonox/objects/infos/HumanPlayer.h
   trunk/src/orxonox/objects/infos/PlayerInfo.cc
   trunk/src/orxonox/objects/infos/PlayerInfo.h
   trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
   trunk/src/orxonox/objects/worldentities/ControllableEntity.h
   trunk/src/orxonox/overlays/hud/GametypeStatus.cc
   trunk/src/orxonox/overlays/hud/GametypeStatus.h
   trunk/src/orxonox/overlays/hud/PongScore.cc
Log:
changed type of gametype-HUD and default-HUD to PlayerInfo (instead of Gametype and ControllableEntity respectively). The owner of the Pawn-HUD remains Pawn.


Modified: trunk/src/orxonox/objects/infos/HumanPlayer.cc
===================================================================
--- trunk/src/orxonox/objects/infos/HumanPlayer.cc	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/objects/infos/HumanPlayer.cc	2009-05-12 19:24:58 UTC (rev 2973)
@@ -166,14 +166,6 @@
                 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
     }
 
-    void HumanPlayer::changedControllableEntity()
-    {
-        PlayerInfo::changedControllableEntity();
-
-        if (this->humanHud_)
-            this->humanHud_->setOwner(this->getControllableEntity());
-    }
-
     void HumanPlayer::updateHumanHUD()
     {
         if (this->humanHud_)
@@ -186,7 +178,7 @@
         {
             this->humanHud_ = new OverlayGroup(this);
             this->humanHud_->addTemplate(this->humanHudTemplate_);
-            this->humanHud_->setOwner(this->getControllableEntity());
+            this->humanHud_->setOwner(this);
         }
     }
 
@@ -202,7 +194,7 @@
         {
             this->gametypeHud_ = new OverlayGroup(this);
             this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
-            this->gametypeHud_->setOwner(this->getGametype());
+            this->gametypeHud_->setOwner(this);
         }
     }
 }

Modified: trunk/src/orxonox/objects/infos/HumanPlayer.h
===================================================================
--- trunk/src/orxonox/objects/infos/HumanPlayer.h	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/objects/infos/HumanPlayer.h	2009-05-12 19:24:58 UTC (rev 2973)
@@ -51,7 +51,6 @@
             void setClientID(unsigned int clientID);
 
             virtual void changedGametype();
-            virtual void changedControllableEntity();
 
             inline void setHumanHUDTemplate(const std::string& name)
             {

Modified: trunk/src/orxonox/objects/infos/PlayerInfo.cc
===================================================================
--- trunk/src/orxonox/objects/infos/PlayerInfo.cc	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/objects/infos/PlayerInfo.cc	2009-05-12 19:24:58 UTC (rev 2973)
@@ -50,6 +50,10 @@
         this->controllableEntity_ = 0;
         this->controllableEntityID_ = CLIENTID_UNKNOWN;
 
+        this->gtinfo_ = 0;
+        this->gtinfoID_ = OBJECTID_UNKNOWN;
+        this->updateGametypeInfo();
+
         this->registerVariables();
     }
 
@@ -75,6 +79,7 @@
         registerVariable(this->name_,                 variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
         registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
         registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
+        registerVariable(this->gtinfoID_,             variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
     }
 
     void PlayerInfo::changedName()
@@ -87,6 +92,8 @@
 
     void PlayerInfo::changedGametype()
     {
+        this->updateGametypeInfo();
+
         if (this->isInitialized())
         {
             if (this->getOldGametype())
@@ -107,6 +114,18 @@
         }
     }
 
+    void PlayerInfo::updateGametypeInfo()
+    {
+        this->gtinfo_ = 0;
+        this->gtinfoID_ = OBJECTID_UNKNOWN;
+
+        if (this->getGametype() && this->getGametype()->getGametypeInfo())
+        {
+            this->gtinfo_ = this->getGametype()->getGametypeInfo();
+            this->gtinfoID_ = this->gtinfo_->getObjectID();
+        }
+    }
+
     void PlayerInfo::createController()
     {
         if (this->controller_)
@@ -180,4 +199,15 @@
             this->stopControl(this->controllableEntity_);
         }
     }
+
+    void PlayerInfo::networkcallback_changedgtinfoID()
+    {
+        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
+        {
+            this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
+
+            if (!this->gtinfo_)
+                this->gtinfoID_ = OBJECTID_UNKNOWN;
+        }
+    }
 }

Modified: trunk/src/orxonox/objects/infos/PlayerInfo.h
===================================================================
--- trunk/src/orxonox/objects/infos/PlayerInfo.h	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/objects/infos/PlayerInfo.h	2009-05-12 19:24:58 UTC (rev 2973)
@@ -76,6 +76,9 @@
             inline Controller* getController() const
                 { return this->controller_; }
 
+            inline const GametypeInfo* getGametypeInfo() const
+                { return this->gtinfo_; }
+
         protected:
             void createController();
 
@@ -87,11 +90,16 @@
 
         private:
             void networkcallback_changedcontrollableentityID();
+            void networkcallback_changedgtinfoID();
+            void updateGametypeInfo();
 
             bool bReadyToSpawn_;
             Controller* controller_;
             ControllableEntity* controllableEntity_;
             unsigned int controllableEntityID_;
+
+            const GametypeInfo* gtinfo_;
+            unsigned int gtinfoID_;
     };
 }
 

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-12 19:24:58 UTC (rev 2973)
@@ -41,7 +41,6 @@
 #include "objects/infos/PlayerInfo.h"
 #include "objects/worldentities/Camera.h"
 #include "objects/worldentities/CameraPosition.h"
-#include "objects/gametypes/Gametype.h"
 #include "overlays/OverlayGroup.h"
 
 namespace orxonox
@@ -66,10 +65,6 @@
         this->bMouseLook_ = false;
         this->mouseLookSpeed_ = 200;
 
-        this->gtinfo_ = 0;
-        this->gtinfoID_ = OBJECTID_UNKNOWN;
-        this->changedGametype();
-
         this->server_position_         = Vector3::ZERO;
         this->client_position_         = Vector3::ZERO;
         this->server_linear_velocity_  = Vector3::ZERO;
@@ -126,21 +121,6 @@
         SetConfigValue(mouseLookSpeed_, 3.0f);
     }
 
-    void ControllableEntity::changedGametype()
-    {
-        //SUPER(ControllableEntity, changedGametype);
-        WorldEntity::changedGametype();
-
-        this->gtinfo_ = 0;
-        this->gtinfoID_ = OBJECTID_UNKNOWN;
-
-        if (this->getGametype() && this->getGametype()->getGametypeInfo())
-        {
-            this->gtinfo_ = this->getGametype()->getGametypeInfo();
-            this->gtinfoID_ = this->gtinfo_->getObjectID();
-        }
-    }
-
     void ControllableEntity::addCameraPosition(CameraPosition* position)
     {
         if (!position->getIsAbsolute())
@@ -282,17 +262,6 @@
         }
     }
 
-    void ControllableEntity::networkcallback_changedgtinfoID()
-    {
-        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
-        {
-            this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
-
-            if (!this->gtinfo_)
-                this->gtinfoID_ = OBJECTID_UNKNOWN;
-        }
-    }
-
     void ControllableEntity::startLocalHumanControl()
     {
         if (!this->camera_)
@@ -393,7 +362,6 @@
         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
 
         registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
-        registerVariable(this->gtinfoID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
     }
 
     void ControllableEntity::processServerPosition()

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.h	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.h	2009-05-12 19:24:58 UTC (rev 2973)
@@ -47,7 +47,6 @@
             void registerVariables();
             void setConfigValues();
 
-            virtual void changedGametype();
             virtual void changedPlayer() {}
 
             virtual void setPlayer(PlayerInfo* player);
@@ -125,9 +124,6 @@
             inline bool hasHumanController() const
                 { return this->bHasHumanController_; }
 
-            inline const GametypeInfo* getGametypeInfo() const
-                { return this->gtinfo_; }
-
             inline bool isInMouseLook() const
                 { return this->bMouseLook_; }
             inline float getMouseLookSpeed() const
@@ -156,7 +152,6 @@
             void processClientAngularVelocity();
 
             void networkcallback_changedplayerID();
-            void networkcallback_changedgtinfoID();
 
             // Bullet btMotionState related
             void setWorldTransform(const btTransform& worldTrans);
@@ -189,9 +184,6 @@
             Ogre::SceneNode* cameraPositionRootNode_;
             std::list<CameraPosition*> cameraPositions_;
             std::string cameraPositionTemplate_;
-
-            const GametypeInfo* gtinfo_;
-            unsigned int gtinfoID_;
     };
 }
 

Modified: trunk/src/orxonox/overlays/hud/GametypeStatus.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/GametypeStatus.cc	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/overlays/hud/GametypeStatus.cc	2009-05-12 19:24:58 UTC (rev 2973)
@@ -57,14 +57,14 @@
     {
         SUPER(GametypeStatus, tick, dt);
 
-        if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getPlayer())
+        if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity())
         {
             const GametypeInfo* gtinfo = this->owner_->getGametypeInfo();
-            PlayerInfo* pinfo = this->owner_->getPlayer();
+            ControllableEntity* ce = this->owner_->getControllableEntity();
 
             if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning())
             {
-                if (!pinfo->isReadyToSpawn())
+                if (!this->owner_->isReadyToSpawn())
                     this->setCaption("Press [Fire] to start the match");
                 else
                     this->setCaption("Waiting for other players");
@@ -73,7 +73,7 @@
             {
                 if (gtinfo->isStartCountdownRunning())
                     this->setCaption(convertToString((int)ceil(gtinfo->getStartCountdown())));
-                else if (this->owner_->isA(Class(Spectator)))
+                else if (ce->isA(Class(Spectator)))
                     this->setCaption("Press [Fire] to respawn");
                 else
                     this->setCaption("");
@@ -88,6 +88,6 @@
     {
         SUPER(GametypeStatus, changedOwner);
 
-        this->owner_ = dynamic_cast<ControllableEntity*>(this->getOwner());
+        this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
     }
 }

Modified: trunk/src/orxonox/overlays/hud/GametypeStatus.h
===================================================================
--- trunk/src/orxonox/overlays/hud/GametypeStatus.h	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/overlays/hud/GametypeStatus.h	2009-05-12 19:24:58 UTC (rev 2973)
@@ -46,7 +46,7 @@
             virtual void changedOwner();
 
         private:
-            ControllableEntity* owner_;
+            PlayerInfo* owner_;
     };
 }
 #endif /* _GametypeStatus_H__ */

Modified: trunk/src/orxonox/overlays/hud/PongScore.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/PongScore.cc	2009-05-11 16:03:40 UTC (rev 2972)
+++ trunk/src/orxonox/overlays/hud/PongScore.cc	2009-05-12 19:24:58 UTC (rev 2973)
@@ -134,6 +134,9 @@
     {
         SUPER(PongScore, changedOwner);
 
-        this->owner_ = dynamic_cast<Pong*>(this->getOwner());
+        if (this->getOwner() && this->getOwner()->getGametype())
+            this->owner_ = dynamic_cast<Pong*>(this->getOwner()->getGametype());
+        else
+            this->owner_ = 0;
     }
 }




More information about the Orxonox-commit mailing list