Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource/src/core/Game.cc @ 3363

Last change on this file since 3363 was 3363, checked in by rgrieder, 16 years ago

Exception-safety for the Game and Core c'tors as well as load/unload-Graphics.

  • Property svn:eol-style set to native
File size: 22.6 KB
RevLine 
[2805]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30@file
31@brief
32    Implementation of the Game class.
33*/
34
35#include "Game.h"
36
37#include <exception>
[3196]38#include <boost/weak_ptr.hpp>
[2805]39
40#include "util/Debug.h"
41#include "util/Exception.h"
[3363]42#include "util/ScopeGuard.h"
[3304]43#include "util/Sleep.h"
[2850]44#include "util/SubString.h"
[2844]45#include "Clock.h"
46#include "CommandLine.h"
47#include "ConsoleCommand.h"
48#include "Core.h"
49#include "CoreIncludes.h"
50#include "ConfigValueIncludes.h"
[3355]51#include "GameMode.h"
[2844]52#include "GameState.h"
[2805]53
54namespace orxonox
55{
[3196]56    using boost::shared_ptr;
57    using boost::weak_ptr;
58
[2845]59    static void stop_game()
60        { Game::getInstance().stop(); }
61    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
[2805]62
[3355]63    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
[3280]64    Game* Game::singletonRef_s = 0;
65
66
67    /**
68    @brief
69        Represents one node of the game state tree.
70    */
71    struct GameStateTreeNode
[2844]72    {
[3356]73        std::string name_;
[3196]74        weak_ptr<GameStateTreeNode> parent_;
75        std::vector<shared_ptr<GameStateTreeNode> > children_;
[2844]76    };
77
[2805]78
79    /**
80    @brief
[3280]81        Another helper class for the Game singleton: we cannot derive
82        Game from OrxonoxClass because we need to handle the Identifier
83        destruction in the Core destructor.
84    */
85    class GameConfiguration : public OrxonoxClass
86    {
87    public:
88        GameConfiguration()
89        {
90            RegisterRootObject(GameConfiguration);
91            this->setConfigValues();
92        }
93
94        void setConfigValues()
95        {
96            SetConfigValue(statisticsRefreshCycle_, 250000)
97                .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
98            SetConfigValue(statisticsAvgLength_, 1000000)
99                .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
[3304]100            SetConfigValue(fpsLimit_, 50)
101                .description("Sets the desired framerate (0 for no limit).");
[3280]102        }
103
104        unsigned int statisticsRefreshCycle_;
105        unsigned int statisticsAvgLength_;
[3304]106        unsigned int fpsLimit_;
[3280]107    };
108
109
110    /**
111    @brief
[2805]112        Non-initialising constructor.
113    */
[3323]114    Game::Game(const std::string& cmdLine)
[2805]115    {
[3280]116        if (singletonRef_s != 0)
117        {
118            COUT(0) << "Error: The Game singleton cannot be recreated! Shutting down." << std::endl;
119            abort();
120        }
[2805]121        singletonRef_s = this;
122
[3280]123        this->bAbort_ = false;
124        bChangingState_ = false;
[2805]125
[3352]126#ifdef ORXONOX_PLATFORM_WINDOWS
127        minimumSleepTime_ = 1000/*us*/;
128#else
129        minimumSleepTime_ = 0/*us*/;
130#endif
131
[3280]132        // Create an empty root state
[3352]133        this->declareGameState<GameState>("GameState", "emptyRootGameState", true, false);
[3280]134
[2846]135        // Set up a basic clock to keep time
[3363]136        this->gameClock_.reset(new Clock());
[2846]137
[3280]138        // Create the Core
[3363]139        this->core_.reset(new Core(cmdLine));
[2817]140
[3356]141        // After the core has been created, we can safely instantiate the GameStates that don't require graphics
[3280]142        for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
143            it != gameStateDeclarations_s.end(); ++it)
144        {
[3356]145            if (!it->second.bGraphicsMode)
146                constructedStates_[it->second.stateName] = GameStateFactory::fabricate(it->second);
[3280]147        }
148
149        // The empty root state is ALWAYS loaded!
150        this->rootStateNode_ = shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
[3356]151        this->rootStateNode_->name_ = "emptyRootGameState";
152        this->loadedTopStateNode_ = this->rootStateNode_;
153        this->loadedStates_.push_back(this->getState(rootStateNode_->name_));
[3280]154
155        // Do this after the Core creation!
[3363]156        this->configuration_.reset(new GameConfiguration());
[2805]157    }
158
159    /**
160    @brief
[3363]161        All destruction code is handled by scoped_ptrs and SimpleScopeGuards.
[2805]162    */
163    Game::~Game()
164    {
[3280]165        // Don't assign singletonRef_s with NULL! Recreation is not supported
[2817]166    }
167
[2805]168    /**
169    @brief
170        Main loop of the orxonox game.
171    @note
172        We use the Ogre::Timer to measure time since it uses the most precise
173        method an any platform (however the windows timer lacks time when under
174        heavy kernel load!).
175    */
176    void Game::run()
177    {
[3280]178        if (this->requestedStateNodes_.empty())
179            COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
[2805]180
[3352]181        // reset statistics
182        this->statisticsStartTime_ = 0;
183        this->statisticsTickTimes_.clear();
184        this->periodTickTime_ = 0;
185        this->periodTime_ = 0;
186        this->avgFPS_ = 0.0f;
187        this->avgTickTime_ = 0.0f;
188        this->excessSleepTime_ = 0;
189
[2845]190        // START GAME
[3304]191        // first delta time should be about 0 seconds
192        this->gameClock_->capture();
193        // A first item is required for the fps limiter
194        StatisticsTickInfo tickInfo = {0, 0};
195        statisticsTickTimes_.push_back(tickInfo);
[3356]196        while (!this->bAbort_ && (!this->loadedStates_.empty() || this->requestedStateNodes_.size() > 0))
[2805]197        {
[3352]198            // Generate the dt
[2807]199            this->gameClock_->capture();
[2805]200
[3352]201            // Statistics init
202            StatisticsTickInfo tickInfo = {gameClock_->getMicroseconds(), 0};
[2817]203            statisticsTickTimes_.push_back(tickInfo);
204            this->periodTime_ += this->gameClock_->getDeltaTimeMicroseconds();
205
[3352]206            // Update the GameState stack if required
207            this->updateGameStateStack();
208
209            // Core preUpdate (doesn't throw)
210            if (!this->core_->preUpdate(*this->gameClock_))
[2844]211            {
[3352]212                this->stop();
213                break;
[2844]214            }
[2805]215
[3352]216            // Update the GameStates bottom up in the stack
217            this->updateGameStates();
218
219            // Core postUpdate (doesn't throw)
220            if (!this->core_->postUpdate(*this->gameClock_))
[3280]221            {
222                this->stop();
223                break;
224            }
225
[3352]226            // Evaluate statistics
227            this->updateStatistics();
228
229            // Limit framerate
230            this->updateFPSLimiter();
231        }
232
233        // UNLOAD all remaining states
[3356]234        while (this->loadedStates_.size() > 1)
235            this->unloadState(this->loadedStates_.back()->getName());
236        this->loadedTopStateNode_ = this->rootStateNode_;
[3352]237        this->requestedStateNodes_.clear();
238    }
239
240    void Game::updateGameStateStack()
241    {
242        while (this->requestedStateNodes_.size() > 0)
243        {
244            shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();
[3356]245            assert(this->loadedTopStateNode_);
246            if (!this->loadedTopStateNode_->parent_.expired() && requestedStateNode == this->loadedTopStateNode_->parent_.lock())
247                this->unloadState(loadedTopStateNode_->name_);
[3352]248            else // has to be child
[3084]249            {
[3280]250                try
251                {
[3356]252                    this->loadState(requestedStateNode->name_);
[3280]253                }
254                catch (const std::exception& ex)
255                {
[3356]256                    COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << ex.what() << std::endl;
[3352]257                    // All scheduled operations have now been rendered inert --> flush them and issue a warning
258                    if (this->requestedStateNodes_.size() > 1)
259                        COUT(1) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
260                    this->requestedStateNodes_.clear();
[3280]261                    break;
262                }
[3084]263            }
[3356]264            this->loadedTopStateNode_ = requestedStateNode;
[3352]265            this->requestedStateNodes_.erase(this->requestedStateNodes_.begin());
266        }
267    }
[3084]268
[3352]269    void Game::updateGameStates()
270    {
271        // Note: The first element is the empty root state, which doesn't need ticking
[3363]272        for (GameStateVector::const_iterator it = this->loadedStates_.begin() + 1;
[3356]273            it != this->loadedStates_.end(); ++it)
[3352]274        {
275            std::string exceptionMessage;
276            try
[3349]277            {
[3352]278                // Add tick time for most of the states
279                uint64_t timeBeforeTick;
[3355]280                if ((*it)->getInfo().bIgnoreTickTime)
[3352]281                    timeBeforeTick = this->gameClock_->getRealMicroseconds();
282                (*it)->update(*this->gameClock_);
[3355]283                if ((*it)->getInfo().bIgnoreTickTime)
[3352]284                    this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
285            }
286            catch (const std::exception& ex)
287            { exceptionMessage = ex.what(); }
288            catch (...)
289            { exceptionMessage = "Unknown exception"; }
290            if (!exceptionMessage.empty())
291            {
292                COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << exceptionMessage << std::endl;
293                COUT(1) << "This should really never happen!" << std::endl;
294                COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
[3356]295                shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;
296                while (current->name_ != (*it)->getName() && current)
297                    current = current->parent_.lock();
298                if (current && current->parent_.lock())
299                    this->requestState(current->parent_.lock()->name_);
[3352]300                else
301                    this->stop();
[3349]302                break;
303            }
[3352]304        }
305    }
[3349]306
[3352]307    void Game::updateStatistics()
308    {
309        // Add the tick time of this frame (rendering time has already been subtracted)
310        uint64_t currentTime = gameClock_->getMicroseconds();
311        uint64_t currentRealTime = gameClock_->getRealMicroseconds();
312        this->statisticsTickTimes_.back().tickLength += currentRealTime - currentTime;
313        this->periodTickTime_ += currentRealTime - currentTime;
314        if (this->periodTime_ > this->configuration_->statisticsRefreshCycle_)
315        {
316            std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
317            assert(it != this->statisticsTickTimes_.end());
318            int64_t lastTime = currentTime - this->configuration_->statisticsAvgLength_;
319            if (static_cast<int64_t>(it->tickTime) < lastTime)
[2817]320            {
[3352]321                do
[2817]322                {
[3352]323                    assert(this->periodTickTime_ >= it->tickLength);
324                    this->periodTickTime_ -= it->tickLength;
325                    ++it;
326                    assert(it != this->statisticsTickTimes_.end());
327                } while (static_cast<int64_t>(it->tickTime) < lastTime);
328                this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
329            }
[2817]330
[3352]331            uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
332            this->avgFPS_ = static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
333            this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
[2817]334
[3352]335            this->periodTime_ -= this->configuration_->statisticsRefreshCycle_;
[2805]336        }
[3352]337    }
[2805]338
[3352]339    void Game::updateFPSLimiter()
340    {
341        // Why configuration_->fpsLimit_ - 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too high
342        uint32_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / (configuration_->fpsLimit_ - 1));
343        uint64_t currentRealTime = gameClock_->getRealMicroseconds();
344        while (currentRealTime < nextTime - minimumSleepTime_)
345        {
346            usleep(nextTime - currentRealTime);
347            currentRealTime = gameClock_->getRealMicroseconds();
348        }
349        // Integrate excess to avoid steady state error
350        excessSleepTime_ = currentRealTime - nextTime;
351        // Anti windup
352        if (excessSleepTime_ > 50000) // 20ms is about the maximum time Windows would sleep for too long
353            excessSleepTime_ = 50000;
[2805]354    }
355
356    void Game::stop()
357    {
[3280]358        this->bAbort_ = true;
[2805]359    }
[2817]360
[3349]361    void Game::subtractTickTime(int32_t length)
[2817]362    {
363        assert(!this->statisticsTickTimes_.empty());
[3349]364        this->statisticsTickTimes_.back().tickLength -= length;
365        this->periodTickTime_ -= length;
[2817]366    }
[2844]367
368
369    /***** GameState related *****/
370
371    void Game::requestState(const std::string& name)
372    {
[3356]373        if (!this->checkState(name))
374        {
375            COUT(2) << "Warning: GameState named '" << name << "' doesn't exist!" << std::endl;
[2844]376            return;
[3356]377        }
[2844]378
[3358]379        if (this->bChangingState_)
380        {
381            COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
382            return;
383        }
[2844]384
[3280]385        shared_ptr<GameStateTreeNode> lastRequestedNode;
386        if (this->requestedStateNodes_.empty())
[3356]387            lastRequestedNode = this->loadedTopStateNode_;
[3280]388        else
389            lastRequestedNode = this->requestedStateNodes_.back();
[3356]390        if (name == lastRequestedNode->name_)
[2844]391        {
392            COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;
393            return;
394        }
395
396        // Check children first
[3280]397        std::vector<shared_ptr<GameStateTreeNode> > requestedNodes;
[2844]398        for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
399        {
[3356]400            if (lastRequestedNode->children_[i]->name_ == name)
[2844]401            {
[3280]402                requestedNodes.push_back(lastRequestedNode->children_[i]);
[2844]403                break;
404            }
405        }
406
[3280]407        if (requestedNodes.empty())
[2844]408        {
[3280]409            // Check parent and all its grand parents
410            shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
411            while (currentNode != NULL)
412            {
[3356]413                if (currentNode->name_ == name)
[3280]414                    break;
415                currentNode = currentNode->parent_.lock();
416                requestedNodes.push_back(currentNode);
417            }
[2844]418        }
419
[3280]420        if (requestedNodes.empty())
[2844]421            COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
422        else
[3280]423            this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
[2844]424    }
425
[2850]426    void Game::requestStates(const std::string& names)
427    {
428        SubString tokens(names, ",;", " ");
429        for (unsigned int i = 0; i < tokens.size(); ++i)
430            this->requestState(tokens[i]);
431    }
432
[2844]433    void Game::popState()
434    {
[3280]435        shared_ptr<GameStateTreeNode> lastRequestedNode;
436        if (this->requestedStateNodes_.empty())
[3356]437            lastRequestedNode = this->loadedTopStateNode_;
[2844]438        else
[3280]439            lastRequestedNode = this->requestedStateNodes_.back();
440        if (lastRequestedNode != this->rootStateNode_)
[3356]441            this->requestState(lastRequestedNode->parent_.lock()->name_);
[3280]442        else
443            COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;
[2844]444    }
445
[3363]446    shared_ptr<GameState> Game::getState(const std::string& name)
[2844]447    {
[3363]448        GameStateMap::const_iterator it = constructedStates_.find(name);
[3356]449        if (it != constructedStates_.end())
[2844]450            return it->second;
451        else
452        {
[3356]453            std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name);
454            if (it != gameStateDeclarations_s.end())
455                COUT(1) << "Error: GameState '" << name << "' has not yet been loaded." << std::endl;
456            else
457                COUT(1) << "Error: Could not find GameState '" << name << "'." << std::endl;
[3363]458            return shared_ptr<GameState>();
[2844]459        }
460    }
461
462    void Game::setStateHierarchy(const std::string& str)
463    {
464        // Split string into pieces of the form whitespacesText
465        std::vector<std::pair<std::string, unsigned> > stateStrings;
466        size_t pos = 0;
467        size_t startPos = 0;
468        while (pos < str.size())
469        {
470            unsigned indentation = 0;
471            while(pos < str.size() && str[pos] == ' ')
472                ++indentation, ++pos;
473            startPos = pos;
474            while(pos < str.size() && str[pos] != ' ')
475                ++pos;
[3280]476            stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));
[2844]477        }
478        unsigned int currentLevel = 0;
[3280]479        shared_ptr<GameStateTreeNode> currentNode = this->rootStateNode_;
[2844]480        for (std::vector<std::pair<std::string, unsigned> >::const_iterator it = stateStrings.begin(); it != stateStrings.end(); ++it)
481        {
482            std::string newStateName = it->first;
[3280]483            unsigned newLevel = it->second + 1; // empty root is 0
[3356]484            if (!this->checkState(newStateName))
[3280]485                ThrowException(GameState, "GameState with name '" << newStateName << "' not found!");
[3356]486            if (newStateName == this->rootStateNode_->name_)
[3280]487                ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
488            shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
[3356]489            newNode->name_ = newStateName;
[3280]490
491            if (newLevel <= currentLevel)
[2844]492            {
[3280]493                do
494                    currentNode = currentNode->parent_.lock();
495                while (newLevel <= --currentLevel);
[2844]496            }
[3280]497            if (newLevel == currentLevel + 1)
[2844]498            {
[3280]499                // Add the child
500                newNode->parent_ = currentNode;
501                currentNode->children_.push_back(newNode);
[2844]502            }
503            else
[3280]504                ThrowException(GameState, "Indentation error while parsing the hierarchy.");
505            currentNode = newNode;
506            currentLevel = newLevel;
[2844]507        }
508    }
509
510    /*** Internal ***/
511
[3355]512    void Game::loadGraphics()
513    {
514        if (!GameMode::bShowsGraphics_s)
515        {
516            core_->loadGraphics();
[3363]517            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
[3355]518            GameMode::bShowsGraphics_s = true;
[3356]519
520            // Construct all the GameStates that require graphics
521            for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
522                it != gameStateDeclarations_s.end(); ++it)
523            {
524                if (it->second.bGraphicsMode)
525                {
[3363]526                    // Game state loading failure is serious --> don't catch
527                    shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);
[3356]528                    if (!constructedStates_.insert(std::make_pair(
[3363]529                        it->second.stateName, gameState)).second)
[3356]530                        assert(false); // GameState was already created!
531                }
532            }
[3363]533            graphicsUnloader.Dismiss();
[3355]534        }
535    }
536
537    void Game::unloadGraphics()
538    {
539        if (GameMode::bShowsGraphics_s)
540        {
[3356]541            // Destroy all the GameStates that require graphics
[3363]542            for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)
[3356]543            {
544                if (it->second->getInfo().bGraphicsMode)
[3359]545                    constructedStates_.erase(it++);
[3356]546                else
547                    ++it;
548            }
549
[3355]550            core_->unloadGraphics();
551            GameMode::bShowsGraphics_s = false;
552        }
553    }
554
[3356]555    bool Game::checkState(const std::string& name) const
[2844]556    {
[3356]557        std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name);
558        if (it == gameStateDeclarations_s.end())
559            return false;
560        else
561            return true;
562    }
563
564    void Game::loadState(const std::string& name)
565    {
[3280]566        this->bChangingState_ = true;
[3363]567        LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState);
568
[3355]569        // If state requires graphics, load it
[3363]570        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
571        if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())
[3355]572            this->loadGraphics();
[3363]573        else
574            graphicsUnloader.Dismiss();
575
576        shared_ptr<GameState> state = this->getState(name);
[3280]577        state->activate();
[3356]578        if (!this->loadedStates_.empty())
579            this->loadedStates_.back()->activity_.topState = false;
580        this->loadedStates_.push_back(state);
[2850]581        state->activity_.topState = true;
[3363]582
583        graphicsUnloader.Dismiss();
[2844]584    }
585
[3356]586    void Game::unloadState(const std::string& name)
[2844]587    {
[3280]588        this->bChangingState_ = true;
589        try
590        {
[3363]591            shared_ptr<GameState> state = this->getState(name);
592            state->activity_.topState = false;
593            this->loadedStates_.pop_back();
594            if (!this->loadedStates_.empty())
595                this->loadedStates_.back()->activity_.topState = true;
[3280]596            state->deactivate();
597        }
598        catch (const std::exception& ex)
599        {
[3356]600            COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << ex.what() << std::endl;
[3280]601            COUT(2) << "         There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
602        }
[3363]603        // Check if graphics is still required
604        bool graphicsRequired = false;
605        for (unsigned i = 0; i < loadedStates_.size(); ++i)
606            graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
607        if (!graphicsRequired)
608            this->unloadGraphics();
[3280]609        this->bChangingState_ = false;
[2844]610    }
611
[3363]612    std::map<std::string, shared_ptr<Game::GameStateFactory> > Game::GameStateFactory::factories_s;
[3280]613
[3363]614    /*static*/ shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info)
[2844]615    {
[3363]616        std::map<std::string, shared_ptr<Game::GameStateFactory> >::const_iterator it = factories_s.find(info.className);
[3280]617        assert(it != factories_s.end());
[3355]618        return it->second->fabricateInternal(info);
[2844]619    }
[2805]620}
Note: See TracBrowser for help on using the repository browser.