| 90 | } |
| 91 | |
| 92 | Command::Result ConsoleInterface::tryExecuteServerCommand(const std::vector<std::string>& args, GameMap& gameMap) |
| 93 | { |
| 94 | if(args.empty()) |
| 95 | { |
| 96 | print("Invalid empty command"); |
| 97 | return Command::Result::INVALID_ARGUMENT; |
| 98 | } |
| 99 | const std::string& commandName = args[0]; |
| 100 | auto it = mCommandMap.find(commandName); |
| 101 | if(it != mCommandMap.end()) |
| 102 | { |
| 103 | // Check if there is something to do on client side |
| 104 | try |
| 105 | { |
| 106 | Command::Result result = Command::Result::SUCCESS; |
| 107 | result = it->second->executeServer(args, *this, gameMap); |
| 108 | |
| 109 | return result; |
| 110 | } |
| 111 | catch(const std::invalid_argument& e) |
| 112 | { |
| 113 | print(std::string("Invalid argument: ") + e.what()); |
| 114 | return Command::Result::INVALID_ARGUMENT; |
| 115 | } |
| 116 | catch(const std::out_of_range& e) |
| 117 | { |
| 118 | print(std::string("Argument out of range") + e.what()); |
| 119 | return Command::Result::INVALID_ARGUMENT; |
| 120 | } |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | print("Unknown command: \"" + commandName + "\""); |
| 125 | return Command::Result::NOT_FOUND; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | bool ConsoleInterface::tryCompleteCommand(const String_t& prefix, String_t& completedCmd) |
| 130 | { |
no test coverage detected