Changeset 2415 for code/branches/presentation/src/orxonox/gamestates
- Timestamp:
- Dec 12, 2008, 10:10:31 AM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/gamestates
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/gamestates/GSDedicated.cc
r2171 r2415 35 35 #include "network/Server.h" 36 36 #include "objects/Tickable.h" 37 #include "util/Sleep.h" 37 38 38 39 namespace orxonox … … 41 42 : GameState<GSRoot>("dedicated") 42 43 , server_(0) 44 , timeSinceLastUpdate_(0) 43 45 { 44 46 } … … 72 74 void GSDedicated::ticked(const Clock& time) 73 75 { 74 GSLevel::ticked(time); 75 server_->tick(time.getDeltaTime()); 76 this->tickChild(time); 76 // static float startTime = time.getSecondsPrecise(); 77 // static int nrOfTicks = 0; 78 timeSinceLastUpdate_+=time.getDeltaTime(); 79 if(timeSinceLastUpdate_>=NETWORK_PERIOD){ 80 // ++nrOfTicks; 81 // COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl; 82 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 83 GSLevel::ticked(time); 84 server_->tick(time.getDeltaTime()); 85 this->tickChild(time); 86 } 87 else 88 { 89 usleep( (int)( (NETWORK_PERIOD - timeSinceLastUpdate_)*1000*1000 ) ); 90 // COUT(0) << "sleeping for " << (int)( (NETWORK_PERIOD - timeSinceLastUpdate_)*1000*1000 ) << " usec" << endl; 91 } 77 92 } 78 93 } -
code/branches/presentation/src/orxonox/gamestates/GSDedicated.h
r2171 r2415 49 49 50 50 Server* server_; 51 float timeSinceLastUpdate_; 51 52 }; 52 53 }
Note: See TracChangeset
for help on using the changeset viewer.