[Orxonox-commit 104] r2799 - in branches/gui: bin src/core src/orxonox src/orxonox/gamestates src/orxonox/objects/worldentities

rgrieder at orxonox.net rgrieder at orxonox.net
Wed Mar 18 21:15:40 CET 2009


Author: rgrieder
Date: 2009-03-18 20:15:39 +0000 (Wed, 18 Mar 2009)
New Revision: 2799

Modified:
   branches/gui/bin/client1.bat.in
   branches/gui/bin/client1.in
   branches/gui/bin/client2.bat.in
   branches/gui/bin/client2.in
   branches/gui/bin/dedicated.bat.in
   branches/gui/bin/dedicated.in
   branches/gui/bin/server.bat.in
   branches/gui/bin/server.in
   branches/gui/bin/standalone.bat.in
   branches/gui/bin/standalone.in
   branches/gui/src/core/Core.cc
   branches/gui/src/core/Core.h
   branches/gui/src/orxonox/Main.cc
   branches/gui/src/orxonox/gamestates/GSGraphics.h
   branches/gui/src/orxonox/gamestates/GSRoot.cc
   branches/gui/src/orxonox/gamestates/GSRoot.h
   branches/gui/src/orxonox/objects/worldentities/Model.cc
   branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc
Log:
Moved all core related initialisations from Main.cc and GSRoot.cc to Core.cc so that everything sticks together more obviously.

Renamed --directory command line argument: Name really doesn't say what it is.
using --writingPathSuffix now. Not much better, but at least you wonder ^^

Modified: branches/gui/bin/client1.bat.in
===================================================================
--- branches/gui/bin/client1.bat.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/client1.bat.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 title @PROJECT_NAME@
 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
- at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --directory client1
+ at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client1
 pause

Modified: branches/gui/bin/client1.in
===================================================================
--- branches/gui/bin/client1.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/client1.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 #!/bin/sh
 # convenience script for starting orxonox on Linux
 
-exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --directory client1 $@
+exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client1 $@

Modified: branches/gui/bin/client2.bat.in
===================================================================
--- branches/gui/bin/client2.bat.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/client2.bat.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 title @PROJECT_NAME@
 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
- at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --directory client2
+ at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client2
 pause

Modified: branches/gui/bin/client2.in
===================================================================
--- branches/gui/bin/client2.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/client2.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 #!/bin/sh
 # convenience script for starting orxonox on Linux
 
-exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --directory client2 $@
+exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client2 $@

Modified: branches/gui/bin/dedicated.bat.in
===================================================================
--- branches/gui/bin/dedicated.bat.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/dedicated.bat.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 title @PROJECT_NAME@
 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
- at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state dedicated --directory dedicated
+ at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state dedicated --writingPathSuffix dedicated
 pause

Modified: branches/gui/bin/dedicated.in
===================================================================
--- branches/gui/bin/dedicated.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/dedicated.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 #!/bin/sh
 # convenience script for starting orxonox on Linux
 
-exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state dedicated --directory dedicated $@
+exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state dedicated --writingPathSuffix dedicated $@

Modified: branches/gui/bin/server.bat.in
===================================================================
--- branches/gui/bin/server.bat.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/server.bat.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 title @PROJECT_NAME@
 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
- at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state server --directory server
+ at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state server --writingPathSuffix server
 pause

Modified: branches/gui/bin/server.in
===================================================================
--- branches/gui/bin/server.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/server.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 #!/bin/sh
 # convenience script for starting orxonox on Linux
 
-exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state server --directory server $@
+exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state server --writingPathSuffix server $@

Modified: branches/gui/bin/standalone.bat.in
===================================================================
--- branches/gui/bin/standalone.bat.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/standalone.bat.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 title @PROJECT_NAME@
 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
- at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state standalone --directory standalone
+ at CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state standalone --writingPathSuffix standalone
 pause

Modified: branches/gui/bin/standalone.in
===================================================================
--- branches/gui/bin/standalone.in	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/bin/standalone.in	2009-03-18 20:15:39 UTC (rev 2799)
@@ -1,4 +1,4 @@
 #!/bin/sh
 # convenience script for starting orxonox on Linux
 
-exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state standalone --directory standalone $@
+exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state standalone --writingPathSuffix standalone $@

