[Orxonox-commit 2523] r7228 - in code/branches/consolecommands3/src/libraries/core: . command input

landauf at orxonox.net landauf at orxonox.net
Fri Aug 27 14:41:03 CEST 2010


Author: landauf
Date: 2010-08-27 14:41:03 +0200 (Fri, 27 Aug 2010)
New Revision: 7228

Modified:
   code/branches/consolecommands3/src/libraries/core/XMLPort.h
   code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
   code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h
   code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionListElement.h
   code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.cc
   code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h
   code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc
   code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h
   code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
   code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
   code/branches/consolecommands3/src/libraries/core/command/Executor.cc
   code/branches/consolecommands3/src/libraries/core/command/Executor.h
   code/branches/consolecommands3/src/libraries/core/command/Shell.cc
   code/branches/consolecommands3/src/libraries/core/command/TclBind.cc
   code/branches/consolecommands3/src/libraries/core/command/TclBind.h
   code/branches/consolecommands3/src/libraries/core/command/TclThreadManager.cc
   code/branches/consolecommands3/src/libraries/core/input/InputCommands.cc
Log:
re-implemented CommandExecutor and CommandEvaluation. parameter evaluation is currently not implemented, will come soon.

Modified: code/branches/consolecommands3/src/libraries/core/XMLPort.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/XMLPort.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/XMLPort.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -393,9 +393,9 @@
                         if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
                         {
                             COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
-                            bool success;
-                            this->loadexecutor_->parse(object, attributeValue, &success, ",");
-                            if (success || (mode  == XMLPort::ExpandObject))
+                            int error;
+                            this->loadexecutor_->parse(object, attributeValue, &error, ",");
+                            if (!error || (mode  == XMLPort::ExpandObject))
                                 this->parseResult_ = PR_finished;
                             else
                                 this->parseResult_ = PR_waiting_for_default_values;

Modified: code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -38,6 +38,7 @@
 #include "core/ConfigFileManager.h"
 #include "core/ConfigValueContainer.h"
 #include "TclThreadManager.h"
+#include "ConsoleCommand.h"
 
 // Boost 1.36 has some issues with deprecated functions that have been omitted
 #if (BOOST_VERSION == 103600)
@@ -55,6 +56,49 @@
             return ArgumentCompletionList();
         }
 
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)()
+        {
+            ArgumentCompletionList groupList;
+
+            const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& commands = _ConsoleCommand::getCommands();
+            for (std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
+                // todo: check if active / not hidden / not denied
+                groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
+
+            std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.find("");
+            if (it_group != commands.end())
+            {
+                groupList.push_back(ArgumentCompletionListElement("\n"));
+
+                for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
+                    // todo: check if active / not hidden / not denied
+                    groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+            }
+
+            return groupList;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(subcommands)(const std::string& fragment, const std::string& group)
+        {
+            ArgumentCompletionList commandList;
+
+            std::string groupLC = getLowercase(group);
+
+            std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = _ConsoleCommand::getCommands().begin();
+            for ( ; it_group != _ConsoleCommand::getCommands().end(); ++it_group)
+                if (getLowercase(it_group->first) == groupLC)
+                    break;
+
+            if (it_group != _ConsoleCommand::getCommands().end())
+            {
+                for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
+                    // todo: check if active / not hidden / not denied
+                    commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
+            }
+
+            return commandList;
+        }
+
         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment)
         {
             ArgumentCompletionList dirlist;

Modified: code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -52,6 +52,8 @@
     namespace autocompletion
     {
         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(groupsandcommands)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(subcommands)(const std::string& fragment, const std::string& group);
         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingssections)();
         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsentries)(const std::string& fragment, const std::string& section);

Modified: code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionListElement.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionListElement.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionListElement.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -37,7 +37,7 @@
 namespace orxonox
 {
     const int ACL_MODE_NORMAL    = 1;
-    const int ACL_MODE_LOWERCASE = 2;
+    const int ACL_MODE_COMPARABLE = 2;
     const int ACL_MODE_DISPLAY   = 4;
 
     typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList;
@@ -45,27 +45,29 @@
     class _CoreExport ArgumentCompletionListElement
     {
         public:
-            ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normalCase_(normalcase) {}
-            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE), normalCase_(normalcase), lowerCase_(lowercase) {}
-            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE | ACL_MODE_DISPLAY), normalCase_(normalcase), lowerCase_(lowercase), display_(display) {}
+            ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normal_(normalcase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE), normal_(normalcase), comparable_(lowercase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE | ACL_MODE_DISPLAY), normal_(normalcase), comparable_(lowercase), display_(display) {}
 
             const std::string& getString() const
-                { return this->normalCase_; }
+                { return this->normal_; }
             const std::string& getComparable() const
-                { if (this->mode_ & ACL_MODE_LOWERCASE) { return this->lowerCase_; } else { return this->normalCase_; } }
+                { return (this->mode_ & ACL_MODE_COMPARABLE) ? this->comparable_ : this->normal_; }
             const std::string& getDisplay() const
-                { if (this->mode_ & ACL_MODE_DISPLAY) { return this->display_; } else { return this->normalCase_; } }
+                { return (this->mode_ & ACL_MODE_DISPLAY) ? this->display_ : this->normal_; }
 
-            bool lowercaseComparison() const
-                { return (this->mode_ & ACL_MODE_LOWERCASE); }
+            bool hasComparable() const
+                { return (this->mode_ & ACL_MODE_COMPARABLE); }
+            bool hasDisplay() const
+                { return (this->mode_ & ACL_MODE_DISPLAY); }
 
             bool operator<(const ArgumentCompletionListElement& other) const
                 { return (this->getComparable() < other.getComparable()); }
 
         private:
             unsigned char mode_;
-            std::string normalCase_;
-            std::string lowerCase_;
+            std::string normal_;
+            std::string comparable_;
             std::string display_;
     };
 }

Modified: code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -28,9 +28,8 @@
 
 #include "CommandEvaluation.h"
 
-#include "util/Debug.h"
 #include "util/StringUtils.h"
-#include "core/Identifier.h"
+#include "CommandExecutor.h"
 #include "ConsoleCommand.h"
 
 namespace orxonox
@@ -38,230 +37,190 @@
     CommandEvaluation::CommandEvaluation()
     {
         this->initialize("");
-        this->state_ = CommandState::Uninitialized;
     }
 
     void CommandEvaluation::initialize(const std::string& command)
     {
-        this->bNewCommand_ = true;
-        this->bCommandChanged_ = false;
-        this->originalCommand_ = command;
-        this->command_ = command;
-        this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
+        this->execCommand_ = 0;
+        this->hintCommand_ = 0;
+        this->string_ = command;
+        this->execArgumentsOffset_ = 0;
+        this->hintArgumentsOffset_ = 0;
+        this->bPossibleArgumentsRetrieved_ = false;
+        this->possibleArguments_.clear();
 
-        this->additionalParameter_.clear();
+        this->tokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
+    }
 
