Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2799 for code/branches


Ignore:
Timestamp:
Mar 18, 2009, 9:15:39 PM (16 years ago)
Author:
rgrieder
Message:

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

Location:
code/branches/gui
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/bin/client1.bat.in

    r2729 r2799  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --directory client1
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client1
    44pause
  • code/branches/gui/bin/client1.in

    r2730 r2799  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --directory client1 $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client1 $@
  • code/branches/gui/bin/client2.bat.in

    r2729 r2799  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --directory client2
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client2
    44pause
  • code/branches/gui/bin/client2.in

    r2730 r2799  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --directory client2 $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --writingPathSuffix client2 $@
  • code/branches/gui/bin/dedicated.bat.in

    r2729 r2799  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state dedicated --directory dedicated
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state dedicated --writingPathSuffix dedicated
    44pause
  • code/branches/gui/bin/dedicated.in

    r2730 r2799  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state dedicated --directory dedicated $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state dedicated --writingPathSuffix dedicated $@
  • code/branches/gui/bin/server.bat.in

    r2729 r2799  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state server --directory server
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state server --writingPathSuffix server
    44pause
  • code/branches/gui/bin/server.in

    r2730 r2799  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state server --directory server $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state server --writingPathSuffix server $@
  • code/branches/gui/bin/standalone.bat.in

    r2762 r2799  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state standalone --directory standalone
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state standalone --writingPathSuffix standalone
    44pause
  • code/branches/gui/bin/standalone.in

    r2762 r2799  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state standalone --directory standalone $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state standalone --writingPathSuffix standalone $@
  • code/branches/gui/src/core/Core.cc

    r2759 r2799  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    25  *      Reto Grieder
     26 *      ...
    2627 *
    2728 */
     
    4142
    4243#ifdef ORXONOX_PLATFORM_WINDOWS
     44#  ifndef WIN32_LEAN_AND_MEAN
     45#    define WIN32_LEAN_AND_MEAN
     46#  endif
    4347#  include <windows.h>
    4448#elif defined(ORXONOX_PLATFORM_APPLE)
     
    5155
    5256#include "SpecialConfig.h"
     57#include "util/Debug.h"
    5358#include "util/Exception.h"
     59#include "util/SignalHandler.h"
     60#include "Clock.h"
     61#include "CommandExecutor.h"
     62#include "CommandLine.h"
     63#include "ConfigFileManager.h"
     64#include "ConfigValueIncludes.h"
     65#include "CoreIncludes.h"
     66#include "Factory.h"
     67#include "Identifier.h"
    5468#include "Language.h"
    55 #include "CoreIncludes.h"
    56 #include "ConfigValueIncludes.h"
    5769#include "LuaBind.h"
    58 #include "CommandLine.h"
     70#include "Shell.h"
     71#include "TclBind.h"
     72#include "TclThreadManager.h"
    5973
    6074namespace orxonox
     
    7387    bool Core::bIsMaster_s      = false;
    7488
    75     bool Core::isDevBuild_s     = false;
    7689    Core* Core::singletonRef_s  = 0;
    7790
    7891    SetCommandLineArgument(mediaPath, "").information("PATH");
    79     SetCommandLineArgument(directory, "").information("DIR");
     92    SetCommandLineArgument(writingPathSuffix, "").information("DIR");
     93    SetCommandLineArgument(settingsFile, "orxonox.ini");
     94    SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
    8095
    8196    /**
     
    8398        @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
    8499    */
    85     Core::Core()
     100    Core::Core(int argc, char** argv)
    86101    {
    87102        RegisterRootObject(Core);
     
    90105        Core::singletonRef_s = this;
    91106
    92         this->bInitializeRandomNumberGenerator_ = false;
    93         this->setConfigValues();
     107        // Parse command line arguments fist
     108        try
     109        {
     110            CommandLine::parseAll(argc, argv);
     111        }
     112        catch (ArgumentException& ex)
     113        {
     114            COUT(1) << ex.what() << std::endl;
     115            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
     116        }
     117
     118        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
     119        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
     120        // the timer though).
     121        int limitToCPU = CommandLine::getValue("limitToCPU");
     122        if (limitToCPU > 0)
     123            setThreadAffinity((unsigned int)limitToCPU);
     124
     125        // Determine and set the location of the executable
     126        setExecutablePath();
     127
     128        // Determine whether we have an installed or a binary dir run
     129        // The latter occurs when simply running from the build directory
     130        checkDevBuild();
     131
     132        // Make sure the directories we write in exist or else make them
     133        createDirectories();
     134
     135        // create a signal handler (only active for linux)
     136        // This call is placed as soon as possible, but after the directories are set
     137        this->signalHandler_ = new SignalHandler();
     138        this->signalHandler_->doCatch(executablePath_g.string(), Core::getLogPathString() + "orxonox_crash.log");
    94139
    95140        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
    96141        OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
    97142
     143        // Manage ini files and set the default settings file (usually orxonox.ini)
     144        this->configFileManager_ = new ConfigFileManager();
     145        this->configFileManager_->setFilename(ConfigFileType::Settings,
     146            CommandLine::getValue("settingsFile").getString());
     147
     148        this->languageInstance_ = new Language();
     149
     150        // Do this soon after the ConfigFileManager has been created to open up the
     151        // possibility to configure everything below here
     152        this->setConfigValues();
     153
    98154        // Possible media path override by the command line
    99155        if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
     
    102158            Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
    103159        }
     160
     161        // Create the lua interface
     162        this->luaBind_ = new LuaBind();
     163
     164        // initialise Tcl
     165        this->tclBind_ = new TclBind(Core::getMediaPathString());
     166        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
     167
     168        // create a shell
     169        this->shell_ = new Shell();
     170
     171        // creates the class hierarchy for all classes with factories
     172        Factory::createClassHierarchy();
     173       
     174        this->loaded_ = true;
    104175    }
    105176
     
    109180    Core::~Core()
    110181    {
     182        this->loaded_ = false;
     183
     184        delete this->shell_;
     185        delete this->tclThreadManager_;
     186        delete this->tclBind_;
     187        delete this->luaBind_;
     188        delete this->languageInstance_;
     189        delete this->configFileManager_;
     190        delete this->signalHandler_;
     191
     192        // Destroy command line arguments
     193        CommandLine::destroyAllArguments();
     194        // Also delete external console command that don't belong to an Identifier
     195        CommandExecutor::destroyExternalCommands();
     196
    111197        assert(Core::singletonRef_s);
    112198        Core::singletonRef_s = 0;
     
    292378    }
    293379
    294     /**
    295     @brief
    296         Performs the rather lower level operations just after
    297         int main() has been called.
    298     @remarks
    299         This gets called AFTER pre-main stuff like AddFactory,
    300         SetConsoleCommand, etc.
    301     */
    302     /*static*/ void Core::postMainInitialisation()
    303     {
    304         // set location of the executable
    305         Core::setExecutablePath();
    306 
    307         // Determine whether we have an installed or a binary dir run
    308         // The latter occurs when simply running from the build directory
    309         Core::checkDevBuild();
    310 
    311         // Make sure the directories we write in exist or else make them
    312         Core::createDirectories();
     380
     381    /**
     382    @note
     383        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
     384            (Object-oriented Graphics Rendering Engine)
     385        For the latest info, see http://www.ogre3d.org/
     386
     387        Copyright (c) 2000-2008 Torus Knot Software Ltd
     388
     389        OGRE is licensed under the LGPL. For more info, see OGRE license.
     390    */
     391    void Core::setThreadAffinity(int limitToCPU)
     392    {
     393        if (limitToCPU <= 0)
     394            return;
     395
     396        unsigned int coreNr = limitToCPU - 1;
     397#ifdef ORXONOX_PLATFORM_WINDOWS
     398        // Get the current process core mask
     399        DWORD procMask;
     400        DWORD sysMask;
     401#  if _MSC_VER >= 1400 && defined (_M_X64)
     402        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
     403#  else
     404        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
     405#  endif
     406
     407        // If procMask is 0, consider there is only one core available
     408        // (using 0 as procMask will cause an infinite loop below)
     409        if (procMask == 0)
     410            procMask = 1;
     411
     412        // if the core specified with coreNr is not available, take the lowest one
     413        if (!(procMask & (1 << coreNr)))
     414            coreNr = 0;
     415
     416        // Find the lowest core that this process uses and coreNr suggests
     417        DWORD threadMask = 1;
     418        while ((threadMask & procMask) == 0 || (threadMask < (1u << coreNr)))
     419            threadMask <<= 1;
     420
     421        // Set affinity to the first core
     422        SetThreadAffinityMask(GetCurrentThread(), threadMask);
     423#endif
    313424    }
    314425
     
    317428        Compares the executable path with the working directory
    318429    */
    319     /*static*/ void Core::setExecutablePath()
     430    void Core::setExecutablePath()
    320431    {
    321432#ifdef ORXONOX_PLATFORM_WINDOWS
     
    369480        don't write the logs and config files to ~/.orxonox
    370481    */
    371     /*static*/ void Core::checkDevBuild()
     482    void Core::checkDevBuild()
    372483    {
    373484        if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
    374485        {
    375486            COUT(1) << "Running from the build tree." << std::endl;
    376             Core::isDevBuild_s = true;
     487            Core::isDevBuild_ = true;
    377488            mediaPath_g  = ORXONOX_MEDIA_DEV_PATH;
    378489            configPath_g = ORXONOX_CONFIG_DEV_PATH;
     
    416527
    417528        // Option to put all the config and log files in a separate folder
    418         if (!CommandLine::getArgument("directory")->hasDefaultValue())
    419         {
    420             std::string directory(CommandLine::getValue("directory").getString());
     529        if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
     530        {
     531            std::string directory(CommandLine::getValue("writingPathSuffix").getString());
    421532            configPath_g = configPath_g / directory;
    422533            logPath_g    = logPath_g    / directory;
     
    429540        if necessary. Otherwise me might have problems opening those files.
    430541    */
    431     /*static*/ void Core::createDirectories()
     542    void Core::createDirectories()
    432543    {
    433544        std::vector<std::pair<boost::filesystem::path, std::string> > directories;
     
    451562        }
    452563    }
     564
     565    void Core::tick(const Clock& time)
     566    {
     567        this->tclThreadManager_->tick(time.getDeltaTime());
     568    }
    453569}
  • code/branches/gui/src/core/Core.h

    r2759 r2799  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    25  *      Reto Grieder
     26 *      ...
    2627 *
    2728 */
     
    5960    class _CoreExport Core : public OrxonoxClass
    6061    {
    61         friend int ::main(int, char**); // sets isDevBuild_s
    62 
    6362        public:
    64             Core();
     63            Core(int argc, char** argv);
    6564            ~Core();
    6665            void setConfigValues();
     66
     67            bool isLoaded() { return this->loaded_; }
     68            void tick(const Clock& time);
    6769
    6870            static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
     
    7274            static const std::string& getLanguage();
    7375            static void  resetLanguage();
    74 
    75             static bool isDevBuild() { return Core::isDevBuild_s; }
    7676
    7777            static void tsetMediaPath(const std::string& path)
     
    9898        private:
    9999            Core(const Core&);
     100
     101            void checkDevBuild();
     102            void setExecutablePath();
     103            void createDirectories();
     104            void setThreadAffinity(int limitToCPU);
     105
    100106            void resetLanguageIntern();
    101107            void initializeRandomNumberGenerator();
     
    105111            void _tsetMediaPath(const std::string& path);
    106112
    107             static void postMainInitialisation();
    108             static void checkDevBuild();
    109             static void setExecutablePath();
    110             static void createDirectories();
     113            // Singletons
     114            ConfigFileManager*    configFileManager_;
     115            Language*             languageInstance_;
     116            LuaBind*              luaBind_;
     117            Shell*                shell_;
     118            SignalHandler*        signalHandler_;
     119            TclBind*              tclBind_;
     120            TclThreadManager*     tclThreadManager_;
    111121
    112122            int softDebugLevel_;                            //!< The debug level
     
    117127            bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    118128            std::string mediaPathString_;                   //!< Path to the data/media file folder as string
     129            bool isDevBuild_;                               //!< True for builds in the build directory (not installed)
     130            bool loaded_;                                   //!< Only true if constructor was interrupted
    119131
    120132            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     
    124136            static bool bIsMaster_s;
    125137
    126             static bool isDevBuild_s;                       //!< True for builds in the build directory (not installed)
    127 
    128138            static Core* singletonRef_s;
    129139    };
  • code/branches/gui/src/orxonox/Main.cc

    r2716 r2799  
    3434
    3535#include "OrxonoxStableHeaders.h"
     36#include "OrxonoxConfig.h"
    3637
    3738#include <exception>
    3839#include <cassert>
    3940
    40 #include "OrxonoxConfig.h"
    4141#include "util/Debug.h"
    42 #include "util/SignalHandler.h"
    43 #include "core/ConfigFileManager.h"
    44 #include "core/CommandLine.h"
    45 #include "core/CommandExecutor.h"
     42#include "core/Core.h"
    4643#include "core/Identifier.h"
    47 #include "core/Core.h"
    48 #include "core/Language.h"
    4944
    5045#include "gamestates/GSRoot.h"
     
    8580
    8681
    87 SetCommandLineArgument(settingsFile, "orxonox.ini");
    88 SetCommandLineArgument(configFileDirectory, "");
    8982
    9083int main(int argc, char** argv)
    9184{
    92     using namespace orxonox;
    93 
    94     // Parse command line arguments
    95     try
     85    orxonox::Core* core = new orxonox::Core(argc, argv);
     86    if (!core->isLoaded())
    9687    {
    97         CommandLine::parseAll(argc, argv);
     88        COUT(0) << "Core was not fully loaded, probably an exception occurred during consruction. Aborting" << std::endl;
     89        abort();
    9890    }
    99     catch (ArgumentException& ex)
    100     {
    101         COUT(1) << ex.what() << std::endl;
    102         COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
    103     }
    104 
    105     // Do this after parsing the command line to allow customisation
    106     Core::postMainInitialisation();
    107 
    108     // create a signal handler (only active for linux)
    109     SignalHandler signalHandler;
    110     signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log");
    111 
    112     // Create the ConfigFileManager before creating the GameStates in order to have
    113     // setConfigValues() in the constructor (required).
    114     ConfigFileManager* configFileManager = new ConfigFileManager();
    115     configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
    116     // create the Core settings to configure the output level
    117     Language* language = new Language();
    118     Core*     core     = new Core();
    11991
    12092    // put GameStates in its own scope so we can destroy the identifiers at the end of main().
    12193    {
     94        using namespace orxonox;
    12295        // create the gamestates
    12396        GSRoot root;
     
    143116    }
    144117
    145     // destroy singletons
     118    // Destroy pretty much everyhting left
    146119    delete core;
    147     delete language;
    148     delete configFileManager;
    149120
    150121    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
    151     Identifier::destroyAllIdentifiers();
    152     // destroy command line arguments
    153     CommandLine::destroyAllArguments();
    154     // Also delete external console command that don't belong to an Identifier
    155     CommandExecutor::destroyExternalCommands();
     122    // Needs to be done after 'delete core' because of ~OrxonoxClass
     123    orxonox::Identifier::destroyAllIdentifiers();
    156124
    157125    return 0;
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.h

    r2756 r2799  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include <OgrePrerequisites.h>
    3433#define NOMINMAX // required to stop windows.h screwing up std::min definition
    3534#include <OgreWindowEventUtilities.h>
     35#include <OgreLog.h>
    3636#include "core/GameState.h"
    3737#include "core/OrxonoxClass.h"
  • code/branches/gui/src/orxonox/gamestates/GSRoot.cc

    r2759 r2799  
    3333#include "util/Debug.h"
    3434#include "core/Core.h"
    35 #include "core/Factory.h"
    3635#include "core/ConfigValueIncludes.h"
    3736#include "core/CoreIncludes.h"
    3837#include "core/ConsoleCommand.h"
    39 #include "core/CommandLine.h"
    40 #include "core/Shell.h"
    41 #include "core/TclBind.h"
    42 #include "core/TclThreadManager.h"
    43 #include "core/LuaBind.h"
    4438#include "tools/Timer.h"
    4539#include "objects/Tickable.h"
    4640
    47 #ifdef ORXONOX_PLATFORM_WINDOWS
    48 #  ifndef WIN32_LEAN_AND_MEAN
    49 #    define WIN32_LEAN_AND_MEAN
    50 #  endif
    51 #  define NOMINMAX // required to stop windows.h screwing up std::min definition
    52 #  include "windows.h"
    53 #endif
    54 
    5541namespace orxonox
    5642{
    57     SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
    58 
    5943    GSRoot::GSRoot()
    6044        : RootGameState("root")
     
    6246        , bPaused_(false)
    6347        , timeFactorPauseBackup_(1.0f)
    64         , tclBind_(0)
    65         , tclThreadManager_(0)
    66         , shell_(0)
    6748    {
    6849        RegisterRootObject(GSRoot);
     
    8768    void GSRoot::enter()
    8869    {
    89         // creates the class hierarchy for all classes with factories
    90         Factory::createClassHierarchy();
    91 
    9270        // reset game speed to normal
    9371        timeFactor_ = 1.0f;
     
    10078        this->avgTickTime_ = 0.0f;
    10179
    102         // Create the lua interface
    103         this->luaBind_ = new LuaBind();
    104 
    105         // initialise TCL
    106         this->tclBind_ = new TclBind(Core::getMediaPathString());
    107         this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
    108 
    109         // create a shell
    110         this->shell_ = new Shell();
    111 
    112         // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
    113         // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    114         // the timer though).
    115         int limitToCPU = CommandLine::getValue("limitToCPU");
    116         if (limitToCPU > 0)
    117             setThreadAffinity((unsigned int)(limitToCPU - 1));
    118 
    11980        {
    12081            // add console commands
     
    156117        delete this->ccSelectGameState_;
    157118
    158         delete this->shell_;
    159         delete this->tclThreadManager_;
    160         delete this->tclBind_;
    161 
    162         delete this->luaBind_;
    163 
    164119        if (this->ccSetTimeFactor_)
    165120        {
     
    179134        uint64_t timeBeforeTick = time.getRealMicroseconds();
    180135
    181         TclThreadManager::getInstance().tick(time.getDeltaTime());
     136        Core::getInstance().tick(time);
    182137
    183138        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
     
    235190
    236191    /**
    237     @note
    238         The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
    239             (Object-oriented Graphics Rendering Engine)
    240         For the latest info, see http://www.ogre3d.org/
    241 
    242         Copyright (c) 2000-2008 Torus Knot Software Ltd
    243 
    244         OGRE is licensed under the LGPL. For more info, see OGRE license.
    245     */
    246     void GSRoot::setThreadAffinity(unsigned int limitToCPU)
    247     {
    248 #ifdef ORXONOX_PLATFORM_WINDOWS
    249         // Get the current process core mask
    250         DWORD procMask;
    251         DWORD sysMask;
    252 #  if _MSC_VER >= 1400 && defined (_M_X64)
    253         GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
    254 #  else
    255         GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
    256 #  endif
    257 
    258         // If procMask is 0, consider there is only one core available
    259         // (using 0 as procMask will cause an infinite loop below)
    260         if (procMask == 0)
    261             procMask = 1;
    262 
    263         // if the core specified with limitToCPU is not available, take the lowest one
    264         if (!(procMask & (1 << limitToCPU)))
    265             limitToCPU = 0;
    266 
    267         // Find the lowest core that this process uses and limitToCPU suggests
    268         DWORD threadMask = 1;
    269         while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
    270             threadMask <<= 1;
    271 
    272         // Set affinity to the first core
    273         SetThreadAffinityMask(GetCurrentThread(), threadMask);
    274 #endif
    275     }
    276 
    277     /**
    278192    @brief
    279193        Changes the speed of Orxonox
  • code/branches/gui/src/orxonox/gamestates/GSRoot.h

    r2710 r2799  
    3333
    3434#include <list>
    35 #include <OgreLog.h>
    3635#include "core/RootGameState.h"
    3736#include "core/OrxonoxClass.h"
     
    7675
    7776        void setConfigValues();
    78         void setThreadAffinity(unsigned int limitToCPU);
    7977
    8078        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    8179        bool                  bPaused_;
    8280        float                 timeFactorPauseBackup_;
    83         TclBind*              tclBind_;
    84         TclThreadManager*     tclThreadManager_;
    85         Shell*                shell_;
    86         LuaBind*              luaBind_;
    8781
    8882        // variables for time statistics
  • code/branches/gui/src/orxonox/objects/worldentities/Model.cc

    r2662 r2799  
    3131#include <OgreEntity.h>
    3232#include "Model.h"
     33#include "core/Core.h"
    3334#include "core/CoreIncludes.h"
    3435#include "core/XMLPort.h"
  • code/branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2662 r2799  
    3939#include "tools/ParticleInterface.h"
    4040#include "util/Exception.h"
     41#include "core/Core.h"
    4142#include "core/CoreIncludes.h"
    4243#include "core/XMLPort.h"
Note: See TracChangeset for help on using the changeset viewer.