From edc6ed69584c77aeec53e5098c1504d84b7a6183 Mon Sep 17 00:00:00 2001 From: dinomking33 <38479763+TAHuntling@users.noreply.github.com> Date: Thu, 16 May 2024 00:06:44 -0500 Subject: [PATCH] Update SlashCommandHandler.cpp --- dGame/dUtilities/SlashCommandHandler.cpp | 64 ++++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 3760f4e9c..bf6237eac 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -41,38 +41,6 @@ void SlashCommandHandler::RegisterCommand(Command command) { CommandInfos[command.aliases[0]] = command; } -void GMZeroCommands::Help(Entity* entity, const SystemAddress& sysAddr, const std::string args) { - std::ostringstream feedback; - if (args.empty()) { - feedback << "----- Commands -----"; - for (const auto& [alias, command] : CommandInfos) { - // TODO: Limit displaying commands based on GM level they require - if (command.requiredLevel > entity->GetGMLevel()) continue; - LOG("Help command: %s", alias.c_str()); - feedback << "\n/" << alias << ": " << command.help; - } - } else { - auto it = CommandInfos.find(args); - if (it != CommandInfos.end() && entity->GetGMLevel() >= it->second.requiredLevel) { - feedback << "----- " << args << " -----\n"; - feedback << it->second.info; - if (it->second.aliases.size() > 1) { - feedback << "\nAliases: "; - for (size_t i = 0; i < it->second.aliases.size(); i++) { - if (i > 0) feedback << ", "; - feedback << it->second.aliases[i]; - } - } - } else { - if (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN) { - feedback << "Command " << std::quoted(args) << " does not exist!"; - } - } - } - const auto feedbackStr = feedback.str(); - if (!feedbackStr.empty()) GameMessages::SendSlashCommandFeedbackText(entity, GeneralUtils::ASCIIToUTF16(feedbackStr)); -} - void SlashCommandHandler::HandleChatCommand(const std::u16string& chat, Entity* entity, const SystemAddress& sysAddr) { auto input = GeneralUtils::UTF16ToWTF8(chat); if (input.empty() || input.front() != '/') return; @@ -105,6 +73,38 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& chat, Entity* } } +void GMZeroCommands::Help(Entity* entity, const SystemAddress& sysAddr, const std::string args) { + std::ostringstream feedback; + if (args.empty()) { + feedback << "----- Commands -----"; + for (const auto& [alias, command] : CommandInfos) { + // TODO: Limit displaying commands based on GM level they require + if (command.requiredLevel > entity->GetGMLevel()) continue; + LOG("Help command: %s", alias.c_str()); + feedback << "\n/" << alias << ": " << command.help; + } + } else { + auto it = CommandInfos.find(args); + if (it != CommandInfos.end() && entity->GetGMLevel() >= it->second.requiredLevel) { + feedback << "----- " << args << " -----\n"; + feedback << it->second.info; + if (it->second.aliases.size() > 1) { + feedback << "\nAliases: "; + for (size_t i = 0; i < it->second.aliases.size(); i++) { + if (i > 0) feedback << ", "; + feedback << it->second.aliases[i]; + } + } + } else { + if (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN) { + feedback << "Command " << std::quoted(args) << " does not exist!"; + } + } + } + const auto feedbackStr = feedback.str(); + if (!feedbackStr.empty()) GameMessages::SendSlashCommandFeedbackText(entity, GeneralUtils::ASCIIToUTF16(feedbackStr)); +} + void SlashCommandHandler::SendAnnouncement(const std::string& title, const std::string& message) { AMFArrayValue args;