-        this->bEvaluatedParams_ = false;
+    unsigned int CommandEvaluation::getNumberOfArguments() const
+    {
+        unsigned int count = this->tokens_.size();
+        if (count > 0 && this->string_[this->string_.size() - 1] != ' ')
+            return count;
+        else
+            return count + 1;
+    }
 
-        this->listOfPossibleIdentifiers_.clear();
-        this->listOfPossibleFunctions_.clear();
-        this->listOfPossibleArguments_.clear();
+    const std::string& CommandEvaluation::getLastArgument() const
+    {
+        if (this->tokens_.size() > 0 && this->string_[this->string_.size() - 1] != ' ')
+            return this->tokens_.back();
+        else
+            return BLANKSTRING;
+    }
 
-        this->functionclass_ = 0;
-        this->function_ = 0;
-        this->possibleArgument_.clear();
-        this->argument_.clear();
-
-        this->errorMessage_.clear();
-        this->state_ = CommandState::Empty;
+    const std::string& CommandEvaluation::getToken(unsigned int i) const
+    {
+        if (i < this->tokens_.size())
+            return this->tokens_[i];
+        else
+            return BLANKSTRING;
     }
 
-    bool CommandEvaluation::execute() const
+    int CommandEvaluation::execute() const
     {
-        bool success;
-        this->query(&success);
-        return success;
+        int error;
+        this->query(&error);
+        return error;
     }
 
-    MultiType CommandEvaluation::query(bool* success) const
+    MultiType CommandEvaluation::query(int* error) const
     {
-        if (success)
-            *success = false;
-
-        if (!this->function_ || !this->function_->isActive())
-            return MT_Type::Null;
-
-        if (this->bEvaluatedParams_ && this->function_)
+        if (error)
         {
-            if (success)
-                *success = true;
-            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << ' ' << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl;
-            return (*this->function_->getExecutor())(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
-        }
+            *error = CommandExecutor::Success;
 
-        if (!this->bCommandChanged_ || nocaseCmp(removeTrailingWhitespaces(this->command_), removeTrailingWhitespaces(this->originalCommand_)) == 0)
-        {
-            COUT(4) << "CE_execute: " << this->command_ << "\n";
+            if (!this->execCommand_)
+                *error = CommandExecutor::Error;
+            else if (!this->execCommand_->isActive())
+                *error = CommandExecutor::Deactivated;
+            else if (!this->execCommand_->hasAccess())
+                *error = CommandExecutor::Denied;
 
-            unsigned int startindex = this->getStartindex();
-            if (this->commandTokens_.size() > startindex)
-                return this->function_->getExecutor()->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()), success);
-            else
-                return this->function_->getExecutor()->parse(removeSlashes(this->additionalParameter_), success);
+            if (*error != CommandExecutor::Success)
+                return MT_Type::Null;
         }
 
-        return MT_Type::Null;
+        if (this->execCommand_ && this->execCommand_->isActive() && this->execCommand_->hasAccess())
+            return this->execCommand_->getExecutor()->parse(this->tokens_.subSet(this->execArgumentsOffset_).join(), error, " ", false);
+        else
+            return MT_Type::Null;
     }
 
-    const std::string& CommandEvaluation::complete()
+    std::string CommandEvaluation::complete() const
     {
-        if (!this->bNewCommand_)
-        {
-            switch (this->state_)
-            {
-                case CommandState::Uninitialized:
-                    break;
-                case CommandState::Empty:
-                    break;
-                case CommandState::ShortcutOrIdentifier:
-                    if (this->function_)
-                    {
-                        if (this->function_->getExecutor()->getParamCount() == 0)
-                            return (this->command_ = this->function_->getName());
-                        else
-                            return (this->command_ = this->function_->getName() + ' ');
-                    }
-                    else if (this->functionclass_)
-                        return (this->command_ = this->functionclass_->getName() + ' ');
-                    break;
-                case CommandState::Function:
-                    if (this->function_)
-                    {
-                        if (this->function_->getExecutor()->getParamCount() == 0)
-                            return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName());
-                        else
-                            return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName() + ' ');
-                    }
-                    break;
-                case CommandState::ParamPreparation:
-                case CommandState::Params:
-                {
-                    if (this->argument_.empty() && this->possibleArgument_.empty())
-                        break;
+        if (!this->hintCommand_ || !this->hintCommand_->isActive())
+            return this->string_;
 
-                    unsigned int maxIndex = this->commandTokens_.size();
-                    if (this->command_[this->command_.size() - 1] != ' ')
-                        maxIndex -= 1;
-                    std::string whitespace;
+        if (!this->bPossibleArgumentsRetrieved_)
+            this->retrievePossibleArguments();
 
-                    if (!this->possibleArgument_.empty())
-                    {
-                        this->argument_ = this->possibleArgument_;
-                        if (this->function_->getExecutor()->getParamCount() > (maxIndex + 1 - this->getStartindex()))
-                            whitespace = " ";
-                    }
+        if (this->possibleArguments_.empty())
+        {
+            return this->string_;
+        }
+        else
+        {
+            std::string output;
+            for (unsigned int i = 0; i < this->getNumberOfArguments() - 1; ++i)
+                output += this->getToken(i) + ' ';
 
-                    return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + ' ' + this->argument_ + whitespace);
-                    break;
-                }
-                case CommandState::Finished:
-                    break;
-                case CommandState::Error:
-                    break;
-            }
+            output += CommandEvaluation::getCommonBegin(this->possibleArguments_);
+            return output;
         }
-        this->bNewCommand_ = false;
-        return this->command_;
     }
 
     std::string CommandEvaluation::hint() const
     {
-        switch (this->state_)
-        {
-            case CommandState::Uninitialized:
-                break;
-            case CommandState::Empty:
-            case CommandState::ShortcutOrIdentifier:
-                if (this->listOfPossibleFunctions_.size() == 0)
-                    return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
-                else if (this->listOfPossibleIdentifiers_.size() == 0)
-                    return CommandEvaluation::dump(this->listOfPossibleFunctions_);
-                else
-                    return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
-                break;
-            case CommandState::Function:
-                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
-                break;
-            case CommandState::ParamPreparation:
-            case CommandState::Params:
-                if (this->listOfPossibleArguments_.size() > 0)
-                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
-                else
-                    return CommandEvaluation::dump(this->function_);
-            case CommandState::Finished:
-                if (this->function_)
-                    return CommandEvaluation::dump(this->function_);
-                break;
-            case CommandState::Error:
-                return this->errorMessage_;
-                break;
-        }
+        if (!this->hintCommand_ || !this->hintCommand_->isActive())
+            return "";
 
-        return "";
-    }
+        if (!this->bPossibleArgumentsRetrieved_)
+            this->retrievePossibleArguments();
 