Modified: branches/gui/src/core/Core.cc
===================================================================
--- branches/gui/src/core/Core.cc	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/core/Core.cc	2009-03-18 20:15:39 UTC (rev 2799)
@@ -21,8 +21,9 @@
  *
  *   Author:
  *      Fabian 'x3n' Landau
+ *      Reto Grieder
  *   Co-authors:
- *      Reto Grieder
+ *      ...
  *
  */
 
@@ -40,6 +41,9 @@
 #include <boost/filesystem.hpp>
 
 #ifdef ORXONOX_PLATFORM_WINDOWS
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
 #  include <windows.h>
 #elif defined(ORXONOX_PLATFORM_APPLE)
 #  include <sys/param.h>
@@ -50,12 +54,22 @@
 #endif
 
 #include "SpecialConfig.h"
+#include "util/Debug.h"
 #include "util/Exception.h"
+#include "util/SignalHandler.h"
+#include "Clock.h"
+#include "CommandExecutor.h"
+#include "CommandLine.h"
+#include "ConfigFileManager.h"
+#include "ConfigValueIncludes.h"
+#include "CoreIncludes.h"
+#include "Factory.h"
+#include "Identifier.h"
 #include "Language.h"
-#include "CoreIncludes.h"
-#include "ConfigValueIncludes.h"
 #include "LuaBind.h"
-#include "CommandLine.h"
+#include "Shell.h"
+#include "TclBind.h"
+#include "TclThreadManager.h"
 
 namespace orxonox
 {
@@ -72,35 +86,92 @@
     bool Core::bIsStandalone_s  = false;
     bool Core::bIsMaster_s      = false;
 
-    bool Core::isDevBuild_s     = false;
     Core* Core::singletonRef_s  = 0;
 
     SetCommandLineArgument(mediaPath, "").information("PATH");
-    SetCommandLineArgument(directory, "").information("DIR");
+    SetCommandLineArgument(writingPathSuffix, "").information("DIR");
+    SetCommandLineArgument(settingsFile, "orxonox.ini");
+    SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
 
     /**
         @brief Constructor: Registers the object and sets the config-values.
         @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
     */
-    Core::Core()
+    Core::Core(int argc, char** argv)
     {
         RegisterRootObject(Core);
 
         assert(Core::singletonRef_s == 0);
         Core::singletonRef_s = this;
 
-        this->bInitializeRandomNumberGenerator_ = false;
-        this->setConfigValues();
+        // Parse command line arguments fist
+        try
+        {
+            CommandLine::parseAll(argc, argv);
+        }
+        catch (ArgumentException& ex)
+        {
+            COUT(1) << ex.what() << std::endl;
+            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
+        }
 
+        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
+        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
+        // the timer though).
+        int limitToCPU = CommandLine::getValue("limitToCPU");
+        if (limitToCPU > 0)
+            setThreadAffinity((unsigned int)limitToCPU);
+
+        // Determine and set the location of the executable
+        setExecutablePath();
+
+        // Determine whether we have an installed or a binary dir run
+        // The latter occurs when simply running from the build directory
+        checkDevBuild();
+
+        // Make sure the directories we write in exist or else make them
+        createDirectories();
+
+        // create a signal handler (only active for linux)
+        // This call is placed as soon as possible, but after the directories are set
+        this->signalHandler_ = new SignalHandler();
+        this->signalHandler_->doCatch(executablePath_g.string(), Core::getLogPathString() + "orxonox_crash.log");
+
         // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
         OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
 
+        // Manage ini files and set the default settings file (usually orxonox.ini)
+        this->configFileManager_ = new ConfigFileManager();
+        this->configFileManager_->setFilename(ConfigFileType::Settings,
+            CommandLine::getValue("settingsFile").getString());
+
+        this->languageInstance_ = new Language();
+
+        // Do this soon after the ConfigFileManager has been created to open up the
+        // possibility to configure everything below here
+        this->setConfigValues();
+
         // Possible media path override by the command line
         if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
         {
             //std::string mediaPath = CommandLine::getValue("mediaPath");
             Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
         }
+
+        // Create the lua interface
+        this->luaBind_ = new LuaBind();
+
+        // initialise Tcl
+        this->tclBind_ = new TclBind(Core::getMediaPathString());
+        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
+
+        // create a shell
+        this->shell_ = new Shell();
+
+        // creates the class hierarchy for all classes with factories
+        Factory::createClassHierarchy();
+        
+        this->loaded_ = true;
     }
 
     /**
@@ -108,6 +179,21 @@
     */
     Core::~Core()
     {
+        this->loaded_ = false;
+
+        delete this->shell_;
+        delete this->tclThreadManager_;
+        delete this->tclBind_;
+        delete this->luaBind_;
+        delete this->languageInstance_;
+        delete this->configFileManager_;
+        delete this->signalHandler_;
+
+        // Destroy command line arguments
+        CommandLine::destroyAllArguments();
+        // Also delete external console command that don't belong to an Identifier
+        CommandExecutor::destroyExternalCommands();
+
         assert(Core::singletonRef_s);
         Core::singletonRef_s = 0;
     }
@@ -291,32 +377,57 @@
         }
     }
 
