Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.