-    void CommandEvaluation::evaluateParams()
-    {
-        this->bEvaluatedParams_ = false;
+        if (!this->possibleArguments_.empty())
+            return CommandEvaluation::dump(this->possibleArguments_);
 
-        for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
-            this->param_[i] = MT_Type::Null;
-
-        if (!this->function_)
-            return;
-
-        unsigned int startindex = this->getStartindex();
-
-        if (this->commandTokens_.size() <= startindex)
+        if (this->isValid())
         {
-            if (this->function_->getBaseExecutor()->evaluate(this->getAdditionalParameter(), this->param_, " "))
-                this->bEvaluatedParams_ = true;
+            return CommandEvaluation::dump(this->hintCommand_);
         }
-        else if (this->commandTokens_.size() > startindex)
+        else
         {
-            if (this->function_->getBaseExecutor()->evaluate(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
-                this->bEvaluatedParams_ = true;
+            if (this->getNumberOfArguments() > 2)
+            {
+                return std::string("Error: There is no command with name \"") + this->getToken(0) + " " + this->getToken(1) + "\".";
+            }
+            else
+            {
+                std::string groupLC = getLowercase(this->getToken(0));
+                std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = _ConsoleCommand::getCommands().begin();
+                for ( ; it_group != _ConsoleCommand::getCommands().end(); ++it_group)
+                    if (getLowercase(it_group->first) == groupLC)
+                        return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\".";
+
+                return std::string("Error: There is no command starting with \"") + this->getToken(0) + "\".";
+            }
         }
     }
 
-    void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param)
+    void CommandEvaluation::retrievePossibleArguments() const
     {
-        if (index < MAX_FUNCTOR_ARGUMENTS)
-            this->param_[index] = param;
-    }
+        this->bPossibleArgumentsRetrieved_ = true;
+        unsigned int argumentID = std::min(this->getNumberOfArguments() - this->hintArgumentsOffset_, this->hintCommand_->getExecutor()->getParamCount());
+        ArgumentCompleter* ac = this->hintCommand_->getArgumentCompleter(argumentID - 1);
 
-    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
-    {
-        if (index < MAX_FUNCTOR_ARGUMENTS)
-            return this->param_[index];
+COUT(0) << "hint: args: " << this->getNumberOfArguments() << ", aID: " << argumentID << ", offset: " << this->hintArgumentsOffset_ << ", ac: " << ac << std::endl;
+        if (ac)
+        {
+            MultiType param[MAX_FUNCTOR_ARGUMENTS];
 
-        return MT_Type::Null;
+            for (size_t i = 0; i < argumentID; ++i)
+            {
+                param[i] = this->getToken(this->getNumberOfArguments() - i - 1);
+COUT(0) << i << ": " << (this->getNumberOfArguments() - i - 1) << " -> " << this->getToken(this->getNumberOfArguments() - i - 1) << " / " << param[i] << std::endl;
+            }
+
+COUT(0) << "hint: 1: " << param[0] << ", 2: " << param[1] << ", 3: " << param[2] << ", 4: " << param[3] << ", 5: " << param[4] << std::endl;
+            this->possibleArguments_ = (*ac)(param[0], param[1], param[2], param[3], param[4]);
+
+            CommandEvaluation::strip(this->possibleArguments_, param[0]);
+        }
     }
 
-    unsigned int CommandEvaluation::getStartindex() const
+    /* static */ void CommandEvaluation::strip(ArgumentCompletionList& list, const std::string& fragment)
     {
-        if (this->functionclass_ && this->function_)
-            return 2;
-        else if (this->function_)
-            return 1;
-        else
-            return 0;
-    }
+        std::string fragmentLC = getLowercase(fragment);
 
-    std::string CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
-    {
-        std::string output;
-        for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
+        for (ArgumentCompletionList::iterator it = list.begin(); it != list.end(); )
         {
-            if (it != list.begin())
-                output += ' ';
+            const std::string& entry = it->getComparable();
 
-            output += *(it->second);
+            if (entry.size() < fragmentLC.size())
+            {
+                list.erase(it++);
+            }
+            else
+            {
+                bool bErase = false;
+                for (size_t i = 0; i < fragmentLC.size(); ++i)
+                {
+                    if (fragmentLC[i] != entry[i])
+                    {
+                        bErase = true;
+                        break;
+                    }
+                }
+
+                if (bErase)
+                    list.erase(it++);
+                else
+                    ++it;
+            }
         }
-        return output;
     }
 
-    std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
+    /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
     {
         std::string output;
         for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
@@ -274,7 +233,7 @@
         return output;
     }
 
-    std::string CommandEvaluation::dump(const _ConsoleCommand* command)
+    /* static */ std::string CommandEvaluation::dump(const _ConsoleCommand* command)
     {
         std::string output = command->getName();
         if (command->getExecutor()->getParamCount() > 0)
@@ -299,4 +258,54 @@
         }
         return output;
     }
+
+    /* static */ std::string CommandEvaluation::getCommonBegin(const ArgumentCompletionList& list)
+    {
+        if (list.size() == 0)
+        {
+            return "";
+        }
+        else if (list.size() == 1)
+        {
+            if (list.begin()->hasDisplay())
+                return (list.begin()->getString());
+            else
+                return (list.begin()->getString() + ' ');
+        }
+        else
+        {
+            std::string output;
+            for (unsigned int i = 0; true; i++)
+            {
+                char tempComparable = 0;
+                char temp = 0;
+                for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+                {
+                    const std::string& argumentComparable = it->getComparable();
+                    const std::string& argument = it->getString();
+                    if (argument.size() > i)
+                    {
+                        if (it == list.begin())
+                        {
+                            tempComparable = argumentComparable[i];
+                            temp = argument[i];
+                        }
+                        else
+                        {
+                            if (tempComparable != argumentComparable[i])
+                                return output;
+                            else if (temp != argument[i])
+                                temp = tempComparable;
+                        }
+                    }
+                    else
+                    {
+                        return output;
+                    }
+                }
+                output += temp;
+            }
+            return output;
+        }
+    }
 }

Modified: code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -32,7 +32,6 @@
 #include "core/CorePrereqs.h"
 
 #include <string>
-#include <list>
 
 #include "ArgumentCompletionListElement.h"
 #include "util/SubString.h"
