[Orxonox-commit 4662] r9333 - in code/branches/presentation2012merge/src: modules/gametypes modules/objects/triggers orxonox/infos

landauf at orxonox.net landauf at orxonox.net
Sun Jul 22 22:04:11 CEST 2012


Author: landauf
Date: 2012-07-22 22:04:10 +0200 (Sun, 22 Jul 2012)
New Revision: 9333

Modified:
   code/branches/presentation2012merge/src/modules/gametypes/OldRaceCheckPoint.cc
   code/branches/presentation2012merge/src/modules/gametypes/OldSpaceRace.cc
   code/branches/presentation2012merge/src/modules/gametypes/RaceCheckPoint.cc
   code/branches/presentation2012merge/src/modules/gametypes/SpaceRace.cc
   code/branches/presentation2012merge/src/modules/objects/triggers/CheckPoint.cc
   code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.cc
   code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.h
Log:
added const qualifier to all message-sending functions in GametypeInfo
removed some related const_casts from spacerace classes

Modified: code/branches/presentation2012merge/src/modules/gametypes/OldRaceCheckPoint.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/gametypes/OldRaceCheckPoint.cc	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/modules/gametypes/OldRaceCheckPoint.cc	2012-07-22 20:04:10 UTC (rev 9333)
@@ -111,7 +111,7 @@
             {
                 const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)
                             + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1);
-                const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
+                gametype->getGametypeInfo()->sendAnnounceMessage(message);
                 ChatManager::message(message);
             }
         }

Modified: code/branches/presentation2012merge/src/modules/gametypes/OldSpaceRace.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/gametypes/OldSpaceRace.cc	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/modules/gametypes/OldSpaceRace.cc	2012-07-22 20:04:10 UTC (rev 9333)
@@ -57,7 +57,7 @@
             const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
                         + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
                         + " before the time limit. You lose!";
-            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+            this->getGametypeInfo()->sendAnnounceMessage(message);
             ChatManager::message(message);
         }
         else
@@ -67,7 +67,7 @@
             int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
             const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
                         + "." + multi_cast<std::string>(ms) + " seconds.";
