Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2996


Ignore:
Timestamp:
May 20, 2009, 4:13:26 PM (15 years ago)
Author:
rgrieder
Message:

Fixed tick-time issue: Not all tick times were being taken into account.
As of now, only GSRoot and GSGraphics manage the tick times themselves (marked with "AddGameState(GSRoot, "root", false)")

Location:
code/branches/netp3/src
Files:
8 edited

Legend:

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

    r2927 r2996  
    168168            for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin();
    169169                it != this->activeStates_.end(); ++it)
     170            {
     171                // Add tick time for most of the states
     172                uint64_t timeBeforeTick;
     173                if ((*it)->getCountTickTime())
     174                    timeBeforeTick = this->gameClock_->getRealMicroseconds();
     175               
    170176                (*it)->update(*this->gameClock_);
     177
     178                if ((*it)->getCountTickTime())
     179                    this->addTickTime(this->gameClock_->getRealMicroseconds() - timeBeforeTick);
     180            }
    171181
    172182            // STATISTICS
  • code/branches/netp3/src/core/Game.h

    r2946 r2996  
    4343#include "OrxonoxClass.h"
    4444
    45 #define AddGameState(classname, name) \
    46     static bool MACRO_CONCATENATE(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(name))
     45/**
     46@def
     47    Adds a new GameState to the Game. The second parameter is the name as string
     48    and every following paramter is a constructor argument (which is usually non existent)
     49*/
     50#define AddGameState(classname, ...) \
     51    static bool MACRO_CONCATENATE(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(__VA_ARGS__))
    4752
    4853namespace orxonox
  • code/branches/netp3/src/core/GameState.cc

    r2896 r2996  
    4545        Constructor only initialises variables and sets the name permanently.
    4646    */
    47     GameState::GameState(const std::string& name)
     47    GameState::GameState(const std::string& name, bool countTickTime)
    4848        : name_(name)
     49        , bCountTickTime_(countTickTime)
    4950        , parent_(0)
    5051    {
  • code/branches/netp3/src/core/GameState.h

    r2896 r2996  
    7878
    7979    public:
    80         GameState(const std::string& name);
     80        GameState(const std::string& name, bool countTicktime = true);
    8181        virtual ~GameState();
    8282
    8383        const std::string& getName() const { return name_; }
    84         State getActivity() const    { return this->activity_; }
    85         GameState* getParent() const       { return this->parent_; }
     84        State getActivity()          const { return this->activity_; }
     85        GameState* getParent()       const { return this->parent_; }
     86
     87        bool getCountTickTime()      const { return this->bCountTickTime_; }
    8688
    8789        void addChild(GameState* state);
     
    102104        const std::string                        name_;
    103105        State                                    activity_;
     106        const bool                               bCountTickTime_;
    104107        GameState*                               parent_;
    105108        std::map<std::string, GameState*>        children_;
  • code/branches/netp3/src/orxonox/gamestates/GSGraphics.cc

    r2928 r2996  
    5757namespace orxonox
    5858{
    59     AddGameState(GSGraphics, "graphics");
    60 
    61     GSGraphics::GSGraphics(const std::string& name)
    62         : GameState(name)
     59    AddGameState(GSGraphics, "graphics", false);
     60
     61    GSGraphics::GSGraphics(const std::string& name, bool countTickTime)
     62        : GameState(name, countTickTime)
    6363        , inputManager_(0)
    6464        , console_(0)
     
    213213        uint64_t timeBeforeTick = time.getRealMicroseconds();
    214214
    215         this->inputManager_->update(time);        // tick console
     215        this->inputManager_->update(time);
    216216        this->console_->update(time);
    217         this->guiManager_->update(time);
    218217
    219218        uint64_t timeAfterTick = time.getRealMicroseconds();
     
    222221        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    223222
     223        // Process gui events
     224        this->guiManager_->update(time);
    224225        // Render
    225226        this->graphicsManager_->update(time);
  • code/branches/netp3/src/orxonox/gamestates/GSGraphics.h

    r2896 r2996  
    5151    {
    5252    public:
    53         GSGraphics(const std::string& name);
     53        GSGraphics(const std::string& name, bool countTickTime);
    5454        ~GSGraphics();
    5555        void setConfigValues();
  • code/branches/netp3/src/orxonox/gamestates/GSRoot.cc

    r2928 r2996  
    4343namespace orxonox
    4444{
    45     AddGameState(GSRoot, "root");
     45    AddGameState(GSRoot, "root", false);
    4646    SetCommandLineSwitch(console);
    4747    // Shortcuts for easy direct loading
     
    5151    SetCommandLineSwitch(standalone);
    5252
    53     GSRoot::GSRoot(const std::string& name)
    54         : GameState(name)
     53    GSRoot::GSRoot(const std::string& name, bool countTickTime)
     54        : GameState(name, countTickTime)
    5555        , timeFactor_(1.0f)
    5656        , bPaused_(false)
  • code/branches/netp3/src/orxonox/gamestates/GSRoot.h

    r2896 r2996  
    3939    {
    4040    public:
    41         GSRoot(const std::string& name);
     41        GSRoot(const std::string& name, bool countTickTime);
    4242        ~GSRoot();
    4343
Note: See TracChangeset for help on using the changeset viewer.