[Orxonox-commit 843] r3358 - in branches/resource/src: core orxonox orxonox/gamestates
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon Jul 27 14:42:37 CEST 2009
Author: rgrieder
Date: 2009-07-27 14:42:37 +0200 (Mon, 27 Jul 2009)
New Revision: 3358
Modified:
branches/resource/src/core/Game.cc
branches/resource/src/orxonox/Main.cc
branches/resource/src/orxonox/gamestates/GSGraphics.cc
branches/resource/src/orxonox/gamestates/GSRoot.cc
Log:
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).
Modified: branches/resource/src/core/Game.cc
===================================================================
--- branches/resource/src/core/Game.cc 2009-07-27 11:57:28 UTC (rev 3357)
+++ branches/resource/src/core/Game.cc 2009-07-27 12:42:37 UTC (rev 3358)
@@ -389,11 +389,11 @@
return;
}
- //if (this->bChangingState_)
- //{
- // COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
- // return;
- //}
+ if (this->bChangingState_)
+ {
+ COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
+ return;
+ }
shared_ptr<GameStateTreeNode> lastRequestedNode;
if (this->requestedStateNodes_.empty())
Modified: branches/resource/src/orxonox/Main.cc
===================================================================
--- branches/resource/src/orxonox/Main.cc 2009-07-27 11:57:28 UTC (rev 3357)
+++ branches/resource/src/orxonox/Main.cc 2009-07-27 12:42:37 UTC (rev 3358)
@@ -45,8 +45,16 @@
#include "util/Debug.h"
#include "util/Exception.h"
+#include "core/CommandLine.h"
#include "core/Game.h"
+SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
+// Shortcuts for easy direct loading
+SetCommandLineSwitch(server).information("Start in server mode");
+SetCommandLineSwitch(client).information("Start in client mode");
+SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
+SetCommandLineSwitch(standalone).information("Start in standalone mode");
+
/*
@brief
Main method. Game starts here (except for static initialisations).
@@ -85,6 +93,20 @@
);
game->requestState("root");
+
+ // Some development hacks (not really, but in the future, this calls won't make sense anymore)
+ if (CommandLine::getValue("standalone").getBool())
+ Game::getInstance().requestStates("graphics, standalone, level");
+ else if (CommandLine::getValue("server").getBool())
+ Game::getInstance().requestStates("graphics, server, level");
+ else if (CommandLine::getValue("client").getBool())
+ Game::getInstance().requestStates("graphics, client, level");
+ else if (CommandLine::getValue("dedicated").getBool())
+ Game::getInstance().requestStates("dedicated, level");
+ else if (CommandLine::getValue("console").getBool())
+ Game::getInstance().requestStates("ioConsole");
+ else
+ Game::getInstance().requestStates("graphics, mainMenu");
}
catch (const std::exception& ex)
{
Modified: branches/resource/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- branches/resource/src/orxonox/gamestates/GSGraphics.cc 2009-07-27 11:57:28 UTC (rev 3357)
+++ branches/resource/src/orxonox/gamestates/GSGraphics.cc 2009-07-27 12:42:37 UTC (rev 3358)
@@ -67,6 +67,7 @@
// load master key bindings
masterInputState_ = InputManager::getInstance().createInputState("master", true);
masterKeyBinder_ = new KeyBinder();
+ masterInputState_->setKeyHandler(masterKeyBinder_);
}
GSGraphics::~GSGraphics()
@@ -98,7 +99,6 @@
Loader::open(debugOverlay_);
masterKeyBinder_->loadBindings("masterKeybindings.ini");
- masterInputState_->setKeyHandler(masterKeyBinder_);
// Load the SoundManager
soundManager_ = new SoundManager();
Modified: branches/resource/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- branches/resource/src/orxonox/gamestates/GSRoot.cc 2009-07-27 11:57:28 UTC (rev 3357)
+++ branches/resource/src/orxonox/gamestates/GSRoot.cc 2009-07-27 12:42:37 UTC (rev 3358)
@@ -29,7 +29,6 @@
#include "GSRoot.h"
#include "core/Clock.h"
-#include "core/CommandLine.h"
#include "core/ConsoleCommand.h"
#include "core/Game.h"
#include "core/GameMode.h"
@@ -45,12 +44,6 @@
namespace orxonox
{
DeclareGameState(GSRoot, "root", false, false);
- SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
- // Shortcuts for easy direct loading
- SetCommandLineSwitch(server).information("Start in server mode");
- SetCommandLineSwitch(client).information("Start in client mode");
- SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
- SetCommandLineSwitch(standalone).information("Start in standalone mode");
GSRoot::GSRoot(const GameStateInfo& info)
: GameState(info)
@@ -94,36 +87,6 @@
// create the global LevelManager
this->levelManager_ = new LevelManager();
-
- // Load level directly?
- bool loadLevel = false;
- if (CommandLine::getValue("standalone").getBool())
- {
- Game::getInstance().requestStates("graphics, standalone, level");
- loadLevel = true;
- }
- if (CommandLine::getValue("server").getBool())
- {
- Game::getInstance().requestStates("graphics, server, level");
- loadLevel = true;
- }
- if (CommandLine::getValue("client").getBool())
- {
- Game::getInstance().requestStates("graphics, client, level");
- loadLevel = true;
- }
- if (CommandLine::getValue("dedicated").getBool())
- {
- Game::getInstance().requestStates("dedicated, level");
- loadLevel = true;
- }
-
- // Determine where to start otherwise
- if (!loadLevel && !CommandLine::getValue("console").getBool())
- {
- // Also load graphics
- Game::getInstance().requestState("graphics");
- }
}
void GSRoot::deactivate()
More information about the Orxonox-commit
mailing list