-            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+            this->getGametypeInfo()->sendAnnounceMessage(message);
             ChatManager::message(message);
 /*
             float time = this->clock_.getSecondsPrecise();
@@ -84,7 +84,7 @@
         Gametype::start();
 
         std::string message("The match has started! Reach the check points as quickly as possible!");
-        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        this->getGametypeInfo()->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
 
@@ -97,7 +97,7 @@
         const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
                         + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
                         + " seconds.";
-        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        this->getGametypeInfo()->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
 

Modified: code/branches/presentation2012merge/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/gametypes/RaceCheckPoint.cc	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/modules/gametypes/RaceCheckPoint.cc	2012-07-22 20:04:10 UTC (rev 9333)
@@ -96,7 +96,7 @@
         {
             std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
                         + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
-            const_cast<GametypeInfo*>(this->getGametype()->getGametypeInfo())->sendAnnounceMessage(message);
+            this->getGametype()->getGametypeInfo()->sendAnnounceMessage(message);
             ChatManager::message(message);
         }
     }

Modified: code/branches/presentation2012merge/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/gametypes/SpaceRace.cc	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/modules/gametypes/SpaceRace.cc	2012-07-22 20:04:10 UTC (rev 9333)
@@ -71,7 +71,7 @@
                         + "." + multi_cast<std::string>(ms) + " seconds.";
         }
 
-        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        this->getGametypeInfo()->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
 
@@ -98,7 +98,7 @@
             this->cantMove_= false;
 
             std::string message = "The match has started! Reach the check points as quickly as possible!";
-            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+            this->getGametypeInfo()->sendAnnounceMessage(message);
             ChatManager::message(message);
         }
     }
@@ -113,7 +113,7 @@
 
         const std::string& message = "Checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1)
             + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds.";
-        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        this->getGametypeInfo()->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
 

Modified: code/branches/presentation2012merge/src/modules/objects/triggers/CheckPoint.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/objects/triggers/CheckPoint.cc	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/modules/objects/triggers/CheckPoint.cc	2012-07-22 20:04:10 UTC (rev 9333)
@@ -108,13 +108,13 @@
 
                 if (bIsDestination_)
                 {
-                    const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Congratulations - you have won the match!");
+                    gametype->getGametypeInfo()->sendAnnounceMessage("Congratulations - you have won the match!");
                     gametype->end();
                 }
 
                 if (!bIsFirst_ && !bIsDestination_)
                 {
-                    const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Checkpoint reached");
+                    gametype->getGametypeInfo()->sendAnnounceMessage("Checkpoint reached");
                 }
             }
         }

Modified: code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.cc	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.cc	2012-07-22 20:04:10 UTC (rev 9333)
@@ -67,7 +67,7 @@
     GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator)
     {
         RegisterObject(GametypeInfo);
-        
+
         this->bStarted_ = false;
         this->bEnded_ = false;
         this->startCountdown_ = 10.0f;
@@ -164,11 +164,11 @@
     {
         if(this->bStarted_)
            { return;}
-        
+
         this->bStarted_ = true;
         this->changedStarted();
-        
-       
+
+
     }
 
     /**
@@ -194,7 +194,7 @@
     {
         if(this->startCountdown_ == countdown || countdown < 0.0f)
             return;
-        
+
         this->startCountdown_ = countdown;
         // Set the counter to the ceiling of the current countdown.
         this->counter_ = static_cast<unsigned int>(std::ceil(countdown));
@@ -224,7 +224,7 @@
     {
         if(this->counter_ == 0)
             return;
-        
+
         this->counter_--;
         this->changedCountdownCounter();
     }
@@ -324,7 +324,7 @@
     {
         if(this->spawned_ == spawned)
             return;
-        
+
         this->spawned_ = spawned;
         // Clear the notifications if the Player has spawned.
         if(this->spawned_ && !this->hasEnded())
@@ -394,7 +394,7 @@
     // Announce messages.
     // TODO: Replace with notifications.
 
-    void GametypeInfo::sendAnnounceMessage(const std::string& message)
+    void GametypeInfo::sendAnnounceMessage(const std::string& message) const
     {
         if (GameMode::isMaster())
         {
@@ -403,7 +403,7 @@
         }
     }
 
-    void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID)
+    void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const
     {
         if (GameMode::isMaster())
         {
@@ -414,7 +414,7 @@
         }
     }
 
-    void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID)
+    void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const
     {
         if (GameMode::isMaster())
         {
@@ -425,7 +425,7 @@
         }
     }
 
-    void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID)
+    void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const
     {
         if (GameMode::isMaster())
         {
@@ -436,7 +436,7 @@
         }
     }
 
-    void GametypeInfo::sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour)
+    void GametypeInfo::sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour) const
     {
         if (GameMode::isMaster())
         {
@@ -447,7 +447,7 @@
         }
     }
 
-    void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID)
+    void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID) const
     {
         if (GameMode::isMaster())
         {
@@ -458,31 +458,31 @@
         }
     }
 
-    void GametypeInfo::dispatchAnnounceMessage(const std::string& message)
+    void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const
     {
         for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
             it->announcemessage(this, message);
     }
 
-    void GametypeInfo::dispatchKillMessage(const std::string& message)
+    void GametypeInfo::dispatchKillMessage(const std::string& message) const
     {
         for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
             it->killmessage(this, message);
     }
 
-    void GametypeInfo::dispatchDeathMessage(const std::string& message)
+    void GametypeInfo::dispatchDeathMessage(const std::string& message) const
     {
         for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
             it->deathmessage(this, message);
     }
 
-     void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour)
+     void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour) const
     {
         for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
             it->staticmessage(this, message, colour);
     }
 
-     void GametypeInfo::dispatchFadingMessage(const std::string& message)
+     void GametypeInfo::dispatchFadingMessage(const std::string& message) const
     {
         for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
             it->fadingmessage(this, message);

Modified: code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.h
===================================================================
--- code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.h	2012-07-22 19:54:48 UTC (rev 9332)
+++ code/branches/presentation2012merge/src/orxonox/infos/GametypeInfo.h	2012-07-22 20:04:10 UTC (rev 9333)
@@ -67,7 +67,7 @@
             inline bool hasStarted() const
                 { return this->bStarted_; }
             void changedStarted(void); // Is called when the game has changed to started.
-            
+
             /**
             @brief Get whether the game has ended yet.
             @return Returns true if the game has ended, false if not.
@@ -107,7 +107,7 @@
             inline bool isReadyToSpawn() const
                 { return this->readyToSpawn_; }
             void changedReadyToSpawn(bool ready); // Inform the GametypeInfo that the local player has changed its spawned status.
-            
+
             /**
             @brief Get whether the local player is spawned.
             @return Returns true if the local player is currently spawned, false if not.
@@ -118,23 +118,23 @@
 
             inline const std::string& getHUDTemplate() const
                 { return this->hudtemplate_; }
-            
+
             inline unsigned int getNumberOfPlayers() const
                 {  return this->spawnedPlayers_.size(); }
 
-            void sendAnnounceMessage(const std::string& message);
-            void sendAnnounceMessage(const std::string& message, unsigned int clientID);
-            void sendKillMessage(const std::string& message, unsigned int clientID);
-            void sendDeathMessage(const std::string& message, unsigned int clientID);
-            void sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour);
-            void sendFadingMessage(const std::string& message, unsigned int clientID);
+            void sendAnnounceMessage(const std::string& message) const;
+            void sendAnnounceMessage(const std::string& message, unsigned int clientID) const;
+            void sendKillMessage(const std::string& message, unsigned int clientID) const;
+            void sendDeathMessage(const std::string& message, unsigned int clientID) const;
+            void sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour) const;
+            void sendFadingMessage(const std::string& message, unsigned int clientID) const;
 
-            void dispatchAnnounceMessage(const std::string& message);
-            void dispatchKillMessage(const std::string& message);
-            void dispatchDeathMessage(const std::string& message);
-            void dispatchStaticMessage(const std::string& message,const ColourValue& colour);
-            void dispatchFadingMessage(const std::string& message);
-            
+            void dispatchAnnounceMessage(const std::string& message) const;
+            void dispatchKillMessage(const std::string& message) const;
+            void dispatchDeathMessage(const std::string& message) const;
+            void dispatchStaticMessage(const std::string& message,const ColourValue& colour) const;
+            void dispatchFadingMessage(const std::string& message) const;
+
         protected:
             void start(void); // Inform the GametypeInfo that the game has started.
             void end(void); // Inform the GametypeInfo that the game has ended.
@@ -164,7 +164,7 @@
             float startCountdown_; //!< The current value of the start countdown.
             unsigned int counter_; //!< The current integer value of the start countdown, the start countdown counter.
             std::string hudtemplate_;
-            
+
             std::set<PlayerInfo*> spawnedPlayers_; //!< A set of players that are currently spawned.
             bool spawned_; //!< Whether the local Player is currently spawned.
             bool readyToSpawn_; //!< Whether the local Player is ready to spawn.




More information about the Orxonox-commit mailing list