Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2009, 4:13:26 PM (16 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/core
Files:
4 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_;
Note: See TracChangeset for help on using the changeset viewer.