[Orxonox-commit 914] r5637 - in code/branches/libraries/src: core orxonox/gamestates

landauf at orxonox.net landauf at orxonox.net
Wed Aug 12 17:06:34 CEST 2009


Author: landauf
Date: 2009-08-12 17:06:34 +0200 (Wed, 12 Aug 2009)
New Revision: 5637

Modified:
   code/branches/libraries/src/core/Core.cc
   code/branches/libraries/src/core/Game.cc
   code/branches/libraries/src/core/Game.h
   code/branches/libraries/src/orxonox/gamestates/GSClient.cc
Log:
Applied retos patch for Game.cc and Game.h (thanks)

+2 small changes in Core.cc and GSClient.cc

Modified: code/branches/libraries/src/core/Core.cc
===================================================================
--- code/branches/libraries/src/core/Core.cc	2009-08-12 12:21:56 UTC (rev 5636)
+++ code/branches/libraries/src/core/Core.cc	2009-08-12 15:06:34 UTC (rev 5637)
@@ -298,7 +298,7 @@
                         std::string library = filename.substr(0, filename.size() - pluginextensionlength);
                         boost::filesystem::path librarypath = searchpath / library;
 
-                        this->dynLibManager_->load(librarypath.string());
+                        DynLibManager::getInstance().load(librarypath.string());
                     }
                 }
 

Modified: code/branches/libraries/src/core/Game.cc
===================================================================
--- code/branches/libraries/src/core/Game.cc	2009-08-12 12:21:56 UTC (rev 5636)
+++ code/branches/libraries/src/core/Game.cc	2009-08-12 15:06:34 UTC (rev 5637)
@@ -112,6 +112,8 @@
         Non-initialising constructor.
     */
     Game::Game(const std::string& cmdLine)
+        // Destroy factories before the Core!
+        : gsFactoryDestroyer_(Game::GameStateFactory::factories_s, &std::map<std::string, shared_ptr<GameStateFactory> >::clear)
     {
         this->bAbort_ = false;
         bChangingState_ = false;

Modified: code/branches/libraries/src/core/Game.h
===================================================================
--- code/branches/libraries/src/core/Game.h	2009-08-12 12:21:56 UTC (rev 5636)
+++ code/branches/libraries/src/core/Game.h	2009-08-12 15:06:34 UTC (rev 5637)
@@ -47,6 +47,7 @@
 #include <boost/preprocessor/cat.hpp>
 
 #include "util/Debug.h"
+#include "util/ScopeGuard.h"
 #include "util/Singleton.h"
 
 /**
@@ -84,6 +85,7 @@
         typedef std::vector<shared_ptr<GameState> > GameStateVector;
         typedef std::map<std::string, shared_ptr<GameState> > GameStateMap;
         typedef boost::shared_ptr<GameStateTreeNode> GameStateTreeNodePtr;
+
     public:
         Game(const std::string& cmdLine);
         ~Game();
@@ -117,7 +119,7 @@
             template <class T>
             static void createFactory(const std::string& className)
                 { factories_s[className].reset(new TemplateGameStateFactory<T>()); }
-        private:
+
             virtual shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;
             static std::map<std::string, shared_ptr<GameStateFactory> > factories_s;
         };
@@ -128,6 +130,8 @@
             shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)
                 { return shared_ptr<GameState>(new T(info)); }
         };
+        // For the factory destruction
+        typedef Loki::ObjScopeGuardImpl0<std::map<std::string, shared_ptr<GameStateFactory> >, void (std::map<std::string, shared_ptr<GameStateFactory> >::*)()> ObjScopeGuard;
 
         struct StatisticsTickInfo
         {
@@ -155,6 +159,7 @@
 
         scoped_ptr<Clock>                  gameClock_;
         scoped_ptr<Core>                   core_;
+        ObjScopeGuard                      gsFactoryDestroyer_;
         scoped_ptr<GameConfiguration>      configuration_;
 
         GameStateMap                       constructedStates_;

Modified: code/branches/libraries/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/branches/libraries/src/orxonox/gamestates/GSClient.cc	2009-08-12 12:21:56 UTC (rev 5636)
+++ code/branches/libraries/src/orxonox/gamestates/GSClient.cc	2009-08-12 15:06:34 UTC (rev 5637)
@@ -39,7 +39,7 @@
 {
     DeclareGameState(GSClient, "client", false, true);
 
-    SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as strin in the form #.#.#.#");
+    SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as string in the form #.#.#.#");
 
     GSClient::GSClient(const GameStateInfo& info)
         : GameState(info)




More information about the Orxonox-commit mailing list