| 49 | } |
| 50 | |
| 51 | Command::Result ConsoleInterface::tryExecuteClientCommand(String_t commandString, |
| 52 | ModeType modeType, |
| 53 | AbstractModeManager& modeManager) |
| 54 | { |
| 55 | mCommandHistoryBuffer.emplace_back(commandString); |
| 56 | print(">> " + commandString); |
| 57 | Command::ArgumentList_t tokenList; |
| 58 | boost::algorithm::split(tokenList, |
| 59 | commandString, boost::algorithm::is_space(), |
| 60 | boost::algorithm::token_compress_on); |
| 61 | |
| 62 | const String_t& commandName = tokenList.front(); |
| 63 | auto it = mCommandMap.find(commandName); |
| 64 | if(it != mCommandMap.end()) |
| 65 | { |
| 66 | // Check if there is something to do on client side |
| 67 | try |
| 68 | { |
| 69 | Command::Result result = Command::Result::SUCCESS; |
| 70 | result = it->second->executeClient(tokenList, modeType, *this, modeManager); |
| 71 | |
| 72 | return result; |
| 73 | } |
| 74 | catch(const std::invalid_argument& e) |
| 75 | { |
| 76 | print(String_t("Invalid argument: ") + e.what()); |
| 77 | return Command::Result::INVALID_ARGUMENT; |
| 78 | } |
| 79 | catch(const std::out_of_range& e) |
| 80 | { |
| 81 | print(String_t("Argument out of range") + e.what()); |
| 82 | return Command::Result::INVALID_ARGUMENT; |
| 83 | } |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | print("Unknown command: \"" + commandString + "\""); |
| 88 | return Command::Result::NOT_FOUND; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | Command::Result ConsoleInterface::tryExecuteServerCommand(const std::vector<std::string>& args, GameMap& gameMap) |
| 93 | { |