[Orxonox-commit 2465] r7172 - in code/trunk/src: libraries/tools libraries/tools/interfaces orxonox/gamestates

landauf at orxonox.net landauf at orxonox.net
Tue Aug 17 20:25:21 CEST 2010


Author: landauf
Date: 2010-08-17 20:25:21 +0200 (Tue, 17 Aug 2010)
New Revision: 7172

Modified:
   code/trunk/src/libraries/tools/CMakeLists.txt
   code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h
   code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
   code/trunk/src/orxonox/gamestates/GSRoot.cc
   code/trunk/src/orxonox/gamestates/GSRoot.h
Log:
removed network as dependency of tools. these libraries can build in parallel again now.
moved network synchronization of setTimeFactor from TimeFactorListener to GSRoot (GSRoot inherits from TimeFactorListener now)

Modified: code/trunk/src/libraries/tools/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/tools/CMakeLists.txt	2010-08-17 15:47:25 UTC (rev 7171)
+++ code/trunk/src/libraries/tools/CMakeLists.txt	2010-08-17 18:25:21 UTC (rev 7172)
@@ -21,6 +21,5 @@
   FIND_HEADER_FILES
   LINK_LIBRARIES
     core
-    network
   SOURCE_FILES ${TOOLS_SRC_FILES}
 )

Modified: code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h
===================================================================
--- code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h	2010-08-17 15:47:25 UTC (rev 7171)
+++ code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h	2010-08-17 18:25:21 UTC (rev 7172)
@@ -40,9 +40,9 @@
             TimeFactorListener();
             virtual ~TimeFactorListener() {}
 
-            static void setTimeFactor( float factor );
-            static void setTimeFactorInternal( float factor );
-            static inline float getTimeFactor(){ return TimeFactorListener::timefactor_s; }
+            static void setTimeFactor(float factor);
+            static inline float getTimeFactor()
+                { return TimeFactorListener::timefactor_s; }
 
         protected:
             virtual void changedTimeFactor(float factor_new, float factor_old) {}

Modified: code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
===================================================================
--- code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	2010-08-17 15:47:25 UTC (rev 7171)
+++ code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	2010-08-17 18:25:21 UTC (rev 7172)
@@ -37,15 +37,12 @@
 
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-#include "network/NetworkFunction.h"
 
 namespace orxonox
 {
     //----------------------------
     // TimeFactorListener
     //----------------------------
-    registerStaticNetworkFunction( &TimeFactorListener::setTimeFactorInternal );
-
     float TimeFactorListener::timefactor_s = 1.0f;
 
     TimeFactorListener::TimeFactorListener()
@@ -53,15 +50,11 @@
         RegisterRootObject(TimeFactorListener);
     }
 
-    /*static*/ void TimeFactorListener::setTimeFactor( float factor )
+    /*static*/ void TimeFactorListener::setTimeFactor(float factor)
     {
-        if ( !GameMode::isStandalone() )
-            callStaticNetworkFunction( &TimeFactorListener::setTimeFactorInternal, CLIENTID_UNKNOWN, factor );
-        TimeFactorListener::setTimeFactorInternal(factor);
-    }
+        if (factor == TimeFactorListener::timefactor_s)
+            return;
 
-    /*static*/ void TimeFactorListener::setTimeFactorInternal( float factor )
-    {
         float oldFactor = TimeFactorListener::timefactor_s;
         TimeFactorListener::timefactor_s = factor;
         for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)

Modified: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc	2010-08-17 15:47:25 UTC (rev 7171)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc	2010-08-17 18:25:21 UTC (rev 7172)
@@ -35,7 +35,6 @@
 #include "core/GameMode.h"
 #include "network/NetworkFunction.h"
 #include "tools/Timer.h"
-#include "tools/interfaces/TimeFactorListener.h"
 #include "tools/interfaces/Tickable.h"
 
 namespace orxonox
@@ -43,6 +42,8 @@
     DeclareGameState(GSRoot, "root", false, false);
     SetConsoleCommandShortcut(GSRoot, printObjects);
 
+    registerStaticNetworkFunction(&TimeFactorListener::setTimeFactor);
+
     GSRoot::GSRoot(const GameStateInfo& info)
         : GameState(info)
         , bPaused_(false)
@@ -152,8 +153,9 @@
         }
     }
 
-    float GSRoot::getTimeFactor()
+    void GSRoot::changedTimeFactor(float factor_new, float factor_old)
     {
-        return TimeFactorListener::getTimeFactor();
+        if (!GameMode::isStandalone())
+            callStaticNetworkFunction(&TimeFactorListener::setTimeFactor, CLIENTID_UNKNOWN, factor_new);
     }
 }

Modified: code/trunk/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.h	2010-08-17 15:47:25 UTC (rev 7171)
+++ code/trunk/src/orxonox/gamestates/GSRoot.h	2010-08-17 18:25:21 UTC (rev 7172)
@@ -31,10 +31,11 @@
 
 #include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
+#include "tools/interfaces/TimeFactorListener.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSRoot : public GameState
+    class _OrxonoxExport GSRoot : public GameState, public TimeFactorListener
     {
     public:
         GSRoot(const GameStateInfo& info);
@@ -50,8 +51,10 @@
         // when taking the function address.
         void setTimeFactor(float factor);
         void pause();
-        float getTimeFactor();
 
+    protected:
+        virtual void changedTimeFactor(float factor_new, float factor_old);
+
     private:
         bool                  bPaused_;
         float                 timeFactorPauseBackup_;




More information about the Orxonox-commit mailing list