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

Location:
code/branches/gui/src/orxonox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 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.