From d1eb276711f13e1237feadae0adb907fb9fb0a36 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:34:35 -0500 Subject: [PATCH] feat: add locate command functions (#115) --- CommonLibSF/include/RE/S/Script.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CommonLibSF/include/RE/S/Script.h b/CommonLibSF/include/RE/S/Script.h index 8d4b26fc..68591400 100644 --- a/CommonLibSF/include/RE/S/Script.h +++ b/CommonLibSF/include/RE/S/Script.h @@ -168,6 +168,28 @@ namespace RE return std::span{ *chunk }; } + inline static SCRIPT_FUNCTION* LocateConsoleCommand(const std::string_view a_longName) + { + for (auto& command : GetConsoleCommands()) { + if (std::strlen(command.functionName) == a_longName.size()) + if (_strnicmp(command.functionName, a_longName.data(), a_longName.size()) == 0) + return std::addressof(command); + } + + return nullptr; + } + + inline static SCRIPT_FUNCTION* LocateScriptCommand(const std::string_view a_longName) + { + for (auto& command : GetScriptCommands()) { + if (std::strlen(command.functionName) == a_longName.size()) + if (_strnicmp(command.functionName, a_longName.data(), a_longName.size()) == 0) + return std::addressof(command); + } + + return nullptr; + } + // members SCRIPT_HEADER header; // 00 char* text; // 14