@@ -40,21 +39,6 @@
 
 namespace orxonox
 {
-    namespace CommandState
-    {
-        enum Value
-        {
-            Uninitialized,
-            Empty,
-            ShortcutOrIdentifier,
-            Function,
-            ParamPreparation,
-            Params,
-            Finished,
-            Error
-        };
-    }
-
     class _CoreExport CommandEvaluation
     {
         friend class CommandExecutor;
@@ -62,62 +46,45 @@
         public:
             CommandEvaluation();
 
-            void initialize(const std::string& command);
+            int execute() const;
+            MultiType query(int* error = 0) const;
 
-            bool execute() const;
-            MultiType query(bool* success = 0) const;
-
-            const std::string& complete();
+            std::string complete() const;
             std::string hint() const;
-            void evaluateParams();
 
-            bool isValid() const
-                { return this->function_; }
+            inline bool isValid() const
+                { return (this->execCommand_ != 0); }
 
             inline _ConsoleCommand* getConsoleCommand() const
-                { return this->function_; }
-            inline const std::string& getOriginalCommand() const
-                { return this->originalCommand_; }
-            inline const std::string& getCommand() const
-                { return this->command_; }
+                { return this->execCommand_; }
 
-            inline void setAdditionalParameter(const std::string& param)
-                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
-            inline std::string getAdditionalParameter() const
-                { return (!this->additionalParameter_.empty()) ? (' ' + this->additionalParameter_) : ""; }
+//            void setEvaluatedParameter(unsigned int index, MultiType param);
+//            MultiType getEvaluatedParameter(unsigned int index) const;
 
-            void setEvaluatedParameter(unsigned int index, MultiType param);
-            MultiType getEvaluatedParameter(unsigned int index) const;
-
         private:
-            unsigned int getStartindex() const;
-            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
-            static std::string dump(const ArgumentCompletionList& list);
-            static std::string dump(const _ConsoleCommand* command);
+            void initialize(const std::string& command);
 
+            unsigned int getNumberOfArguments() const;
+            const std::string& getLastArgument() const;
+            const std::string& getToken(unsigned int i) const;
 
-            bool bNewCommand_;
-            bool bCommandChanged_;
+            void retrievePossibleArguments() const;
 
-            std::string originalCommand_;
-            std::string command_;
-            SubString commandTokens_;
-            std::string additionalParameter_;
+            static void strip(ArgumentCompletionList& list, const std::string& fragment);
 
-            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
-            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
-            ArgumentCompletionList listOfPossibleArguments_;
+            static std::string dump(const ArgumentCompletionList& list);
+            static std::string dump(const _ConsoleCommand* command);
 
-            Identifier* functionclass_;
-            _ConsoleCommand* function_;
-            std::string possibleArgument_;
-            std::string argument_;
+            static std::string getCommonBegin(const ArgumentCompletionList& list);
 
-            std::string errorMessage_;
-            CommandState::Value state_;
-
-            bool bEvaluatedParams_;
-            MultiType param_[5];
+            _ConsoleCommand* execCommand_;
+            _ConsoleCommand* hintCommand_;
+            SubString tokens_;
+            std::string string_;
+            unsigned int execArgumentsOffset_;
+            unsigned int hintArgumentsOffset_;
+            mutable bool bPossibleArgumentsRetrieved_;
+            mutable ArgumentCompletionList possibleArguments_;
     };
 }
 

Modified: code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -28,625 +28,72 @@
 
 #include "CommandExecutor.h"
 
-#include "util/Debug.h"
-#include "util/StringUtils.h"
-#include "core/Identifier.h"
-#include "core/Language.h"
 #include "ConsoleCommand.h"
 #include "TclBind.h"
+#include "Shell.h"
 
 namespace orxonox
 {
-    CommandExecutor& CommandExecutor::getInstance()
+    static const std::string __CC_CommandExecutor_name = "CommandExecutor";
+    static const std::string __CC_autocomplete_name = "autocomplete";
+
+    _SetConsoleCommand(__CC_CommandExecutor_name, __CC_autocomplete_name, &CommandExecutor::_autocomplete)
+        .hide()
+        .argumentCompleter(0, autocompletion::groupsandcommands())
+        .argumentCompleter(1, autocompletion::subcommands());
+
+    /* static */ CommandExecutor& CommandExecutor::getInstance()
     {
         static CommandExecutor instance;
         return instance;
     }
 
-    CommandEvaluation& CommandExecutor::getEvaluation()
+    /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl)
     {
-        return CommandExecutor::getInstance().evaluation_;
+        int error;
+        CommandExecutor::queryMT(command, &error, useTcl);
+        return error;
     }
 
-    bool CommandExecutor::execute(const std::string& command, bool useTcl)
+    /* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl)
     {
         if (useTcl)
-        {
-            bool success;
-            TclBind::eval(command, &success);
-            return success;
-        }
+            return TclBind::eval(command, error);
         else
-        {
-            CommandExecutor::parseIfNeeded(command);
-            return CommandExecutor::getEvaluation().execute();
-        }
+            return CommandExecutor::evaluate(command).query(error);
     }
 
-    MultiType CommandExecutor::queryMT(const std::string& command, bool* success, bool useTcl)
+    /* static */ std::string CommandExecutor::query(const std::string& command, int* error, bool useTcl)
     {
-        if (useTcl)
-        {
-            return TclBind::eval(command, success);
-        }
-        else
-        {
-            CommandExecutor::parseIfNeeded(command);
-            return CommandExecutor::getEvaluation().query(success);
-        }
+        return CommandExecutor::queryMT(command, error, useTcl).getString();
     }
 
-    std::string CommandExecutor::query(const std::string& command, bool* success, bool useTcl)
+    /* static */ CommandEvaluation CommandExecutor::evaluate(const std::string& command)
     {
-        if (useTcl)
-        {
-            return TclBind::eval(command, success);
-        }
-        else
-        {
-            CommandExecutor::parseIfNeeded(command);
-            return CommandExecutor::getEvaluation().query(success).getString();
-        }
-    }
+        CommandEvaluation evaluation;
+        evaluation.initialize(command);
 
-    std::string CommandExecutor::complete(const std::string& command)
-    {
-        CommandExecutor::parseIfNeeded(command);
-        return CommandExecutor::getEvaluation().complete();
-    }
+        evaluation.hintCommand_ = _ConsoleCommand::getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);
 
-    std::string CommandExecutor::hint(const std::string& command)
-    {
-        CommandExecutor::parseIfNeeded(command);
-        return CommandExecutor::getEvaluation().hint();
-    }
-
-    CommandEvaluation CommandExecutor::evaluate(const std::string& command)
-    {
-        CommandExecutor::parse(command);
-        CommandExecutor::getEvaluation().evaluateParams();
-        return CommandExecutor::getEvaluation();
-    }
-
-    void CommandExecutor::parseIfNeeded(const std::string& command)
-    {
-        if (CommandExecutor::getEvaluation().state_ == CommandState::Uninitialized)
+        if (evaluation.getNumberOfArguments() >= 1)
         {
-            CommandExecutor::parse(command);
-        }
-        else if (CommandExecutor::getEvaluation().originalCommand_ != command)
-        {
-            if (CommandExecutor::getEvaluation().command_ == command)
+            evaluation.execCommand_ = _ConsoleCommand::getCommandLC(evaluation.getToken(0));
+            if (evaluation.execCommand_)
+                evaluation.execArgumentsOffset_ = 1;
+            else if (evaluation.getNumberOfArguments() >= 2)
             {
-                CommandExecutor::parse(command);
-                CommandExecutor::getEvaluation().bNewCommand_ = false;
+                evaluation.execCommand_ = _ConsoleCommand::getCommandLC(evaluation.getToken(0), evaluation.getToken(1));
+                if (evaluation.execCommand_)
+                    evaluation.execArgumentsOffset_ = 2;
             }
-            else
-            {
-                CommandExecutor::parse(command);
-            }
         }
-    }
 
