From 290bf50faf1db6c184459e95a0b0de2ac1a5bf80 Mon Sep 17 00:00:00 2001 From: "Veit F." <52582670+HoodOG1@users.noreply.github.com> Date: Thu, 12 Jun 2025 23:17:43 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E2=9A=A1=20added=20missing=20checks=20f?= =?UTF-8?q?or=20PetIsDeadValue=20(#1376)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: ⚡ added missing guildTaskEnabled checks for GuildTaskMgr Even if guildTaskEnabled was set to 0 in the configuration file, a few queries like PLAYERBOTS_SEL_GUILD_TASKS_BY_VALUE, PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER were executed, which lead to a massive amount of unnecessary database load * fix: :zap: added missing checks for PetIsDeadValue Hunter under level 10, which are not able to summon their pets defined in the database spammed SELECT id FROM character_pet WHERE owner = {}, since the result of the query was true. Bots under level 10 already have pets in their stables. Also the same thing applied to Bots on mounts, because, while mounted, pets get despawned. This should drastically improve server performance. * fix: :zap: refactored query, pet should only check death state of his current pet The old query also fetched all pets out of his stable, which is not needed, since we are looking for slot 0 (active pet) * style: :art: and to AND typo * fix: :bug: Reverted 5a6182f977d6785a98d300f7b5ec7855a35f2e37 A few hunters with pets in stable, where slot = 100 would not summon their pets --- src/GuildTaskMgr.cpp | 15 +++++++++++++++ src/strategy/values/StatsValues.cpp | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/GuildTaskMgr.cpp b/src/GuildTaskMgr.cpp index 0ad8b770..e09d1341 100644 --- a/src/GuildTaskMgr.cpp +++ b/src/GuildTaskMgr.cpp @@ -525,6 +525,11 @@ uint32 GuildTaskMgr::GetMaxItemTaskCount(uint32 itemId) bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId) { + if (!sPlayerbotAIConfig->guildTaskEnabled) + { + return 0; + } + uint32 value = 0; PlayerbotsDatabasePreparedStatement* stmt = @@ -548,6 +553,11 @@ bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId) std::map GuildTaskMgr::GetTaskValues(uint32 owner, std::string const type, [[maybe_unused]] uint32* validIn /* = nullptr */) { + if (!sPlayerbotAIConfig->guildTaskEnabled) + { + return std::map(); + } + std::map results; PlayerbotsDatabasePreparedStatement* stmt = @@ -576,6 +586,11 @@ std::map GuildTaskMgr::GetTaskValues(uint32 owner, std::string c uint32 GuildTaskMgr::GetTaskValue(uint32 owner, uint32 guildId, std::string const type, [[maybe_unused]] uint32* validIn /* = nullptr */) { + if (!sPlayerbotAIConfig->guildTaskEnabled) + { + return 0; + } + uint32 value = 0; PlayerbotsDatabasePreparedStatement* stmt = diff --git a/src/strategy/values/StatsValues.cpp b/src/strategy/values/StatsValues.cpp index ef80e79e..2c87ec72 100644 --- a/src/strategy/values/StatsValues.cpp +++ b/src/strategy/values/StatsValues.cpp @@ -40,6 +40,11 @@ bool IsDeadValue::Calculate() bool PetIsDeadValue::Calculate() { + if ((bot->GetLevel() < 10 && bot->getClass() == CLASS_HUNTER) || bot->IsMounted()) + { + return false; + } + if (!bot->GetPet()) { uint32 ownerid = bot->GetGUID().GetCounter();