From 6f822f54aa61ae930a817dd21f1ed906c9e7e058 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 19 Nov 2017 10:12:35 +0200 Subject: [PATCH] [Server] Make chat commands case insensitive --- apps/openmw-mp/Script/CommandController.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/openmw-mp/Script/CommandController.cpp b/apps/openmw-mp/Script/CommandController.cpp index 372eb4662..00a4c0d7c 100644 --- a/apps/openmw-mp/Script/CommandController.cpp +++ b/apps/openmw-mp/Script/CommandController.cpp @@ -3,8 +3,10 @@ // #include "CommandController.hpp" -#include #include +#include +#include + #include "Player.hpp" #include "LuaState.hpp" @@ -15,15 +17,15 @@ void CommandController::Init(LuaState &lua) sol::table cmdCtrlTable = lua.getState()->create_named_table("CommandController"); cmdCtrlTable["registerCommand"] = [&lua](const std::string &command, sol::function func, const std::string &helpMessage) { - return lua.getCmdCtrl().registerCommand(command, func, helpMessage); + return lua.getCmdCtrl().registerCommand(Misc::StringUtils::lowerCase(command), func, helpMessage); }; cmdCtrlTable["unregisterCommand"] = [&lua](const std::string &command) { - lua.getCmdCtrl().unregisterCommand(command); + lua.getCmdCtrl().unregisterCommand(Misc::StringUtils::lowerCase(command)); }; cmdCtrlTable["hasCommand"] = [&lua](const std::string &command) { - return lua.getCmdCtrl().hasCommand(command); + return lua.getCmdCtrl().hasCommand(Misc::StringUtils::lowerCase(command)); }; cmdCtrlTable["getHelpStrings"] = [&lua]() { @@ -66,7 +68,7 @@ std::pair CommandController::exec(st auto tokens = cmdParser(message); - auto cmd = commands.find(&tokens[0][1]); + auto cmd = commands.find(Misc::StringUtils::lowerCase(&tokens[0][1])); if (cmd != commands.end()) { tokens.pop_front();