-    void CommandExecutor::parse(const std::string& command, bool bInitialize)
-    {
-        if (bInitialize)
-            CommandExecutor::getEvaluation().initialize(command);
-
-        CommandExecutor::getEvaluation().commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
-        CommandExecutor::getEvaluation().command_ = command;
-
-        switch (CommandExecutor::getEvaluation().state_)
+        if (evaluation.execCommand_ && evaluation.getNumberOfArguments() > evaluation.execArgumentsOffset_)
         {
-            case CommandState::Uninitialized:
-            {
-                // Impossible
-                break;
-            }
-            case CommandState::Empty:
-            {
-                if (CommandExecutor::argumentsGiven() == 0)
-                {
-                    CommandExecutor::createListOfPossibleFunctions("");
-                    CommandExecutor::createListOfPossibleIdentifiers("");
-                    break;
-                }
-                else
-                {
-                    CommandExecutor::getEvaluation().state_ = CommandState::ShortcutOrIdentifier;
-                    // Move on to next case
-                }
-            }
-            case CommandState::ShortcutOrIdentifier:
-            {
-                if (CommandExecutor::argumentsGiven() > 1)
-                {
-                    // There's a finished first argument - check if it's a shortcut or a classname
-                    CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
-                    CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
-
-                    if (CommandExecutor::getEvaluation().function_)
-                    {
-                        // It's a shortcut
-                        CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                        CommandExecutor::getEvaluation().functionclass_ = 0;
-                        // Move on to next case
-                    }
-                    else if (CommandExecutor::getEvaluation().functionclass_)
-                    {
-                        // It's a functionname
-                        CommandExecutor::getEvaluation().state_ = CommandState::Function;
-                        CommandExecutor::getEvaluation().function_ = 0;
-                        // Move on to next case
-                    }
-                    else
-                    {
-                        // The first argument is bad
-                        CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                        AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + ' ' + GetLocalisation("commandexecutorunknownfirstargument") + '.';
-                        return;
-                    }
-                }
-                else
-                {
-                    // There's no finished first argument - search possible shortcuts or classnames
-                    CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
-                    CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
-
-                    unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
-                    unsigned int num_identifiers = CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.size();
-
-                    if (num_functions == 1 && num_identifiers == 0)
-                    {
-                        // It's a shortcut
-                        const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
-                        if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
-                        {
-                            // Unfinished shortcut
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        }
-                        CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                        CommandExecutor::getEvaluation().functionclass_ = 0;
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
-                        if (CommandExecutor::getEvaluation().function_->getExecutor()->getParamCount() > 0)
-                        {
-                            CommandExecutor::getEvaluation().command_ += ' ';
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        }
-                        // Move on to next case
-                    }
-                    else if (num_identifiers == 1 && num_functions == 0)
-                    {
-                        // It's a classname
-                        const std::string& classname = *CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()->first;
-                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
-                        if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
-                        {
-                            // Unfinished classname
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        }
-                        CommandExecutor::getEvaluation().state_ = CommandState::Function;
-                        CommandExecutor::getEvaluation().function_ = 0;
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ';
-                        // Move on to next case
-                    }
-                    else if (num_identifiers == 0 && num_functions == 0)
-                    {
-                        // No possibilities
-                        CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                        AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + ' ' + CommandExecutor::getArgument(0) + '.';
-                        return;
-                    }
-                    else
-                    {
-                        // There are several possiblilities
-                        std::list<std::pair<const std::string*, const std::string*> > temp;
-                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.end());
-                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.end());
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getCommonBegin(temp);
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
-                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
-                        CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                        return;
-                    }
-                }
-            }
-            case CommandState::Function:
-            {
-                if (CommandExecutor::getEvaluation().functionclass_)
-                {
-                    // There is a classname - search for the commandname
-                    if (CommandExecutor::argumentsGiven() > 2)
-                    {
-                        // There is a finished second argument - check if it's a commandname
-                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-
-                        if (CommandExecutor::getEvaluation().function_)
-                        {
-                            // It's a function
-                            CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                            // Move on to next case
-                        }
-                        else
-                        {
-                            // The second argument is bad
-                            CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                            AddLanguageEntry("commandexecutorunknownsecondargument", "is not a function of");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknownsecondargument") + " " + CommandExecutor::getEvaluation().functionclass_->getName() + ".";
-                            return;
-                        }
-                    }
-                    else
-                    {
-                        // There is no finished second argument - search for possibilities
-                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-                        unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
-
-                        if (num_functions == 1)
-                        {
-                            // It's a function
-                            const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
-                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_);
-                            if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1)))
-                            {
-                                // Unfinished function
-                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                            }
-                            CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName();
-                            if (CommandExecutor::getEvaluation().function_->getExecutor()->getParamCount() > 0)
-                            {
-                                CommandExecutor::getEvaluation().command_ += ' ';
-                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                            }
-                            // Move on to next case
-                        }
-                        else if (num_functions == 0)
-                        {
-                            // No possibilities
-                            CommandExecutor::getEvaluation().state_ = CommandState::Error;
-                            AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + GetLocalisation("commandexecutorunknownsecondargumentstart") + ' ' + CommandExecutor::getArgument(1) + '.';
-                            return;
-                        }
-                        else
-                        {
-                            // There are several possibilities
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
-                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
-                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
-                            return;
-                        }
-                    }
-                }
-                else
-                {
-                    // There is no classname - move on to CommandState::ParamPreparation
-                }
-            }
-            case CommandState::ParamPreparation:
-            {
-                if (CommandExecutor::getEvaluation().function_->getExecutor()->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
-                {
-                    CommandExecutor::getEvaluation().state_ = CommandState::Finished;
-                    return;
-                }
-                else
-                {
-                    unsigned int argumentNumber = CommandExecutor::argumentsGiven() - 2;
-                    if (CommandExecutor::getEvaluation().functionclass_)
-                        argumentNumber -= 1;
-
-                    CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
-                    CommandExecutor::getEvaluation().state_ = CommandState::Params;
-
-                    if (CommandExecutor::getEvaluation().bCommandChanged_)
-                    {
-                        // Don't do more than one change
-                        return;
-                    }
-                }
-            }
-            case CommandState::Params:
-            {
-                if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
-                {
-                    // There is exactly one possible argument
-                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
-                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
-                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                    return;
-                }
-                else if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 0)
-                {
-                    // The user tries something new - we let him do
-                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getLastArgument();
-                    return;
-                }
-                else
-                {
-                    // There are several possibilities
-                    unsigned int argumentNumber = CommandExecutor::argumentsGiven();
-                    if (argumentNumber > 0)
-                        --argumentNumber;
-                    if (CommandExecutor::getEvaluation().functionclass_ && argumentNumber > 0)
-                        --argumentNumber;
-
-                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleArguments_);
-                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
-                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                    return;
-                }
-            }
-            case CommandState::Finished:
-            {
-                // Nothing more to do
-                break;
-            }
-            case CommandState::Error:
-            {
-                // Bad, very bad
-                break;
-            }
+            evaluation.hintCommand_ = evaluation.execCommand_;
+            evaluation.hintArgumentsOffset_ = evaluation.execArgumentsOffset_;
         }
