Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2009, 9:15:39 PM (15 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/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;
Note: See TracChangeset for help on using the changeset viewer.