+
     /**
-    @brief
-        Performs the rather lower level operations just after
-        int main() has been called.
-    @remarks
-        This gets called AFTER pre-main stuff like AddFactory,
-        SetConsoleCommand, etc.
+    @note
+        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
+            (Object-oriented Graphics Rendering Engine)
+        For the latest info, see http://www.ogre3d.org/
+
+        Copyright (c) 2000-2008 Torus Knot Software Ltd
+
+        OGRE is licensed under the LGPL. For more info, see OGRE license.
     */
-    /*static*/ void Core::postMainInitialisation()
+    void Core::setThreadAffinity(int limitToCPU)
     {
-        // set location of the executable
-        Core::setExecutablePath();
+        if (limitToCPU <= 0)
+            return;
 
-        // Determine whether we have an installed or a binary dir run
-        // The latter occurs when simply running from the build directory
-        Core::checkDevBuild();
+        unsigned int coreNr = limitToCPU - 1;
+#ifdef ORXONOX_PLATFORM_WINDOWS
+        // Get the current process core mask
+        DWORD procMask;
+        DWORD sysMask;
+#  if _MSC_VER >= 1400 && defined (_M_X64)
+        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
+#  else
+        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
+#  endif
 
-        // Make sure the directories we write in exist or else make them
-        Core::createDirectories();
+        // If procMask is 0, consider there is only one core available
+        // (using 0 as procMask will cause an infinite loop below)
+        if (procMask == 0)
+            procMask = 1;
+
+        // if the core specified with coreNr is not available, take the lowest one
+        if (!(procMask & (1 << coreNr)))
+            coreNr = 0;
+
+        // Find the lowest core that this process uses and coreNr suggests
+        DWORD threadMask = 1;
+        while ((threadMask & procMask) == 0 || (threadMask < (1u << coreNr)))
+            threadMask <<= 1;
+
+        // Set affinity to the first core
+        SetThreadAffinityMask(GetCurrentThread(), threadMask);
+#endif
     }
 
     /**
     @brief
         Compares the executable path with the working directory
     */
-    /*static*/ void Core::setExecutablePath()
+    void Core::setExecutablePath()
     {
 #ifdef ORXONOX_PLATFORM_WINDOWS
         // get executable module
@@ -368,12 +479,12 @@
         If found it means that this is not an installed run, hence we
         don't write the logs and config files to ~/.orxonox
     */
-    /*static*/ void Core::checkDevBuild()
+    void Core::checkDevBuild()
     {
         if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
         {
             COUT(1) << "Running from the build tree." << std::endl;
-            Core::isDevBuild_s = true;
+            Core::isDevBuild_ = true;
             mediaPath_g  = ORXONOX_MEDIA_DEV_PATH;
             configPath_g = ORXONOX_CONFIG_DEV_PATH;
             logPath_g    = ORXONOX_LOG_DEV_PATH;
@@ -415,9 +526,9 @@
         }
 
         // Option to put all the config and log files in a separate folder
-        if (!CommandLine::getArgument("directory")->hasDefaultValue())
+        if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
         {
-            std::string directory(CommandLine::getValue("directory").getString());
+            std::string directory(CommandLine::getValue("writingPathSuffix").getString());
             configPath_g = configPath_g / directory;
             logPath_g    = logPath_g    / directory;
         }
@@ -428,7 +539,7 @@
         Checks for the log and the config directory and creates them
         if necessary. Otherwise me might have problems opening those files.
     */
-    /*static*/ void Core::createDirectories()
+    void Core::createDirectories()
     {
         std::vector<std::pair<boost::filesystem::path, std::string> > directories;
         directories.push_back(std::pair<boost::filesystem::path, std::string>
@@ -450,4 +561,9 @@
             }
         }
     }
+
+    void Core::tick(const Clock& time)
+    {
+        this->tclThreadManager_->tick(time.getDeltaTime());
+    }
 }