-    }
 
-    unsigned int CommandExecutor::argumentsFinished()
-    {
-        unsigned int argumentsGiven = CommandExecutor::argumentsGiven();
-        if (argumentsGiven > 0)
-            return argumentsGiven - 1;
-        else
-            return 0;
+        return evaluation;
     }
-
-    unsigned int CommandExecutor::argumentsGiven()
-    {
-        if (CommandExecutor::getEvaluation().command_.size() > 0 && CommandExecutor::getEvaluation().command_[CommandExecutor::getEvaluation().command_.size() - 1] == ' ')
-            return CommandExecutor::getEvaluation().commandTokens_.size() + 1;
-        else
-            return CommandExecutor::getEvaluation().commandTokens_.size();
-    }
-
-    bool CommandExecutor::enoughArgumentsGiven(_ConsoleCommand* command)
-    {
-        if (CommandExecutor::getEvaluation().functionclass_)
-            return (CommandExecutor::argumentsGiven() > (2 + command->getExecutor()->getParamCount()));
-        else
-            return (CommandExecutor::argumentsGiven() > (1 + command->getExecutor()->getParamCount()));
-    }
-
-    const std::string& CommandExecutor::getArgument(unsigned int index)
-    {
-        if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
-            return CommandExecutor::getEvaluation().commandTokens_[index];
-        else
-            return BLANKSTRING;
-    }
-
-    const std::string& CommandExecutor::getLastArgument()
-    {
-        return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
-    }
-
-    void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
-    {
-/*
-        CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
-        const std::string& lowercase = getLowercase(fragment);
-        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it)
-            if (it->second->hasConsoleCommands())
-                if (it->first.find(lowercase) == 0 || fragment.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
-*/
-    }
-
-    void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier)
-    {
-/*
-        CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
-        const std::string& lowercase = getLowercase(fragment);
-        if (!identifier)
-        {
-            for (std::map<std::string, _ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
-                if (it->first.find(lowercase) == 0 || fragment.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
-        }
-        else
-        {
-            for (std::map<std::string, _ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
-                if (it->first.find(lowercase) == 0 || fragment.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
-        }
-*/
-    }
-
-    void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, _ConsoleCommand* command, unsigned int param)
-    {
-/*
-        CommandExecutor::createArgumentCompletionList(command, param);
-
-        CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
-        const std::string& lowercase = getLowercase(fragment);
-        for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
-        {
-            if (it->lowercaseComparison())
-            {
-                if (it->getComparable().find(lowercase) == 0 || fragment.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
-            }
-            else
-            {
-                if (it->getComparable().find(fragment) == 0 || fragment.empty())
-                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
-            }
-        }
-*/
-    }
-
-    Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
-    {
-/*
-        const std::string& lowercase = getLowercase(name);
-        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase);
-        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && it->second->hasConsoleCommands())
-            return it->second;
-*/
-        return 0;
-    }
-
-    _ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
-    {
-/*
-        const std::string& lowercase = getLowercase(name);
-        if (!identifier)
-        {
-            std::map<std::string, _ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
-            if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
-                return it->second;
-        }
-        else
-        {
-            std::map<std::string, _ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
-            if (it != identifier->getLowercaseConsoleCommandMapEnd())
-                return it->second;
-        }
-*/
-        return 0;
-    }
-
-    const std::string& CommandExecutor::getPossibleArgument(const std::string& name, _ConsoleCommand* command, unsigned int param)
-    {
-/*
-        CommandExecutor::createArgumentCompletionList(command, param);
-
-        const std::string& lowercase = getLowercase(name);
-        for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
-        {
-            if (it->lowercaseComparison())
-            {
-                if (it->getComparable() == lowercase)
-                    return it->getString();
-            }
-            else
-            {
-                if (it->getComparable() == name)
-                    return it->getString();
-            }
-        }
-*/
-        return BLANKSTRING;
-    }
-
-    void CommandExecutor::createArgumentCompletionList(_ConsoleCommand* command, unsigned int param)
-    {
-/*
-        std::string params[5];
-
-        unsigned int index = 0;
-        unsigned int lowestIndex = 1 + (CommandExecutor::getEvaluation().functionclass_ != 0);
-
-        for (unsigned int i = CommandExecutor::argumentsGiven() - 1; i >= lowestIndex; --i)
-        {
-            params[index] = CommandExecutor::getArgument(i);
-            ++index;
-            if (index >= 5)
-                break;
-        }
-
-        command->createArgumentCompletionList(param, params[0], params[1], params[2], params[3], params[4]);
-*/
-    }
-
-    std::string CommandExecutor::getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list)
-    {
-        if (list.size() == 0)
-        {
-            return "";
-        }
-        else if (list.size() == 1)
-        {
-            return ((*list.begin()->first) + ' ');
-        }
-        else
-        {
-            std::string output;
-            for (unsigned int i = 0; true; i++)
-            {
-                char temp = 0;
-                for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
-                {
-                    if (it->first->size() > i)
-                    {
-                        if (it == list.begin())
-                        {
-                            temp = (*it->first)[i];
-                        }
-                        else
-                        {
-                            if (temp != (*it->first)[i])
-                                return output;
-                        }
-                    }
-                    else
-                    {
-                        return output;
-                    }
-                }
-                output += temp;
-            }
-            return output;
-        }
-    }
-
-    std::string CommandExecutor::getCommonBegin(const ArgumentCompletionList& list)
-    {
-        if (list.size() == 0)
-        {
-            return "";
-        }
-        else if (list.size() == 1)
-        {
-            return (list.begin()->getComparable() + ' ');
-        }
-        else
-        {
-            std::string output;
-            for (unsigned int i = 0; true; i++)
-            {
-                char tempComparable = 0;
-                char temp = 0;
-                for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
-                {
-                    const std::string& argumentComparable = it->getComparable();
-                    const std::string& argument = it->getString();
-                    if (argument.size() > i)
-                    {
-                        if (it == list.begin())
-                        {
-                            tempComparable = argumentComparable[i];
-                            temp = argument[i];
-                        }
-                        else
-                        {
-                            if (tempComparable != argumentComparable[i])
-                                return output;
-                            else if (temp != argument[i])
-                                temp = tempComparable;
-                        }
-                    }
-                    else
-                    {
-                        return output;
-                    }
-                }
-                output += temp;
-            }
-            return output;
-        }
-    }
 }

Modified: code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -31,8 +31,6 @@
 
 #include "core/CorePrereqs.h"
 
-#include <map>
-#include <set>
 #include <string>
 
 #include "util/MultiType.h"
