Changeset 1145 for code/branches
- Timestamp:
- Apr 23, 2008, 9:42:12 AM (17 years ago)
- Location:
- code/branches/console/src/orxonox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/orxonox/Orxonox.cc
r1143 r1145 54 54 //#include "util/Sleep.h" 55 55 #include "util/ArgReader.h" 56 #include "util/ExprParser.h" 56 57 57 58 // core … … 76 77 #include "hud/HUD.h" 77 78 #include "console/InGameConsole.h" 78 //#include "objects/weapon/BulletManager.h"79 79 80 80 // FIXME: is this really file scope? … … 126 126 }; 127 127 128 class Calculator 129 { 130 public: 131 static void calculate(const std::string& calculation) 132 { 133 ExprParser expr(calculation); 134 if (expr.getSuccess()) 135 { 136 if (expr.getResult() == 42.0) 137 std::cout << "Greetings from the restaurant at the end of the universe." << std::endl; 138 // FIXME: insert modifier to display in full precision 139 std::cout << "Result is: " << expr.getResult() << std::endl; 140 if (expr.getRemains() != "") 141 std::cout << "Warning: Expression could not be parsed to the end! Remains: '" 142 << expr.getRemains() << "'" << std::endl; 143 } 144 else 145 std::cout << "Cannot calculate expression: Parse error" << std::endl; 146 } 147 }; 148 ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None); 149 128 150 /** 129 151 @brief Reference to the only instance of the class. … … 141 163 this->auMan_ = 0; 142 164 this->inputHandler_ = 0; 143 //this->root_ = 0;144 165 // turn on frame smoothing by setting a value different from 0 145 166 this->frameSmoothingTime_ = 0.0f; … … 154 175 { 155 176 // keep in mind: the order of deletion is very important! 156 // if (this->bulletMgr_)157 // delete this->bulletMgr_;158 177 if (this->orxonoxHUD_) 159 178 delete this->orxonoxHUD_; … … 173 192 174 193 /** 175 * error kills orxonox 176 */ 177 void Orxonox::abortImmediate(/* some error code */) 178 { 179 //TODO: destroy and destruct everything and print nice error msg 194 @brief Immediately deletes the orxonox object. 195 Never use if you can help it while rendering! 196 */ 197 void Orxonox::abortImmediateForce() 198 { 199 COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl; 180 200 delete this; 181 201 } … … 186 206 void Orxonox::abortRequest() 187 207 { 208 COUT(3) << "*** Orxonox: Abort requested." << std::endl; 188 209 bAbort_ = true; 189 210 } … … 226 247 ar.checkArgument("data", this->dataPath_, false); 227 248 ar.checkArgument("ip", serverIp_, false); 228 if(ar.errorHandling()) abortImmediate ();249 if(ar.errorHandling()) abortImmediateForce(); 229 250 if(mode == std::string("client")) 230 251 { … … 249 270 ogre_->setup(); 250 271 //root_ = ogre_->getRoot(); 251 if(!ogre_->load(this->dataPath_)) abortImmediate (/* unable to load */);272 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 252 273 253 274 server_g = new network::Server(); … … 264 285 else 265 286 client_g = new network::Client(serverIp_, NETWORK_PORT); 266 if(!ogre_->load(this->dataPath_)) abortImmediate (/* unable to load */);287 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 267 288 } 268 289 … … 273 294 ogre_->setConfigPath(path); 274 295 ogre_->setup(); 275 //root_ = ogre_->getRoot(); 276 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 296 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 277 297 } 278 298 … … 302 322 auMan_ = new audio::AudioManager(); 303 323 304 //bulletMgr_ = new BulletManager();305 306 324 Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2"); 307 325 HUD* orxonoxHud; … … 351 369 auMan_ = new audio::AudioManager(); 352 370 353 //bulletMgr_ = new BulletManager();354 355 371 // load this file from config 356 372 Level* startlevel = new Level("levels/sample.oxw"); … … 381 397 if (!inputHandler_->initialise(ogre_->getWindowHandle(), 382 398 ogre_->getWindowWidth(), ogre_->getWindowHeight())) 383 abortImmediate ();399 abortImmediateForce(); 384 400 inputHandler_->setInputMode(IM_INGAME); 385 401 } … … 426 442 if (Ogre::Root::getSingletonPtr() == 0) 427 443 { 428 COUT(2) << " Error: Could not start rendering. No Ogre root object found" << std::endl;444 COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl; 429 445 return; 430 446 } 447 Ogre::Root& ogreRoot = Ogre::Root::getSingleton(); 448 431 449 432 450 // Contains the times of recently fired events … … 448 466 { 449 467 // Pump messages in all registered RenderWindows 468 // This calls the WindowEventListener objects. 450 469 Ogre::WindowEventUtilities::messagePump(); 451 470 … … 466 485 467 486 // Iterate through all Tickables and call their tick(dt) function 468 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ) 469 { 470 (it)->tick((float)evt.timeSinceLastFrame * this->timefactor_); 471 it++; 472 } 487 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 488 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 473 489 orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_); 474 490 475 491 // don't forget to call _fireFrameStarted in ogre to make sure 476 492 // everything goes smoothly 477 Ogre::Root::getSingleton()._fireFrameStarted(evt);493 ogreRoot._fireFrameStarted(evt); 478 494 479 495 // server still renders at the moment 480 496 //if (mode_ != SERVER) 481 Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode497 ogreRoot._updateAllRenderTargets(); // only render in non-server mode 482 498 483 499 // get current time … … 489 505 490 506 // again, just to be sure ogre works fine 491 Ogre::Root::getSingleton()._fireFrameEnded(evt);507 ogreRoot._fireFrameEnded(evt); 492 508 } 493 509 } -
code/branches/console/src/orxonox/Orxonox.h
r1136 r1145 61 61 void init(int argc, char **argv, std::string path); 62 62 void start(); 63 // not sure if this should be private 64 void abortImmediate(/* some error code */); 63 void abortImmediateForce(); 65 64 void abortRequest(); 66 65 inline audio::AudioManager* getAudioManagerPointer() { return auMan_; }; … … 106 105 // TODO: make this a config-value by creating a config class for orxonox 107 106 float frameSmoothingTime_; 107 InGameConsole* orxonoxConsole_; 108 108 HUD* orxonoxHUD_; 109 InGameConsole* orxonoxConsole_;110 109 bool bAbort_; //!< aborts the render loop if true 111 110 float timefactor_; //!< A factor to change the gamespeed
Note: See TracChangeset
for help on using the changeset viewer.