From 59303a232e7962c2cf5d34074e84420c444e20fa Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:29:00 -0800 Subject: [PATCH] Slash commands: Update compares (#1270) use case insensitive compare use character name for kill instead of account name Use correct Id for muting when a player is found --- dGame/Player.cpp | 6 +++--- dGame/UserManager.cpp | 2 +- dGame/dUtilities/SlashCommandHandler.cpp | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dGame/Player.cpp b/dGame/Player.cpp index 65c7aae5..f2917729 100644 --- a/dGame/Player.cpp +++ b/dGame/Player.cpp @@ -228,9 +228,9 @@ Player* Player::GetPlayer(const std::string& name) { for (auto* character : characters) { if (!character->IsPlayer()) continue; - - if (character->GetCharacter()->GetName() == name) { - return static_cast(character); + + if (GeneralUtils::CaseInsensitiveStringCompare(name, character->GetCharacter()->GetName())) { + return dynamic_cast(character); } } diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index aaa4893f..0b26822d 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -125,7 +125,7 @@ User* UserManager::GetUser(const SystemAddress& sysAddr) { User* UserManager::GetUser(const std::string& username) { for (auto p : m_Users) { if (p.second) { - if (p.second->GetUsername() == username) return p.second; + if (GeneralUtils::CaseInsensitiveStringCompare(p.second->GetUsername(), username)) return p.second; } } diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 47037071..db27ee7b 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -448,9 +448,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (chatCommand == "kill" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { ChatPackets::SendSystemMessage(sysAddr, u"Brutally murdering that player, if online on this server."); - auto* user = UserManager::Instance()->GetUser(args[0]); - if (user) { - auto* player = Game::entityManager->GetEntity(user->GetLoggedInChar()); + auto* player = Player::GetPlayer(args[0]); + if (player) { player->Smash(entity->GetObjectID()); ChatPackets::SendSystemMessage(sysAddr, u"It has been done, do you feel good about yourself now?"); return; @@ -1042,7 +1041,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } } else { accountId = player->GetParentUser()->GetAccountID(); - characterId = player->GetCharacter()->GetID(); + characterId = player->GetObjectID(); } auto* userUpdate = Database::CreatePreppedStmt("UPDATE accounts SET mute_expire = ? WHERE id = ?;");