@@ -45,46 +43,27 @@
     {
 // tolua_end
         public:
-            static bool execute(const std::string& command, bool useTcl = true); // tolua_export
+            static int execute(const std::string& command, bool useTcl = true); // tolua_export
 
-            static MultiType queryMT(const std::string& command, bool* success = 0, bool useTcl = true);
-            static std::string query(const std::string& command, bool* success = 0, bool useTcl = true); // tolua_export
+            static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true);
+            static std::string query(const std::string& command, int* error = 0, bool useTcl = true); // tolua_export
 
-            static std::string complete(const std::string& command);
-            static std::string hint(const std::string& command);
-
             static CommandEvaluation evaluate(const std::string& command);
 
+            static const int Success = 0;
+            static const int Error = 1;
+            static const int Incomplete = 2;
+            static const int Deactivated = 3;
+            static const int Denied = 4;
+
+            static void _autocomplete(const std::string& group, const std::string& name) {}
+
         private:
             CommandExecutor() {}
             CommandExecutor(const CommandExecutor& other);
             ~CommandExecutor() {}
 
             static CommandExecutor& getInstance();
-            static CommandEvaluation& getEvaluation();
-
-            static void parseIfNeeded(const std::string& command);
-            static void parse(const std::string& command, bool bInitialize = true);
-
-            static unsigned int argumentsFinished();
-            static unsigned int argumentsGiven();
-            static bool enoughArgumentsGiven(_ConsoleCommand* command);
-            static const std::string& getArgument(unsigned int index);
-            static const std::string& getLastArgument();
-
-            static void createListOfPossibleIdentifiers(const std::string& fragment);
-            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
-            static void createListOfPossibleArguments(const std::string& fragment, _ConsoleCommand* command, unsigned int param);
-
-            static Identifier* getPossibleIdentifier(const std::string& name);
-            static _ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
-            static const std::string& getPossibleArgument(const std::string& name, _ConsoleCommand* command, unsigned int param);
-
-            static void createArgumentCompletionList(_ConsoleCommand* command, unsigned int param);
-            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
-            static std::string getCommonBegin(const ArgumentCompletionList& list);
-
-            CommandEvaluation evaluation_;
     }; // tolua_export
 } // tolua_export
 

Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -29,6 +29,7 @@
 #include "ConsoleCommand.h"
 
 #include "util/Convert.h"
+#include "util/StringUtils.h"
 #include "core/Language.h"
 #include "core/GameMode.h"
 
@@ -397,7 +398,7 @@
         return GetLocalisation_noerror(this->descriptionReturnvalue_);
     }
 
-    /* static */ const _ConsoleCommand* _ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError)
+    /* static */ _ConsoleCommand* _ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError)
     {
         std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = _ConsoleCommand::getCommandMap().find(group);
         if (it_group != _ConsoleCommand::getCommandMap().end())
@@ -418,12 +419,42 @@
         return 0;
     }
 
+    /* static */ _ConsoleCommand* _ConsoleCommand::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        std::string groupLC = getLowercase(group);
+        std::string nameLC = getLowercase(name);
+
+        std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = _ConsoleCommand::getCommandMapLC().find(groupLC);
+        if (it_group != _ConsoleCommand::getCommandMapLC().end())
+        {
+            std::map<std::string, _ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);
+            if (it_name != it_group->second.end())
+            {
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
+            else
+                COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
+        }
+        return 0;
+    }
+
     /* static */ std::map<std::string, std::map<std::string, _ConsoleCommand*> >& _ConsoleCommand::getCommandMap()
     {
         static std::map<std::string, std::map<std::string, _ConsoleCommand*> > commandMap;
         return commandMap;
     }
 
+    /* static */ std::map<std::string, std::map<std::string, _ConsoleCommand*> >& _ConsoleCommand::getCommandMapLC()
+    {
+        static std::map<std::string, std::map<std::string, _ConsoleCommand*> > commandMapLC;
+        return commandMapLC;
+    }
+
     /* static */ void _ConsoleCommand::registerCommand(const std::string& group, const std::string& name, _ConsoleCommand* command)
     {
         if (name == "")
@@ -439,6 +470,7 @@
         else
         {
             _ConsoleCommand::getCommandMap()[group][name] = command;
+            _ConsoleCommand::getCommandMapLC()[getLowercase(group)][getLowercase(name)] = command;
         }
     }
 
@@ -459,6 +491,22 @@
             else
                 ++it_group;
         }
+
+        for (std::map<std::string, std::map<std::string, _ConsoleCommand*> >::iterator it_group = _ConsoleCommand::getCommandMapLC().begin(); it_group != _ConsoleCommand::getCommandMapLC().end(); )
+        {
+            for (std::map<std::string, _ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            if (it_group->second.empty())
+                _ConsoleCommand::getCommandMapLC().erase(it_group++);
+            else
+                ++it_group;
+        }
     }
 
     /* static */ void _ConsoleCommand::destroyAll()

Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -328,15 +328,23 @@
         public:
             static inline const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommands()
                 { return _ConsoleCommand::getCommandMap(); }
+            static inline const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommandsLC()
+                { return _ConsoleCommand::getCommandMapLC(); }
 
-            static inline const _ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
+            static inline _ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
                 { return _ConsoleCommand::getCommand("", name, bPrintError); }
-            static const _ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
+            static inline _ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
+                { return _ConsoleCommand::getCommandLC("", name, bPrintError); }
 
+            static _ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
+            static _ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
+
             static void destroyAll();
 
         private:
             static std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommandMap();
+            static std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommandMapLC();
+
             static void registerCommand(const std::string& group, const std::string& name, _ConsoleCommand* command);
             static void unregisterCommand(_ConsoleCommand* command);
     };

Modified: code/branches/consolecommands3/src/libraries/core/command/Executor.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/Executor.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/Executor.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -35,6 +35,7 @@
 #include "util/Debug.h"
 #include "util/StringUtils.h"
 #include "util/SubString.h"
+#include "CommandExecutor.h"
 
 namespace orxonox
 {
@@ -48,10 +49,10 @@
     {
     }
 
-    MultiType Executor::parse(const std::string& params, bool* success, const std::string& delimiter) const
+    MultiType Executor::parse(const std::string& params, int* error, const std::string& delimiter, bool bPrintError) const
     {
-        if (success)
-            *success = true;
+        if (error)
+            *error = CommandExecutor::Success;
 
         unsigned int paramCount = this->functor_->getParamCount();
 
@@ -75,9 +76,10 @@
             }
             else
             {
-                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl;
-                if (success)
-                    *success = false;
+                if (bPrintError)
+                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl;
+                if (error)
+                    *error = CommandExecutor::Incomplete;
                 return MT_Type::Null;
             }
         }
@@ -89,9 +91,10 @@
             {
                 if (this->defaultValue_[i].null())
                 {
-                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl;
-                    if (success)
-                        *success = false;
+                    if (bPrintError)
+                        COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << params << ")." << std::endl;
+                    if (error)
+                        *error = CommandExecutor::Incomplete;
                     return MT_Type::Null;
                 }
             }