Modified: branches/gui/src/core/Core.h
===================================================================
--- branches/gui/src/core/Core.h	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/core/Core.h	2009-03-18 20:15:39 UTC (rev 2799)
@@ -21,8 +21,9 @@
  *
  *   Author:
  *      Fabian 'x3n' Landau
+ *      Reto Grieder
  *   Co-authors:
- *      Reto Grieder
+ *      ...
  *
  */
 
@@ -58,13 +59,14 @@
     //! The Core class is a singleton, only used to configure some config-values.
     class _CoreExport Core : public OrxonoxClass
     {
-        friend int ::main(int, char**); // sets isDevBuild_s
-
         public:
-            Core();
+            Core(int argc, char** argv);
             ~Core();
             void setConfigValues();
 
+            bool isLoaded() { return this->loaded_; }
+            void tick(const Clock& time);
+
             static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
 
             static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
@@ -72,8 +74,6 @@
             static const std::string& getLanguage();
             static void  resetLanguage();
 
-            static bool isDevBuild() { return Core::isDevBuild_s; }
-
             static void tsetMediaPath(const std::string& path)
             { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
             static const boost::filesystem::path& getMediaPath();
@@ -97,6 +97,12 @@
 
         private:
             Core(const Core&);
+
+            void checkDevBuild();
+            void setExecutablePath();
+            void createDirectories();
+            void setThreadAffinity(int limitToCPU);
+
             void resetLanguageIntern();
             void initializeRandomNumberGenerator();
             void debugLevelChanged();
@@ -104,10 +110,14 @@
             void mediaPathChanged();
             void _tsetMediaPath(const std::string& path);
 
-            static void postMainInitialisation();
-            static void checkDevBuild();
-            static void setExecutablePath();
-            static void createDirectories();
+            // Singletons
+            ConfigFileManager*    configFileManager_;
+            Language*             languageInstance_;
+            LuaBind*              luaBind_;
+            Shell*                shell_;
+            SignalHandler*        signalHandler_;
+            TclBind*              tclBind_;
+            TclThreadManager*     tclThreadManager_;
 
             int softDebugLevel_;                            //!< The debug level
             int softDebugLevelConsole_;                     //!< The debug level for the console
@@ -116,6 +126,8 @@
             std::string language_;                          //!< The language
             bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
             std::string mediaPathString_;                   //!< Path to the data/media file folder as string
+            bool isDevBuild_;                               //!< True for builds in the build directory (not installed)
+            bool loaded_;                                   //!< Only true if constructor was interrupted
 
             static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
             static bool bHasServer_s;                       //!< global variable that tells whether this is a server
@@ -123,8 +135,6 @@
             static bool bIsStandalone_s;
             static bool bIsMaster_s;
 
-            static bool isDevBuild_s;                       //!< True for builds in the build directory (not installed)
-
             static Core* singletonRef_s;
     };
 }

Modified: branches/gui/src/orxonox/Main.cc
===================================================================
--- branches/gui/src/orxonox/Main.cc	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/orxonox/Main.cc	2009-03-18 20:15:39 UTC (rev 2799)
@@ -33,19 +33,14 @@
   */
 
 #include "OrxonoxStableHeaders.h"
+#include "OrxonoxConfig.h"
 
 #include <exception>
 #include <cassert>
 
-#include "OrxonoxConfig.h"
 #include "util/Debug.h"
-#include "util/SignalHandler.h"
-#include "core/ConfigFileManager.h"
-#include "core/CommandLine.h"
-#include "core/CommandExecutor.h"
-#include "core/Identifier.h"
 #include "core/Core.h"
-#include "core/Language.h"
+#include "core/Identifier.h"
 
 #include "gamestates/GSRoot.h"
 #include "gamestates/GSGraphics.h"
@@ -84,41 +79,19 @@
 #endif
 
 
