From 34f34ef13d154e45b7385e3af500a6e8c890dcb9 Mon Sep 17 00:00:00 2001 From: kadeshar Date: Sat, 23 May 2026 04:24:15 +0200 Subject: [PATCH] Fix for ru translation (#2400) ## Pull Request Description Fixed bug with finding russian texts (loc8) Related with: https://github.com/mod-playerbots/mod-playerbots/issues/1884 ## How to Test the Changes 1. Use ru client 2. Invite bot 3. Use command `focus heal ?" ## Impact Assessment - Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots? - - [x] No, not at all - - [ ] Minimal impact (**explain below**) - - [ ] Moderate impact (**explain below**) - Does this change modify default bot behavior? - - [x] No - - [ ] Yes (**explain why**) - Does this change add new decision branches or increase maintenance complexity? - - [x] No - - [ ] Yes (**explain below**) ## AI Assistance Was AI assistance used while working on this change? - - [ ] No - - [x] Yes (**explain below**) Find and fix wrong places checking texts ## Final Checklist - - [x] Stability is not compromised. - - [x] Performance impact is understood, tested, and acceptable. - - [x] Added logic complexity is justified and explained. - - [x] Any new bot dialogue lines are translated. - - [x] Documentation updated if needed (Conf comments, WiKi commands). ## Notes for Reviewers --- src/Bot/PlayerbotMgr.cpp | 2 +- src/Mgr/Text/PlayerbotTextMgr.cpp | 10 +++++----- src/Mgr/Text/PlayerbotTextMgr.h | 4 ++-- src/Util/BroadcastHelper.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Bot/PlayerbotMgr.cpp b/src/Bot/PlayerbotMgr.cpp index 7a8c311ce..ab239d376 100644 --- a/src/Bot/PlayerbotMgr.cpp +++ b/src/Bot/PlayerbotMgr.cpp @@ -1639,7 +1639,7 @@ void PlayerbotMgr::OnPlayerLogin(Player* player) // For bot texts (DB-driven), prefer the database locale with a safe fallback. LocaleConstant usedLocale = databaseLocale; - if (usedLocale >= MAX_LOCALES) + if (usedLocale >= TOTAL_LOCALES) usedLocale = LOCALE_enUS; // fallback // set locale priority for bot texts diff --git a/src/Mgr/Text/PlayerbotTextMgr.cpp b/src/Mgr/Text/PlayerbotTextMgr.cpp index 0998a5392..e8be8f533 100644 --- a/src/Mgr/Text/PlayerbotTextMgr.cpp +++ b/src/Mgr/Text/PlayerbotTextMgr.cpp @@ -38,7 +38,7 @@ void PlayerbotTextMgr::LoadBotTexts() text[0] = fields[1].Get(); uint8 sayType = fields[2].Get(); uint8 replyType = fields[3].Get(); - for (uint8 i = 1; i < MAX_LOCALES; ++i) + for (uint8 i = 1; i < TOTAL_LOCALES; ++i) { text[i] = fields[i + 3].Get(); } @@ -192,9 +192,9 @@ bool PlayerbotTextMgr::GetBotText(std::string name, std::string& text, std::map< void PlayerbotTextMgr::AddLocalePriority(uint32 locale) { - if (locale >= MAX_LOCALES) + if (locale >= TOTAL_LOCALES) { - LOG_WARN("playerbots", "Ignoring locale {} for bot texts because it exceeds MAX_LOCALES ({})", locale, MAX_LOCALES - 1); + LOG_WARN("playerbots", "Ignoring locale {} for bot texts because it exceeds TOTAL_LOCALES ({})", locale, TOTAL_LOCALES - 1); return; } @@ -212,7 +212,7 @@ uint32 PlayerbotTextMgr::GetLocalePriority() } uint32 topLocale = 0; - for (uint8 i = 0; i < MAX_LOCALES; ++i) + for (uint8 i = 0; i < TOTAL_LOCALES; ++i) { if (botTextLocalePriority[i] > botTextLocalePriority[topLocale]) topLocale = i; @@ -223,7 +223,7 @@ uint32 PlayerbotTextMgr::GetLocalePriority() void PlayerbotTextMgr::ResetLocalePriority() { - for (uint8 i = 0; i < MAX_LOCALES; ++i) + for (uint8 i = 0; i < TOTAL_LOCALES; ++i) { botTextLocalePriority[i] = 0; } diff --git a/src/Mgr/Text/PlayerbotTextMgr.h b/src/Mgr/Text/PlayerbotTextMgr.h index 398d7640a..1613630f9 100644 --- a/src/Mgr/Text/PlayerbotTextMgr.h +++ b/src/Mgr/Text/PlayerbotTextMgr.h @@ -87,7 +87,7 @@ public: private: PlayerbotTextMgr() { - for (uint8 i = 0; i < MAX_LOCALES; ++i) + for (uint8 i = 0; i < TOTAL_LOCALES; ++i) { botTextLocalePriority[i] = 0; } @@ -102,7 +102,7 @@ private: std::map> botTexts; std::map botTextChance; - uint32 botTextLocalePriority[MAX_LOCALES]; + uint32 botTextLocalePriority[TOTAL_LOCALES]; }; #endif diff --git a/src/Util/BroadcastHelper.cpp b/src/Util/BroadcastHelper.cpp index 246344bda..0804ab9fa 100644 --- a/src/Util/BroadcastHelper.cpp +++ b/src/Util/BroadcastHelper.cpp @@ -11,7 +11,7 @@ uint8 BroadcastHelper::GetLocale() { uint8 locale = sWorld->GetDefaultDbcLocale(); // -- In case we're using auto detect on config file^M - if (locale >= MAX_LOCALES) + if (locale >= TOTAL_LOCALES) locale = LocaleConstant::LOCALE_enUS; return locale; }