Changeset 3304 for code/trunk/src/orxonox/gamestates
- Timestamp:
- Jul 18, 2009, 6:23:31 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/netp6 (added) merged: 3215,3226-3227,3229-3231,3240,3242,3251-3252,3256,3258-3259,3263-3264,3267-3268,3277,3283-3284,3289,3298-3299,3302
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gamestates/GSDedicated.cc
r3301 r3304 42 42 #include <boost/bind.hpp> 43 43 44 #if ndef ORXONOX_PLATFORM_WINDOWS44 #ifdef ORXONOX_PLATFORM_UNIX 45 45 #include <termios.h> 46 46 #endif … … 58 58 : GameState(params) 59 59 , server_(0) 60 , timeSinceLastUpdate_(0)61 60 , closeThread_(false) 62 61 , cleanLine_(true) … … 65 64 , cursorY_(0) 66 65 { 67 this->commandLine_ = new unsigned char[MAX_COMMAND_LENGTH];68 // memset( this->commandLine_, 0, MAX_COMMAND_LENGTH );69 66 } 70 67 … … 96 93 97 94 closeThread_ = true; 98 #if ndef ORXONOX_PLATFORM_WINDOWS95 #ifdef ORXONOX_PLATFORM_UNIX 99 96 std::cout << "\033[0G\033[K"; 100 97 std::cout.flush(); … … 102 99 delete this->originalTerminalSettings_; 103 100 #endif 104 //inputThread_->join(); 101 COUT(0) << "Press enter to end the game..." << std::endl; 102 inputThread_->join(); 103 delete this->inputThread_; 105 104 106 105 GameMode::setHasServer(false); … … 109 108 void GSDedicated::update(const Clock& time) 110 109 { 111 timeSinceLastUpdate_ += time.getDeltaTime(); 112 if (timeSinceLastUpdate_ >= NETWORK_PERIOD) 113 { 114 timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD; 115 server_->update(time); 116 } 117 else 118 { 119 msleep(static_cast<unsigned int>((NETWORK_PERIOD - timeSinceLastUpdate_)*1000)); 120 msleep(static_cast<unsigned int>(NETWORK_PERIOD*1000)); // NOTE: this is to throttle the non-network framerate 121 // COUT(0) << "sleeping for " << static_cast<int>((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000) << " usec" << endl; 122 } 110 server_->update(time); 123 111 processQueue(); 124 112 printLine(); … … 127 115 void GSDedicated::inputThread() 128 116 { 117 this->commandLine_ = new unsigned char[MAX_COMMAND_LENGTH]; 118 // memset( this->commandLine_, 0, MAX_COMMAND_LENGTH ); 129 119 unsigned char c; 130 120 unsigned int escapeChar=0; … … 194 184 std::cout << endl << CommandExecutor::hint( std::string((const char*)this->commandLine_,inputIterator_) ) << endl; 195 185 strncpy(reinterpret_cast<char*>(this->commandLine_), CommandExecutor::complete( std::string(reinterpret_cast<char*>(this->commandLine_),inputIterator_) ).c_str(), MAX_COMMAND_LENGTH); 196 inputIterator_ = strlen((const char*)this->commandLine_); 186 this->inputIterator_ = strlen((const char*)this->commandLine_); 187 this->cursorX_ = this->inputIterator_; 197 188 break; 198 189 } … … 207 198 } 208 199 } 200 201 delete[] this->commandLine_; 209 202 } 210 203 211 204 void GSDedicated::printLine() 212 205 { 213 #if ndef ORXONOX_PLATFORM_WINDOWS206 #ifdef ORXONOX_PLATFORM_UNIX 214 207 // set cursor to the begining of the line and erase the line 215 208 std::cout << "\033[0G\033[K"; … … 251 244 void GSDedicated::setTerminalMode() 252 245 { 253 #if ndef ORXONOX_PLATFORM_WINDOWS246 #ifdef ORXONOX_PLATFORM_UNIX 254 247 termios new_settings; 255 248 … … 268 261 void GSDedicated::resetTerminalMode() 269 262 { 270 #if ndef ORXONOX_PLATFORM_WINDOWS263 #ifdef ORXONOX_PLATFORM_UNIX 271 264 tcsetattr(0, TCSANOW, GSDedicated::originalTerminalSettings_); 272 265 #endif -
code/trunk/src/orxonox/gamestates/GSDedicated.h
r3280 r3304 66 66 67 67 Server* server_; 68 float timeSinceLastUpdate_;69 68 70 69 boost::thread *inputThread_; -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r3280 r3304 34 34 #include "core/Game.h" 35 35 #include "core/GameMode.h" 36 #include "network/NetworkFunction.h" 36 37 #include "tools/Timer.h" 37 38 #include "interfaces/TimeFactorListener.h" … … 61 62 GSRoot::~GSRoot() 62 63 { 64 NetworkFunctionBase::destroyAllNetworkFunctions(); 63 65 } 64 66
Note: See TracChangeset
for help on using the changeset viewer.