Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 30, 2008, 5:38:03 AM (16 years ago)
Author:
landauf
Message:
  • added set and tset functions to the ConfigValueContainer to (temporary) set a config-value to a new value
  • ConfigValueContainer uses now the functions of MultiTypeMath to convert and assign values
  • added some errorhandling to the CommandExecutor in case there are not enough parameters when executing the command
  • added updateConfigValues function to Identifier
  • added addTime and removeTime functions to the Timer
  • some changes in Executor to allow adding description and default-values when using the ConsoleCommand macro
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/CommandExecutor.cc

    r955 r957  
    192192                break;
    193193            case CS_Shortcut_Params:
    194                 // not enough parameters but lets hope there are some additional parameters
    195                 if (evaluation.shortcut_ != 0)
    196                     return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_);
    197                 break;
     194                // not enough parameters but lets hope there are some additional parameters and go on
    198195            case CS_Shortcut_Finished:
    199196                // call the shortcut
    200197                if (evaluation.shortcut_ != 0)
    201                     return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_);
     198                {
     199                    if (tokens.size() >= 2)
     200                        return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_);
     201                    else
     202                        return evaluation.shortcut_->parse(evaluation.additionalParameter_);
     203                }
    202204                break;
    203205            case CS_Function:
    204206                break;
    205207            case CS_Function_Params:
    206                 // not enough parameters but lets hope there are some additional parameters
    207                 if (evaluation.function_ != 0)
    208                     return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_);
    209                 break;
     208                // not enough parameters but lets hope there are some additional parameters and go on
    210209            case CS_Function_Finished:
    211210                // call the shortcut
    212211                if (evaluation.function_ != 0)
    213                     return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_);
     212                {
     213                    if (tokens.size() >= 3)
     214                        return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_);
     215                    else
     216                        return evaluation.function_->parse(evaluation.additionalParameter_);
     217                }
    214218                break;
    215219            case CS_ConfigValueClass:
     
    218222                break;
    219223            case CS_ConfigValueType:
    220                 // not enough parameters but lets hope there are some additional parameters
    221                 if (evaluation.configvalue_ != 0)
    222                     return evaluation.configvalue_->parseString(tokens.subSet(3).join() + " " + evaluation.additionalParameter_);
    223                 break;
     224                // not enough parameters but lets hope there are some additional parameters and go on
    224225            case CS_ConfigValueFinished:
    225226                // set the config value
    226227                if (evaluation.configvalue_ != 0)
    227                     return evaluation.configvalue_->parseString(tokens.subSet(3).join() + " " + evaluation.additionalParameter_);
     228                {
     229                    if ((tokens.size() >= 1) && (tokens[0] == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE))
     230                    {
     231                        if (tokens.size() >= 4)
     232                            return evaluation.configvalue_->set(tokens.subSet(3).join() + " " + evaluation.additionalParameter_);
     233                        else
     234                            return evaluation.configvalue_->set(evaluation.additionalParameter_);
     235                    }
     236                    else if ((tokens.size() >= 1) && (tokens[0] == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY))
     237                    {
     238                        if (tokens.size() >= 4)
     239                            return evaluation.configvalue_->tset(tokens.subSet(3).join() + " " + evaluation.additionalParameter_);
     240                        else
     241                            return evaluation.configvalue_->tset(evaluation.additionalParameter_);
     242                    }
     243                }
    228244                break;
    229245            case CS_KeybindKey:
    230246                break;
    231247            case CS_KeybindCommand:
    232                 // not enough parameters but lets hope there are some additional parameters
    233                 break;
     248                // not enough parameters but lets hope there are some additional parameters and go on
    234249            case CS_KeybindFinished:
    235250                // set the keybind
     
    980995
    981996            if (executor->defaultValueSet(i))
    982                 output += "]";
     997                output += "=" + executor->getDefaultValue(i).toString() + "]";
    983998            else
    984999                output += "}";
     
    9891004    std::string CommandExecutor::dump(const ConfigValueContainer* container)
    9901005    {
    991         return container->getTypename();
     1006        AddLanguageEntry("CommandExecutor::oldvalue", "old value");
     1007        return "{" + container->getTypename() + "} (" + GetLocalisation("CommandExecutor::oldvalue") + ": " + container->toString() + ")";
    9921008    }
    9931009
Note: See TracChangeset for help on using the changeset viewer.