Changeset 3289 for code/branches/netp6/src/core
- Timestamp:
- Jul 14, 2009, 10:09:12 AM (15 years ago)
- Location:
- code/branches/netp6/src/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp6/src/core/Clock.cc
r3196 r3289 59 59 tickDtFloat_ = static_cast<float>(tickDt_) / 1000000.0f; 60 60 61 if (timersTime > 0x 7FFFFFF0)61 if (timersTime > 0xFFFFFFFF/4) 62 62 { 63 63 // Ogre timer will overflow at 2^32 microseconds if unsigned long is 32 bit … … 74 74 unsigned long long Clock::getRealMicroseconds() const 75 75 { 76 return this->timer_->getMicroseconds() ;76 return this->timer_->getMicroseconds() + this->storedTime_; 77 77 } 78 78 } -
code/branches/netp6/src/core/Game.cc
r3196 r3289 40 40 #include "util/Debug.h" 41 41 #include "util/Exception.h" 42 #include "util/Sleep.h" 42 43 #include "util/SubString.h" 43 44 #include "Clock.h" … … 120 121 SetConfigValue(levelName_, "presentation_dm.oxw") 121 122 .description("Sets the preselection of the level in the main menu."); 123 SetConfigValue(FPSLimit_, 50) 124 .description("Sets the desired framerate (0 for no limit)."); 122 125 } 123 126 … … 156 159 while (!this->abort_ && !this->activeStates_.empty()) 157 160 { 161 uint64_t currentTime = this->gameClock_->getRealMicroseconds(); 162 163 uint64_t nextTickTime = statisticsTickTimes_.back().tickTime + 1000000.f/this->FPSLimit_; 164 if( currentTime < nextTickTime ) 165 { 166 usleep( nextTickTime - currentTime ); 167 continue; 168 } 158 169 this->gameClock_->capture(); 159 uint64_t currentTime = this->gameClock_->getMicroseconds();160 170 161 171 // STATISTICS -
code/branches/netp6/src/core/Game.h
r3196 r3289 131 131 unsigned int statisticsRefreshCycle_; 132 132 unsigned int statisticsAvgLength_; 133 unsigned int FPSLimit_; 133 134 std::string levelName_; 134 135
Note: See TracChangeset
for help on using the changeset viewer.