From 4f43600e7ad3700f01a5f0e0ad7f01273f6b864e Mon Sep 17 00:00:00 2001 From: SaW Date: Thu, 6 Mar 2025 15:03:23 +0100 Subject: [PATCH] Silence error if preferred mounts SQL table playerbots_preferred_mounts does not exist (#1062) * Fix error spam if DB does not exist --- src/strategy/actions/CheckMountStateAction.cpp | 13 ++++++++----- src/strategy/actions/CheckMountStateAction.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 16a90b0d..c054d619 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -14,7 +14,7 @@ // Define the static map / init bool for caching bot preferred mount data globally std::unordered_map CheckMountStateAction::mountCache; -bool CheckMountStateAction::preferredMountTableExists = false; +bool CheckMountStateAction::preferredMountTableChecked = false; MountData CollectMountData(const Player* bot) { @@ -277,7 +277,7 @@ bool CheckMountStateAction::TryPreferredMount(Player* master) const uint32 botGUID = bot->GetGUID().GetRawValue(); // Build cache (only once) - if (!preferredMountTableExists) + if (!preferredMountTableChecked) { // Verify preferred mounts table existance in the database QueryResult checkTable = PlayerbotsDatabase.Query( @@ -285,7 +285,7 @@ bool CheckMountStateAction::TryPreferredMount(Player* master) const if (checkTable && checkTable->Fetch()[0].Get() == 1) { - preferredMountTableExists = true; + preferredMountTableChecked = true; // Cache all mounts of both types globally, for all entries QueryResult result = PlayerbotsDatabase.Query("SELECT guid, spellid, type FROM playerbots_preferred_mounts"); @@ -312,9 +312,12 @@ bool CheckMountStateAction::TryPreferredMount(Player* master) const LOG_INFO("playerbots", "Preferred mounts initialized | Total records: {}", totalResults); } } - else // If the SQL table is missing, return false + else // If the SQL table is missing, log an error and return false { - LOG_ERROR("playerbots", "Preferred mounts SQL table playerbots_preferred_mounts does not exist!"); + preferredMountTableChecked = true; + + LOG_DEBUG("playerbots", "Preferred mounts SQL table playerbots_preferred_mounts does not exist!"); + return false; } } diff --git a/src/strategy/actions/CheckMountStateAction.h b/src/strategy/actions/CheckMountStateAction.h index 96883827..d93e9adb 100644 --- a/src/strategy/actions/CheckMountStateAction.h +++ b/src/strategy/actions/CheckMountStateAction.h @@ -47,7 +47,7 @@ private: ShapeshiftForm masterInShapeshiftForm; ShapeshiftForm botInShapeshiftForm; static std::unordered_map mountCache; - static bool preferredMountTableExists; + static bool preferredMountTableChecked; float CalculateDismountDistance() const; float CalculateMountDistance() const; void Dismount();