Index: code/branches/console/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/console/src/orxonox/Orxonox.cc	(revision 1143)
+++ code/branches/console/src/orxonox/Orxonox.cc	(revision 1145)
@@ -54,4 +54,5 @@
 //#include "util/Sleep.h"
 #include "util/ArgReader.h"
+#include "util/ExprParser.h"
 
 // core
@@ -76,5 +77,4 @@
 #include "hud/HUD.h"
 #include "console/InGameConsole.h"
-//#include "objects/weapon/BulletManager.h"
 
 // FIXME: is this really file scope?
@@ -126,4 +126,26 @@
   };
 
+  class Calculator
+  {
+  public:
+    static void calculate(const std::string& calculation)
+    {
+      ExprParser expr(calculation);
+      if (expr.getSuccess())
+      {
+        if (expr.getResult() == 42.0)
+          std::cout << "Greetings from the restaurant at the end of the universe." << std::endl;
+        // FIXME: insert modifier to display in full precision
+        std::cout << "Result is: " << expr.getResult() << std::endl;
+        if (expr.getRemains() != "")
+          std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
+              << expr.getRemains() << "'" << std::endl;
+      }
+      else
+        std::cout << "Cannot calculate expression: Parse error" << std::endl;
+    }
+  };
+  ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None);
+
   /**
     @brief Reference to the only instance of the class.
@@ -141,5 +163,4 @@
     this->auMan_ = 0;
     this->inputHandler_ = 0;
-    //this->root_ = 0;
     // turn on frame smoothing by setting a value different from 0
     this->frameSmoothingTime_ = 0.0f;
@@ -154,6 +175,4 @@
   {
     // keep in mind: the order of deletion is very important!
-//    if (this->bulletMgr_)
-//      delete this->bulletMgr_;
     if (this->orxonoxHUD_)
       delete this->orxonoxHUD_;
@@ -173,9 +192,10 @@
 
   /**
-   * error kills orxonox
-   */
-  void Orxonox::abortImmediate(/* some error code */)
-  {
-    //TODO: destroy and destruct everything and print nice error msg
+    @brief Immediately deletes the orxonox object.
+    Never use if you can help it while rendering!
+  */
+  void Orxonox::abortImmediateForce()
+  {
+    COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl;
     delete this;
   }
@@ -186,4 +206,5 @@
   void Orxonox::abortRequest()
   {
+    COUT(3) << "*** Orxonox: Abort requested." << std::endl;
     bAbort_ = true;
   }
@@ -226,5 +247,5 @@
     ar.checkArgument("data", this->dataPath_, false);
     ar.checkArgument("ip", serverIp_, false);
-    if(ar.errorHandling()) abortImmediate();
+    if(ar.errorHandling()) abortImmediateForce();
     if(mode == std::string("client"))
     {
@@ -249,5 +270,5 @@
     ogre_->setup();
     //root_ = ogre_->getRoot();
-    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
+    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
 
     server_g = new network::Server();
@@ -264,5 +285,5 @@
     else
       client_g = new network::Client(serverIp_, NETWORK_PORT);
-    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
+    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
   }
 
@@ -273,6 +294,5 @@
     ogre_->setConfigPath(path);
     ogre_->setup();
-    //root_ = ogre_->getRoot();
-    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
+    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
   }
 
@@ -302,6 +322,4 @@
     auMan_ = new audio::AudioManager();
 
-    //bulletMgr_ = new BulletManager();
-
     Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
     HUD* orxonoxHud;
@@ -351,6 +369,4 @@
     auMan_ = new audio::AudioManager();
 
-    //bulletMgr_ = new BulletManager();
-
     // load this file from config
     Level* startlevel = new Level("levels/sample.oxw");
@@ -381,5 +397,5 @@
     if (!inputHandler_->initialise(ogre_->getWindowHandle(),
           ogre_->getWindowWidth(), ogre_->getWindowHeight()))
-      abortImmediate();
+      abortImmediateForce();
     inputHandler_->setInputMode(IM_INGAME);
   }
@@ -426,7 +442,9 @@
     if (Ogre::Root::getSingletonPtr() == 0)
     {
-      COUT(2) << "Error: Could not start rendering. No Ogre root object found" << std::endl;
+      COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
       return;
     }
+    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
+
 
     // Contains the times of recently fired events
@@ -448,4 +466,5 @@
 	  {
 		  // Pump messages in all registered RenderWindows
+      // This calls the WindowEventListener objects.
       Ogre::WindowEventUtilities::messagePump();
 
@@ -466,18 +485,15 @@
 
       // Iterate through all Tickables and call their tick(dt) function
-      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
-      {
-        (it)->tick((float)evt.timeSinceLastFrame * this->timefactor_);
-        it++;
-      }
+      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
+        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
       orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);
 
       // don't forget to call _fireFrameStarted in ogre to make sure
       // everything goes smoothly
-      Ogre::Root::getSingleton()._fireFrameStarted(evt);
+      ogreRoot._fireFrameStarted(evt);
 
       // server still renders at the moment
       //if (mode_ != SERVER)
-      Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode
+      ogreRoot._updateAllRenderTargets(); // only render in non-server mode
 
       // get current time
@@ -489,5 +505,5 @@
 
       // again, just to be sure ogre works fine
-      Ogre::Root::getSingleton()._fireFrameEnded(evt);
+      ogreRoot._fireFrameEnded(evt);
 	  }
   }
