Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1145 for code/branches


Ignore:
Timestamp:
Apr 23, 2008, 9:42:12 AM (17 years ago)
Author:
rgrieder
Message:
  • changes made in Orxonox.cc and Orxonox.h were overwritten by older files. reverted those.
Location:
code/branches/console/src/orxonox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/orxonox/Orxonox.cc

    r1143 r1145  
    5454//#include "util/Sleep.h"
    5555#include "util/ArgReader.h"
     56#include "util/ExprParser.h"
    5657
    5758// core
     
    7677#include "hud/HUD.h"
    7778#include "console/InGameConsole.h"
    78 //#include "objects/weapon/BulletManager.h"
    7979
    8080// FIXME: is this really file scope?
     
    126126  };
    127127
     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
    128150  /**
    129151    @brief Reference to the only instance of the class.
     
    141163    this->auMan_ = 0;
    142164    this->inputHandler_ = 0;
    143     //this->root_ = 0;
    144165    // turn on frame smoothing by setting a value different from 0
    145166    this->frameSmoothingTime_ = 0.0f;
     
    154175  {
    155176    // keep in mind: the order of deletion is very important!
    156 //    if (this->bulletMgr_)
    157 //      delete this->bulletMgr_;
    158177    if (this->orxonoxHUD_)
    159178      delete this->orxonoxHUD_;
     
    173192
    174193  /**
    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;
    180200    delete this;
    181201  }
     
    186206  void Orxonox::abortRequest()
    187207  {
     208    COUT(3) << "*** Orxonox: Abort requested." << std::endl;
    188209    bAbort_ = true;
    189210  }
     
    226247    ar.checkArgument("data", this->dataPath_, false);
    227248    ar.checkArgument("ip", serverIp_, false);
    228     if(ar.errorHandling()) abortImmediate();
     249    if(ar.errorHandling()) abortImmediateForce();
    229250    if(mode == std::string("client"))
    230251    {
     
    249270    ogre_->setup();
    250271    //root_ = ogre_->getRoot();
    251     if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
     272    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
    252273
    253274    server_g = new network::Server();
     
    264285    else
    265286      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 */);
    267288  }
    268289
     
    273294    ogre_->setConfigPath(path);
    274295    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 */);
    277297  }
    278298
     
    302322    auMan_ = new audio::AudioManager();
    303323
    304     //bulletMgr_ = new BulletManager();
    305 
    306324    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    307325    HUD* orxonoxHud;
     
    351369    auMan_ = new audio::AudioManager();
    352370
    353     //bulletMgr_ = new BulletManager();
    354 
    355371    // load this file from config
    356372    Level* startlevel = new Level("levels/sample.oxw");
     
    381397    if (!inputHandler_->initialise(ogre_->getWindowHandle(),
    382398          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
    383       abortImmediate();
     399      abortImmediateForce();
    384400    inputHandler_->setInputMode(IM_INGAME);
    385401  }
     
    426442    if (Ogre::Root::getSingletonPtr() == 0)
    427443    {
    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;
    429445      return;
    430446    }
     447    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
     448
    431449
    432450    // Contains the times of recently fired events
     
    448466          {
    449467                  // Pump messages in all registered RenderWindows
     468      // This calls the WindowEventListener objects.
    450469      Ogre::WindowEventUtilities::messagePump();
    451470
     
    466485
    467486      // 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_);
    473489      orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    474490
    475491      // don't forget to call _fireFrameStarted in ogre to make sure
    476492      // everything goes smoothly
    477       Ogre::Root::getSingleton()._fireFrameStarted(evt);
     493      ogreRoot._fireFrameStarted(evt);
    478494
    479495      // server still renders at the moment
    480496      //if (mode_ != SERVER)
    481       Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode
     497      ogreRoot._updateAllRenderTargets(); // only render in non-server mode
    482498
    483499      // get current time
     
    489505
    490506      // again, just to be sure ogre works fine
    491       Ogre::Root::getSingleton()._fireFrameEnded(evt);
     507      ogreRoot._fireFrameEnded(evt);
    492508          }
    493509  }
  • code/branches/console/src/orxonox/Orxonox.h

    r1136 r1145  
    6161      void init(int argc, char **argv, std::string path);
    6262      void start();
    63       // not sure if this should be private
    64       void abortImmediate(/* some error code */);
     63      void abortImmediateForce();
    6564      void abortRequest();
    6665      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
     
    106105      // TODO: make this a config-value by creating a config class for orxonox
    107106      float                 frameSmoothingTime_;
     107      InGameConsole*        orxonoxConsole_;
    108108      HUD*                  orxonoxHUD_;
    109       InGameConsole*        orxonoxConsole_;
    110109      bool                  bAbort_;        //!< aborts the render loop if true
    111110      float                 timefactor_;    //!< A factor to change the gamespeed
Note: See TracChangeset for help on using the changeset viewer.