Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3358


Ignore:
Timestamp:
Jul 27, 2009, 2:42:37 PM (15 years ago)
Author:
rgrieder
Message:

Moved startup argument parsing (console, dedicated, server, client and standalone) from GSRoot.cc to Main.cc.
This allows to finally prevent GameState request while loading/unloading them (changed the code in Game.cc to enforce this).

Location:
code/branches/resource/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/core/Game.cc

    r3356 r3358  
    390390        }
    391391
    392         //if (this->bChangingState_)
    393         //{
    394         //    COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
    395         //    return;
    396         //}
     392        if (this->bChangingState_)
     393        {
     394            COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
     395            return;
     396        }
    397397
    398398        shared_ptr<GameStateTreeNode> lastRequestedNode;
  • code/branches/resource/src/orxonox/Main.cc

    r3323 r3358  
    4646#include "util/Debug.h"
    4747#include "util/Exception.h"
     48#include "core/CommandLine.h"
    4849#include "core/Game.h"
     50
     51SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
     52// Shortcuts for easy direct loading
     53SetCommandLineSwitch(server).information("Start in server mode");
     54SetCommandLineSwitch(client).information("Start in client mode");
     55SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
     56SetCommandLineSwitch(standalone).information("Start in standalone mode");
    4957
    5058/*
     
    8694
    8795        game->requestState("root");
     96
     97        // Some development hacks (not really, but in the future, this calls won't make sense anymore)
     98        if (CommandLine::getValue("standalone").getBool())
     99            Game::getInstance().requestStates("graphics, standalone, level");
     100        else if (CommandLine::getValue("server").getBool())
     101            Game::getInstance().requestStates("graphics, server, level");
     102        else if (CommandLine::getValue("client").getBool())
     103            Game::getInstance().requestStates("graphics, client, level");
     104        else if (CommandLine::getValue("dedicated").getBool())
     105            Game::getInstance().requestStates("dedicated, level");
     106        else if (CommandLine::getValue("console").getBool())
     107            Game::getInstance().requestStates("ioConsole");
     108        else
     109            Game::getInstance().requestStates("graphics, mainMenu");
    88110    }
    89111    catch (const std::exception& ex)
  • code/branches/resource/src/orxonox/gamestates/GSGraphics.cc

    r3357 r3358  
    6868        masterInputState_ = InputManager::getInstance().createInputState("master", true);
    6969        masterKeyBinder_ = new KeyBinder();
     70        masterInputState_->setKeyHandler(masterKeyBinder_);
    7071    }
    7172
     
    99100
    100101        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    101         masterInputState_->setKeyHandler(masterKeyBinder_);
    102102
    103103        // Load the SoundManager
  • code/branches/resource/src/orxonox/gamestates/GSRoot.cc

    r3355 r3358  
    3030
    3131#include "core/Clock.h"
    32 #include "core/CommandLine.h"
    3332#include "core/ConsoleCommand.h"
    3433#include "core/Game.h"
     
    4645{
    4746    DeclareGameState(GSRoot, "root", false, false);
    48     SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
    49     // Shortcuts for easy direct loading
    50     SetCommandLineSwitch(server).information("Start in server mode");
    51     SetCommandLineSwitch(client).information("Start in client mode");
    52     SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
    53     SetCommandLineSwitch(standalone).information("Start in standalone mode");
    5447
    5548    GSRoot::GSRoot(const GameStateInfo& info)
     
    9588        // create the global LevelManager
    9689        this->levelManager_ = new LevelManager();
    97 
    98         // Load level directly?
    99         bool loadLevel = false;
    100         if (CommandLine::getValue("standalone").getBool())
    101         {
    102             Game::getInstance().requestStates("graphics, standalone, level");
    103             loadLevel = true;
    104         }
    105         if (CommandLine::getValue("server").getBool())
    106         {
    107             Game::getInstance().requestStates("graphics, server, level");
    108             loadLevel = true;
    109         }
    110         if (CommandLine::getValue("client").getBool())
    111         {
    112             Game::getInstance().requestStates("graphics, client, level");
    113             loadLevel = true;
    114         }
    115         if (CommandLine::getValue("dedicated").getBool())
    116         {
    117             Game::getInstance().requestStates("dedicated, level");
    118             loadLevel = true;
    119         }
    120        
    121         // Determine where to start otherwise
    122         if (!loadLevel && !CommandLine::getValue("console").getBool())
    123         {
    124             // Also load graphics
    125             Game::getInstance().requestState("graphics");
    126         }
    12790    }
    12891
Note: See TracChangeset for help on using the changeset viewer.