From 7b102f53f2b155abf80dbae4cff2f4d2213f0c44 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sun, 11 Aug 2024 13:42:37 +0200 Subject: [PATCH] fix(Core/Chat): Correct misstake in b81bcfb causing outputs to CLI not working properly (#19593) fix(Core/Chat): Correct misstake in b81bcfbfea079950d22d98c6745b2c3766d6ffd0 causing outputs to CLI not working properly * closes https://github.com/azerothcore/azerothcore-wotlk/issues/19592 --- src/server/game/Chat/Chat.cpp | 7 ++++++- src/server/game/Chat/Chat.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index d1e37b06d..b147b5f4b 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -430,7 +430,7 @@ Player* ChatHandler::getSelectedPlayerOrSelf() const return targetPlayer; } -bool ChatHandler::HasSession() +bool ChatHandler::HasSession() const { if (!m_session) return false; @@ -967,6 +967,11 @@ int CliHandler::GetSessionDbLocaleIndex() const return sObjectMgr->GetDBCLocaleIndex(); } +bool CliHandler::HasSession() const +{ + return true; +} + bool AddonChannelCommandHandler::ParseCommands(std::string_view str) { if (memcmp(str.data(), "AzerothCore\t", 12)) diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 2ef435a27..be908e935 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -198,7 +198,8 @@ public: // Returns either the selected player or self if there is no selected player Player* getSelectedPlayerOrSelf() const; - bool HasSession(); + // Has different implementation for console + virtual bool HasSession() const; // Do whatever you want to all the players with a valid session [including GameMasters], i.e.: param exec = [&](Player* p) { p->Whatever(); } // A "valid" session requires player->IsInWorld() to be true void DoForAllValidSessions(std::function exec); @@ -252,6 +253,9 @@ public: LocaleConstant GetSessionDbcLocale() const override; int GetSessionDbLocaleIndex() const override; + // CLI does not have a session, so we override it to always be true to output SendNotification and PSendSysMessage to console + bool HasSession() const override; + private: void* m_callbackArg; Print* m_print;