-SetCommandLineArgument(settingsFile, "orxonox.ini");
-SetCommandLineArgument(configFileDirectory, "");
 
 int main(int argc, char** argv)
 {
-    using namespace orxonox;
-
-    // Parse command line arguments
-    try
+    orxonox::Core* core = new orxonox::Core(argc, argv);
+    if (!core->isLoaded())
     {
-        CommandLine::parseAll(argc, argv);
+        COUT(0) << "Core was not fully loaded, probably an exception occurred during consruction. Aborting" << std::endl;
+        abort();
     }
-    catch (ArgumentException& ex)
-    {
-        COUT(1) << ex.what() << std::endl;
-        COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
-    }
 
-    // Do this after parsing the command line to allow customisation
-    Core::postMainInitialisation();
-
-    // create a signal handler (only active for linux)
-    SignalHandler signalHandler;
-    signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log");
-
-    // Create the ConfigFileManager before creating the GameStates in order to have
-    // setConfigValues() in the constructor (required).
-    ConfigFileManager* configFileManager = new ConfigFileManager();
-    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
-    // create the Core settings to configure the output level
-    Language* language = new Language();
-    Core*     core     = new Core();
-
     // put GameStates in its own scope so we can destroy the identifiers at the end of main().
     {
+        using namespace orxonox;
         // create the gamestates
         GSRoot root;
         GSGraphics graphics;
@@ -142,17 +115,12 @@
         root.start();
     }
 
-    // destroy singletons
+    // Destroy pretty much everyhting left
     delete core;
-    delete language;
-    delete configFileManager;
 
     // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
-    Identifier::destroyAllIdentifiers();
-    // destroy command line arguments
-    CommandLine::destroyAllArguments();
-    // Also delete external console command that don't belong to an Identifier
-    CommandExecutor::destroyExternalCommands();
+    // Needs to be done after 'delete core' because of ~OrxonoxClass
+    orxonox::Identifier::destroyAllIdentifiers();
 
     return 0;
 }

Modified: branches/gui/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- branches/gui/src/orxonox/gamestates/GSGraphics.h	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/orxonox/gamestates/GSGraphics.h	2009-03-18 20:15:39 UTC (rev 2799)
@@ -30,9 +30,9 @@
 #define _GSGraphics_H__
 
 #include "OrxonoxPrereqs.h"
-#include <OgrePrerequisites.h>
 #define NOMINMAX // required to stop windows.h screwing up std::min definition
 #include <OgreWindowEventUtilities.h>
+#include <OgreLog.h>
 #include "core/GameState.h"
 #include "core/OrxonoxClass.h"
 #include "GSRoot.h"

Modified: branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSRoot.cc	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/orxonox/gamestates/GSRoot.cc	2009-03-18 20:15:39 UTC (rev 2799)
@@ -32,38 +32,19 @@
 #include "util/Exception.h"
 #include "util/Debug.h"
 #include "core/Core.h"
-#include "core/Factory.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/ConsoleCommand.h"
-#include "core/CommandLine.h"
-#include "core/Shell.h"
-#include "core/TclBind.h"
-#include "core/TclThreadManager.h"
-#include "core/LuaBind.h"
 #include "tools/Timer.h"
 #include "objects/Tickable.h"
 
