[Orxonox-commit 167] r2846 - in branches/gui/src: core core/input network orxonox/gamestates
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Mar 25 18:24:15 CET 2009
Author: rgrieder
Date: 2009-03-25 17:24:15 +0000 (Wed, 25 Mar 2009)
New Revision: 2846
Modified:
branches/gui/src/core/Core.cc
branches/gui/src/core/Core.h
branches/gui/src/core/Game.cc
branches/gui/src/core/Game.h
branches/gui/src/core/input/KeyBinder.cc
branches/gui/src/network/ChatListener.cc
branches/gui/src/network/ClientConnectionListener.cc
branches/gui/src/orxonox/gamestates/GSClient.cc
branches/gui/src/orxonox/gamestates/GSGraphics.cc
branches/gui/src/orxonox/gamestates/GSRoot.cc
Log:
Moving game clock from Core to Game.
Other small fixes.
Modified: branches/gui/src/core/Core.cc
===================================================================
--- branches/gui/src/core/Core.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/core/Core.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -101,11 +101,8 @@
Core::singletonRef_s = this;
}
- Clock* Core::initialise(int argc, char** argv)
+ void Core::initialise(int argc, char** argv)
{
- // Set up a basic clock to keep time
- this->gameClock_ = new Clock();
-
// Parse command line arguments fist
try
{
@@ -174,9 +171,6 @@
Factory::createClassHierarchy();
this->loaded_ = true;
-
- // Return non const pointer to the game's clock for the main loop
- return this->gameClock_;
}
/**
@@ -199,8 +193,6 @@
// Also delete external console command that don't belong to an Identifier
CommandExecutor::destroyExternalCommands();
- delete this->gameClock_;
-
assert(Core::singletonRef_s);
Core::singletonRef_s = 0;
}
Modified: branches/gui/src/core/Core.h
===================================================================
--- branches/gui/src/core/Core.h 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/core/Core.h 2009-03-25 17:24:15 UTC (rev 2846)
@@ -44,8 +44,6 @@
#include "OrxonoxClass.h"
#include "util/OutputHandler.h"
-// Only allow main to access postMainInitialisation, so we need a forward declaration
-int main(int, char**);
// boost::filesystem header has quite a large tail, use forward declaration
namespace boost { namespace filesystem
{
@@ -63,7 +61,7 @@
Core();
~Core();
- Clock* initialise(int argc, char** argv);
+ void initialise(int argc, char** argv);
void setConfigValues();
void update(const Clock& time);
@@ -75,8 +73,6 @@
static const std::string& getLanguage();
static void resetLanguage();
- static const Clock& getGameClock() { return *getInstance().gameClock_; }
-
static void tsetMediaPath(const std::string& path)
{ assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
static const boost::filesystem::path& getMediaPath();
@@ -122,8 +118,6 @@
TclBind* tclBind_;
TclThreadManager* tclThreadManager_;
- Clock* gameClock_;
-
int softDebugLevel_; //!< The debug level
int softDebugLevelConsole_; //!< The debug level for the console
int softDebugLevelLogfile_; //!< The debug level for the logfile
Modified: branches/gui/src/core/Game.cc
===================================================================
--- branches/gui/src/core/Game.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/core/Game.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -85,8 +85,12 @@
this->avgFPS_ = 0.0f;
this->avgTickTime_ = 0.0f;
+
+ // Set up a basic clock to keep time
+ this->gameClock_ = new Clock();
+
this->core_ = new orxonox::Core();
- this->gameClock_ = this->core_->initialise(argc, argv);
+ this->core_->initialise(argc, argv);
RegisterRootObject(Game);
this->setConfigValues();
@@ -104,6 +108,8 @@
for (std::map<std::string, GameState*>::const_iterator it = allStates_s.begin(); it != allStates_s.end(); ++it)
delete it->second;
+ delete this->gameClock_;
+
assert(singletonRef_s);
singletonRef_s = 0;
}
@@ -157,6 +163,7 @@
}
// UPDATE, bottom to top in the stack
+ this->core_->update(*this->gameClock_);
for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin();
it != this->activeStates_.end(); ++it)
(*it)->update(*this->gameClock_);
Modified: branches/gui/src/core/Game.h
===================================================================
--- branches/gui/src/core/Game.h 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/core/Game.h 2009-03-25 17:24:15 UTC (rev 2846)
@@ -67,6 +67,8 @@
void requestState(const std::string& name);
void popState();
+ const Clock& getGameClock() { return *this->gameClock_; }
+
float getAvgTickTime() { return this->avgTickTime_; }
float getAvgFPS() { return this->avgFPS_; }
Modified: branches/gui/src/core/input/KeyBinder.cc
===================================================================
--- branches/gui/src/core/input/KeyBinder.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/core/input/KeyBinder.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -41,7 +41,6 @@
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/ConfigFileManager.h"
-#include "core/Core.h"
#include "InputCommands.h"
#include "InputManager.h"
Modified: branches/gui/src/network/ChatListener.cc
===================================================================
--- branches/gui/src/network/ChatListener.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/network/ChatListener.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -29,7 +29,6 @@
#include "ChatListener.h"
#include "core/CoreIncludes.h"
-#include "core/Core.h"
namespace orxonox
{
Modified: branches/gui/src/network/ClientConnectionListener.cc
===================================================================
--- branches/gui/src/network/ClientConnectionListener.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/network/ClientConnectionListener.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -1,3 +1,31 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
#include "ClientConnectionListener.h"
#include "core/CoreIncludes.h"
#include "core/Core.h"
Modified: branches/gui/src/orxonox/gamestates/GSClient.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSClient.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/orxonox/gamestates/GSClient.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -61,7 +61,7 @@
if(!client_->establishConnection())
ThrowException(InitialisationFailed, "Could not establish connection with server.");
- client_->update(Core::getGameClock());
+ client_->update(Game::getInstance().getGameClock());
}
void GSClient::deactivate()
Modified: branches/gui/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSGraphics.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/orxonox/gamestates/GSGraphics.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -112,8 +112,7 @@
void GSGraphics::deactivate()
{
- if (Core::showsGraphics())
- InputManager::getInstance().requestLeaveState("master");
+ InputManager::getInstance().requestLeaveState("master");
delete this->guiManager_;
@@ -128,16 +127,15 @@
delete graphicsManager_;
- if (Core::showsGraphics())
+ masterInputState_->setHandler(0);
+ InputManager::getInstance().requestDestroyState("master");
+ if (this->masterKeyBinder_)
{
- masterInputState_->setHandler(0);
- InputManager::getInstance().requestDestroyState("master");
- if (this->masterKeyBinder_)
- {
- delete this->masterKeyBinder_;
- this->masterKeyBinder_ = 0;
- }
+ delete this->masterKeyBinder_;
+ this->masterKeyBinder_ = 0;
}
+
+ Core::setShowsGraphics(false);
}
/**
Modified: branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSRoot.cc 2009-03-25 16:33:58 UTC (rev 2845)
+++ branches/gui/src/orxonox/gamestates/GSRoot.cc 2009-03-25 17:24:15 UTC (rev 2846)
@@ -114,8 +114,6 @@
{
uint64_t timeBeforeTick = time.getRealMicroseconds();
- Core::getInstance().update(time);
-
for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
it->tick(time);
More information about the Orxonox-commit
mailing list