Commit Graph

11 Commits

Author SHA1 Message Date
Alex Dcnh
0c1700c117 CORE - Improved language detection for bots (#1784)
I've had this problem for a long time, my bots only speak English even
though I'm playing on a French client.
I suppose this must be the case for some other people who do not have a
large number of players with the same local client.
If we use French DBCs, the bots bug because they only recognize US DBCs.
From what I understand, the language is chosen as follows:
On load, the module reads the entire `ai_playerbot_texts` table and
stores each text variant in a dictionary indexed by the locale ID: the
`text` column remains the default value (English), and the `text_loc1`
to `text_loc8` columns fill slots 1 through 8.

Whenever a real player connects, the module increments a counter for
that player's DBC locale using
`AddLocalePriority(player->GetSession()->GetSessionDbcLocale())`.

When a bot needs a text, `GetLocalePriority()` returns the most
frequently used locale index among currently connected players. The
corresponding string is then retrieved. if the box is empty, we fall
back to the English version (text[0]).

### This PR improve language detection.
**Summary**

- log both the client DBC locale and the account database locale when a
player logs in
- fall back to the account locale when the client reports enUS but the
account is configured for another locale
- keep the existing vote-based selection so bots always speak the
majority language among connected players

**Therefore, the original behavior is maintained. Bots still choose the
most represented language among connected players (the counter is simply
more efficient by prioritizing the account's locale when it differs from
the client's English). For example, if more English-speaking players are
connected, the language will revert to English, as the bots always share
the majority locale.**
2025-11-21 15:56:03 +01:00
bash
0cc15411c1 license update (#1674) 2025-09-30 15:19:44 +02:00
kadeshar
c20fb34470 - Added method to get translation bot text or default (#1678) 2025-09-28 13:39:59 +02:00
Yunfan Li
62e0235e73 Scripts and sessions update to align with acore (#987) 2025-02-22 12:08:53 +08:00
Yunfan Li
53611c9040 Run clang-format 2024-08-04 10:23:36 +08:00
Atidot3
50bd63575d Progress on channels and say yell etc 2024-07-25 23:18:04 +02:00
Atidot3
916a0002e8 Fix crash 2024-07-25 17:56:53 +02:00
antony
21a6628161 French + locale dbc use fix 2024-07-25 13:56:42 +02:00
郑佩茹
0b599de6bd Fix crash when bot unable to find valid reply. 2022-09-27 18:39:30 -06:00
郑佩茹
b2821d7f3a Rewrite bot texts 2022-09-26 17:20:59 -06:00
UltraNix
b952636f0d Big update. 2022-03-12 22:27:09 +01:00