diff options
Diffstat (limited to 'src/inputManager.cpp')
| -rw-r--r-- | src/inputManager.cpp | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/inputManager.cpp b/src/inputManager.cpp index 57b7b06..8de26bd 100644 --- a/src/inputManager.cpp +++ b/src/inputManager.cpp @@ -16,30 +16,6 @@ void CInputManager::run() { inputLoop(); } -static void handleCommand(std::string &input) { - input = input.substr(1); - - std::string command; - std::string args; - - size_t spacePos = input.find(' '); - if (spacePos == std::string::npos) { - command = input; - args = ""; - } else { - command = input.substr(0, spacePos); - // skip extra spaces - size_t startPos = input.find_first_not_of(' ', spacePos); - if (startPos != std::string::npos) - args = input.substr(startPos); - } - - args.empty() ? log(TRACE, "Spawning Command: {}", command) : log(TRACE, "Spawning Command: {}, Args: {}", command, args); - const auto exe = g_pCommandHandler->newCommand(command, args); - exe.good ? exe.result.empty() ? log(LOG, "Command {} succeeded", command) : log(LOG, "Command {} succeeded: {}", command, exe.result) : exe.result.empty() ? log(ERR, "Command {} failed", command) - : log(ERR, "Command {} failed: {}", command, exe.result); -}; - void CInputManager::inputLoop() { while (true) { std::string input; @@ -49,6 +25,6 @@ void CInputManager::inputLoop() { if (input.empty()) continue; - g_pCommandHandler->isCommand(input) ? handleCommand(input) : g_pChatManager->broadcastMessage({.msg = input, .username = "Server"}); + g_pCommandHandler->isCommand(input) ? g_pCommandHandler->handleCommand(input) : g_pChatManager->newMessage({.msg = input, .username = "Server"}); } } |
