Index: code/branches/core2/src/orxonox/core/CommandExecutor.cc
===================================================================
--- code/branches/core2/src/orxonox/core/CommandExecutor.cc	(revision 953)
+++ code/branches/core2/src/orxonox/core/CommandExecutor.cc	(revision 955)
@@ -49,4 +49,20 @@
     // CommandEvaluation //
     ///////////////////////
+    CommandEvaluation::CommandEvaluation()
+    {
+        this->processedCommand_ = "";
+        this->additionalParameter_ = "";
+
+        this->functionclass_ = 0;
+        this->configvalueclass_ = 0;
+        this->shortcut_ = 0;
+        this->function_ = 0;
+        this->configvalue_ = 0;
+        this->key_ = 0;
+
+        this->errorMessage_ = "";
+        this->state_ = CS_Uninitialized;
+    }
+
     KeybindMode CommandEvaluation::getKeybindMode()
     {
@@ -156,5 +172,5 @@
     bool CommandExecutor::execute(const std::string& command)
     {
-        if (CommandExecutor::getEvaluation().processedCommand_ != command)
+        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
             CommandExecutor::parse(command);
 
@@ -169,4 +185,6 @@
         switch (evaluation.state_)
         {
+            case CS_Uninitialized:
+                break;
             case CS_Empty:
                 break;
@@ -227,5 +245,5 @@
     std::string CommandExecutor::complete(const std::string& command)
     {
-        if (CommandExecutor::getEvaluation().processedCommand_ != command)
+        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
             CommandExecutor::parse(command);
 
@@ -246,6 +264,8 @@
         switch (evaluation.state_)
         {
+            case CS_Uninitialized:
+                break;
             case CS_Empty:
-                return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(temp));
+                return (CommandExecutor::getCommonBegin(temp));
                 break;
             case CS_FunctionClass_Or_Shortcut_Or_Keyword:
@@ -258,5 +278,6 @@
                 break;
             case CS_Function:
-                return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_));
+                if (tokens.size() >= 1)
+                    return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_);
                 break;
             case CS_Function_Params:
@@ -267,8 +288,10 @@
                 break;
             case CS_ConfigValueClass:
-                return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_));
+                if (tokens.size() >= 1)
+                    return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_);
                 break;
             case CS_ConfigValue:
-                return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_));
+                if (tokens.size() >= 2)
+                    return tokens[0] + " " + tokens[1] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_);
                 break;
             case CS_ConfigValueType:
@@ -279,5 +302,6 @@
                 break;
             case CS_KeybindKey:
-                return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_));
+                if (tokens.size() >= 1)
+                    return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_);
                 break;
             case CS_KeybindCommand:
@@ -296,5 +320,5 @@
     std::string CommandExecutor::hint(const std::string& command)
     {
-        if (CommandExecutor::getEvaluation().processedCommand_ != command)
+        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
             CommandExecutor::parse(command);
 
@@ -308,4 +332,6 @@
         switch (evaluation.state_)
         {
+            case CS_Uninitialized:
+                break;
             case CS_Empty:
                 return (CommandExecutor::dump(evaluation.listOfPossibleShortcuts_) + "\n" + CommandExecutor::dump(evaluation.listOfPossibleFunctionClasses_));
@@ -358,5 +384,5 @@
                 break;
             case CS_Error:
-                return "Error";
+                return CommandExecutor::getEvaluation().errorMessage_;
                 break;
         }
@@ -381,4 +407,7 @@
         switch (CommandExecutor::getEvaluation().state_)
         {
+            case CS_Uninitialized:
+                // Impossible
+                break;
             case CS_Empty:
                 if (CommandExecutor::argumentsGiven() == 0)
@@ -635,5 +664,5 @@
                         {
                             CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_);
-                            if (CommandExecutor::getEvaluation().configvalueclass_ != 0)
+                            if (CommandExecutor::getEvaluation().configvalue_ != 0)
                             {
                                 // There is a perfect match: Add a whitespace and continue parsing
@@ -791,5 +820,5 @@
             if ((*it).second->hasConsoleCommands())
             {
-                if ((*it).first.find(getLowercase(fragment)) == 0)
+                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
                 {
                     CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.push_back(&(*it).first);
@@ -805,5 +834,5 @@
         for (std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
         {
-            if ((*it).first.find(getLowercase(fragment)) == 0)
+            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
             {
                 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.push_back(&(*it).first);
@@ -818,5 +847,5 @@
         for (std::map<std::string, ExecutorStatic*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
         {
-            if ((*it).first.find(getLowercase(fragment)) == 0)
+            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
             {
                 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(&(*it).first);
@@ -833,5 +862,5 @@
             if ((*it).second->hasConfigValues())
             {
-                if ((*it).first.find(getLowercase(fragment)) == 0)
+                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
                 {
                     CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.push_back(&(*it).first);
@@ -847,5 +876,5 @@
         for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->getLowercaseConfigValueMapBegin(); it != identifier->getLowercaseConfigValueMapEnd(); ++it)
         {
-            if ((*it).first.find(getLowercase(fragment)) == 0)
+            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
             {
                 CommandExecutor::getEvaluation().listOfPossibleConfigValues_.push_back(&(*it).first);
@@ -908,5 +937,7 @@
         std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->getLowercaseConfigValueMap().find(getLowercase(name));
         if (it != identifier->getLowercaseConfigValueMapEnd())
+        {
             return (*it).second;
+        }
 
         return 0;