Modified: code/branches/consolecommands3/src/libraries/core/command/Executor.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/Executor.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/Executor.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -58,7 +58,7 @@
             inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
                 { return (*this->functor_)(param1, param2, param3, param4, param5); }
 
-            MultiType parse(const std::string& params, bool* success = 0, const std::string& delimiter = " ") const;
+            MultiType parse(const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const;
 
             bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
 
@@ -163,23 +163,23 @@
 
             using Executor::parse;
 
-            MultiType parse(T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
+            MultiType parse(T* object, const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const
             {
                 T* oldobject = this->functorMember_->getObject();
 
                 this->functorMember_->setObject(object);
-                const MultiType& result = this->Executor::parse(params, success, delimiter);
+                const MultiType& result = this->Executor::parse(params, error, delimiter, bPrintError);
                 this->functorMember_->setObject(oldobject);
 
                 return result;
             }
 
-            MultiType parse(const T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
+            MultiType parse(const T* object, const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const
             {
                 T* oldobject = this->functorMember_->getObject();
 
                 this->functorMember_->setObject(object);
-                const MultiType& result = this->Executor::parse(params, success, delimiter);
+                const MultiType& result = this->Executor::parse(params, error, delimiter, bPrintError);
                 this->functorMember_->setObjects(oldobject);
 
                 return result;

Modified: code/branches/consolecommands3/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/Shell.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/Shell.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -314,11 +314,17 @@
         this->addToHistory(this->inputBuffer_->get());
         this->updateListeners<&ShellListener::executed>();
 
-        bool success;
-        const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &success);
-        if (!success)
+        int error;
+        const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error);
+        if (error)
         {
-            this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
+            switch (error)
+            {
+                case CommandExecutor::Error:       this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command doesn't exist. (S)" << std::endl; break;
+                case CommandExecutor::Incomplete:  this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", not enough arguments given. (S)" << std::endl; break;
+                case CommandExecutor::Deactivated: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command is not active. (S)" << std::endl; break;
+                case CommandExecutor::Denied:      this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", access denied. (S)" << std::endl; break;
+            }
             this->outputChanged(Error);
         }
         else if (result != "")
@@ -332,8 +338,8 @@
 
     void Shell::hintAndComplete()
     {
-        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
-        this->outputBuffer_ << CommandExecutor::hint(this->inputBuffer_->get()) << std::endl;
+        this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete());
+        this->outputBuffer_ << CommandExecutor::evaluate(this->inputBuffer_->get()).hint() << std::endl;
         this->outputChanged(Hint);
 
         this->inputChanged();

Modified: code/branches/consolecommands3/src/libraries/core/command/TclBind.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/TclBind.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/TclBind.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -133,11 +133,14 @@
 
         const std::string& command = stripEnclosingBraces(args.get());
 
-        bool success;
-        const std::string& result = CommandExecutor::query(command, &success, false);
-        if (!success)
+        int error;
+        const std::string& result = CommandExecutor::query(command, &error, false);
+        switch (error)
         {
-            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+            case CommandExecutor::Error:       COUT(1) << "Error: Can't execute command \"" << command << "\", command doesn't exist. (B)" << std::endl; break;
+            case CommandExecutor::Incomplete:  COUT(1) << "Error: Can't execute command \"" << command << "\", not enough arguments given. (B)" << std::endl; break;
+            case CommandExecutor::Deactivated: COUT(1) << "Error: Can't execute command \"" << command << "\", command is not active. (B)" << std::endl; break;
+            case CommandExecutor::Denied:      COUT(1) << "Error: Can't execute command \"" << command << "\", access denied. (B)" << std::endl; break;
         }
 
         return result;
@@ -148,7 +151,7 @@
         COUT(4) << "Tcl_execute: " << args.get() << std::endl;
         const std::string& command = stripEnclosingBraces(args.get());
 
-        if (!CommandExecutor::execute(command, false))
+        if (CommandExecutor::execute(command, false))
         {
             COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
         }
@@ -179,10 +182,10 @@
         COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
     }
 
-    std::string TclBind::eval(const std::string& tclcode, bool* success)
+    std::string TclBind::eval(const std::string& tclcode, int* error)
     {
-        if (success)
-            *success = true;
+        if (error)
+            *error = CommandExecutor::Success;
 
         try
         {
@@ -191,8 +194,8 @@
         catch (Tcl::tcl_error const &e)
         {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
 
-        if (success)
-            *success = false;
+        if (error)
+            *error = CommandExecutor::Error;
         return "";
     }
 }

Modified: code/branches/consolecommands3/src/libraries/core/command/TclBind.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/TclBind.h	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/TclBind.h	2010-08-27 12:41:03 UTC (rev 7228)
@@ -58,7 +58,7 @@
             static std::string tcl_query(Tcl::object const &args);
             static void tcl_execute(Tcl::object const &args);
 
-            static std::string eval(const std::string& tclcode, bool* success = 0);
+            static std::string eval(const std::string& tclcode, int* error = 0);
 
         private:
             TclBind(const TclBind& other);

Modified: code/branches/consolecommands3/src/libraries/core/command/TclThreadManager.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/TclThreadManager.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/command/TclThreadManager.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -438,10 +438,15 @@
                     {
                         // It's a query to the CommandExecutor
                         TclThreadManager::debug("TclThread_query -> CE: " + command);
-                        bool success;
-                        output = CommandExecutor::query(command, &success, false);
-                        if (!success)
-                            TclThreadManager::error("Error: Can't execute command \"" + command + "\"!");
+                        int error;
+                        output = CommandExecutor::query(command, &error, false);
+                        switch (error)
+                        {
+                            case CommandExecutor::Error:       TclThreadManager::error("Error: Can't execute command \"" + command + "\", command doesn't exist. (T)"); break;
+                            case CommandExecutor::Incomplete:  TclThreadManager::error("Error: Can't execute command \"" + command + "\", not enough arguments given. (T)"); break;
+                            case CommandExecutor::Deactivated: TclThreadManager::error("Error: Can't execute command \"" + command + "\", command is not active. (T)"); break;
+                            case CommandExecutor::Denied:      TclThreadManager::error("Error: Can't execute command \"" + command + "\", access denied. (T)"); break;
+                        }
                     }
                     else
                     {

Modified: code/branches/consolecommands3/src/libraries/core/input/InputCommands.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/input/InputCommands.cc	2010-08-27 11:47:49 UTC (rev 7227)
+++ code/branches/consolecommands3/src/libraries/core/input/InputCommands.cc	2010-08-27 12:41:03 UTC (rev 7228)
@@ -52,7 +52,7 @@
     {
         if (this->abs_ != 0.0f || this->rel_ != 0.0f)
         {
-            evaluation_.setEvaluatedParameter(paramIndex_, Vector2(abs_, rel_));
+//            evaluation_.setEvaluatedParameter(paramIndex_, Vector2(abs_, rel_));
             // reset
             rel_ = 0.0;
             abs_ = 0.0;




More information about the Orxonox-commit mailing list