-#ifdef ORXONOX_PLATFORM_WINDOWS
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN
-#  endif
-#  define NOMINMAX // required to stop windows.h screwing up std::min definition
-#  include "windows.h"
-#endif
-
 namespace orxonox
 {
-    SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
-
     GSRoot::GSRoot()
         : RootGameState("root")
         , timeFactor_(1.0f)
         , bPaused_(false)
         , timeFactorPauseBackup_(1.0f)
-        , tclBind_(0)
-        , tclThreadManager_(0)
-        , shell_(0)
     {
         RegisterRootObject(GSRoot);
         setConfigValues();
@@ -86,9 +67,6 @@
 
     void GSRoot::enter()
     {
-        // creates the class hierarchy for all classes with factories
-        Factory::createClassHierarchy();
-
         // reset game speed to normal
         timeFactor_ = 1.0f;
 
@@ -99,23 +77,6 @@
         this->avgFPS_ = 0.0f;
         this->avgTickTime_ = 0.0f;
 
-        // Create the lua interface
-        this->luaBind_ = new LuaBind();
-
-        // initialise TCL
-        this->tclBind_ = new TclBind(Core::getMediaPathString());
-        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
-
-        // create a shell
-        this->shell_ = new Shell();
-
-        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
-        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
-        // the timer though).
-        int limitToCPU = CommandLine::getValue("limitToCPU");
-        if (limitToCPU > 0)
-            setThreadAffinity((unsigned int)(limitToCPU - 1));
-
         {
             // add console commands
             FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame);
@@ -155,12 +116,6 @@
         delete this->ccExit_;
         delete this->ccSelectGameState_;
 
-        delete this->shell_;
-        delete this->tclThreadManager_;
-        delete this->tclBind_;
-
-        delete this->luaBind_;
-
         if (this->ccSetTimeFactor_)
         {
             delete this->ccSetTimeFactor_;
@@ -178,7 +133,7 @@
     {
         uint64_t timeBeforeTick = time.getRealMicroseconds();
 
-        TclThreadManager::getInstance().tick(time.getDeltaTime());
+        Core::getInstance().tick(time);
 
         for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
             it->tick(time);
@@ -234,47 +189,6 @@
     }
 
     /**
-    @note
-        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
-            (Object-oriented Graphics Rendering Engine)
-        For the latest info, see http://www.ogre3d.org/
-
-        Copyright (c) 2000-2008 Torus Knot Software Ltd
-
-        OGRE is licensed under the LGPL. For more info, see OGRE license.
-    */
-    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
-    {
-#ifdef ORXONOX_PLATFORM_WINDOWS
-        // Get the current process core mask
-        DWORD procMask;
-        DWORD sysMask;
-#  if _MSC_VER >= 1400 && defined (_M_X64)
-        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
-#  else
-        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
-#  endif
-
-        // If procMask is 0, consider there is only one core available
-        // (using 0 as procMask will cause an infinite loop below)
-        if (procMask == 0)
-            procMask = 1;
-
-        // if the core specified with limitToCPU is not available, take the lowest one
-        if (!(procMask & (1 << limitToCPU)))
-            limitToCPU = 0;
-
-        // Find the lowest core that this process uses and limitToCPU suggests
-        DWORD threadMask = 1;
-        while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
-            threadMask <<= 1;
-
-        // Set affinity to the first core
-        SetThreadAffinityMask(GetCurrentThread(), threadMask);
-#endif
-    }
-
-    /**
     @brief
         Changes the speed of Orxonox
     */

Modified: branches/gui/src/orxonox/gamestates/GSRoot.h
===================================================================
--- branches/gui/src/orxonox/gamestates/GSRoot.h	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/orxonox/gamestates/GSRoot.h	2009-03-18 20:15:39 UTC (rev 2799)
@@ -32,7 +32,6 @@
 #include "OrxonoxPrereqs.h"
 
 #include <list>
-#include <OgreLog.h>
 #include "core/RootGameState.h"
 #include "core/OrxonoxClass.h"
 
@@ -75,15 +74,10 @@
         void ticked(const Clock& time);
 
         void setConfigValues();
-        void setThreadAffinity(unsigned int limitToCPU);
 
         float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
         bool                  bPaused_;
         float                 timeFactorPauseBackup_;
-        TclBind*              tclBind_;
-        TclThreadManager*     tclThreadManager_;
-        Shell*                shell_;
-        LuaBind*              luaBind_;
 
         // variables for time statistics
         uint64_t              statisticsStartTime_;

Modified: branches/gui/src/orxonox/objects/worldentities/Model.cc
===================================================================
--- branches/gui/src/orxonox/objects/worldentities/Model.cc	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/orxonox/objects/worldentities/Model.cc	2009-03-18 20:15:39 UTC (rev 2799)
@@ -30,6 +30,7 @@
 
 #include <OgreEntity.h>
 #include "Model.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "objects/Scene.h"

Modified: branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc
===================================================================
--- branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc	2009-03-18 20:00:48 UTC (rev 2798)
+++ branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc	2009-03-18 20:15:39 UTC (rev 2799)
@@ -38,6 +38,7 @@
 
 #include "tools/ParticleInterface.h"
 #include "util/Exception.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "objects/Scene.h"




More information about the Orxonox-commit mailing list