mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
game: fix talent state not resetting across login sessions
Replace static-local firstSpecReceived with talentsInitialized_ member variable, reset in handleLoginVerifyWorld alongside other per-session state. Also clear learnedTalents_, unspentTalentPoints_, and activeTalentSpec_ at world entry so reconnects and character switches start from a clean talent state instead of carrying over stale data.
This commit is contained in:
parent
2a9d26e1ea
commit
03c4d59592
2 changed files with 13 additions and 4 deletions
|
|
@ -1841,6 +1841,7 @@ private:
|
|||
std::unordered_map<uint32_t, TalentEntry> talentCache_; // talentId -> entry
|
||||
std::unordered_map<uint32_t, TalentTabEntry> talentTabCache_; // tabId -> entry
|
||||
bool talentDbcLoaded_ = false;
|
||||
bool talentsInitialized_ = false; // Reset on world entry; guards first-spec selection
|
||||
|
||||
// ---- Area trigger detection ----
|
||||
struct AreaTriggerEntry {
|
||||
|
|
|
|||
|
|
@ -6039,6 +6039,15 @@ void GameHandler::handleLoginVerifyWorld(network::Packet& packet) {
|
|||
encounterUnitGuids_.fill(0);
|
||||
raidTargetGuids_.fill(0);
|
||||
|
||||
// Reset talent initialization so the first SMSG_TALENTS_INFO after login
|
||||
// correctly sets the active spec (static locals don't reset across logins)
|
||||
talentsInitialized_ = false;
|
||||
learnedTalents_[0].clear();
|
||||
learnedTalents_[1].clear();
|
||||
unspentTalentPoints_[0] = 0;
|
||||
unspentTalentPoints_[1] = 0;
|
||||
activeTalentSpec_ = 0;
|
||||
|
||||
// Suppress area triggers on initial login — prevents exit portals from
|
||||
// immediately firing when spawning inside a dungeon/instance.
|
||||
activeAreaTriggers_.clear();
|
||||
|
|
@ -13220,10 +13229,9 @@ void GameHandler::handleTalentsInfo(network::Packet& packet) {
|
|||
" unspent=", (int)unspentTalentPoints_[data.talentSpec],
|
||||
" learned=", learnedTalents_[data.talentSpec].size());
|
||||
|
||||
// If this is the first spec received, set it as active
|
||||
static bool firstSpecReceived = false;
|
||||
if (!firstSpecReceived) {
|
||||
firstSpecReceived = true;
|
||||
// If this is the first spec received after login, set it as the active spec
|
||||
if (!talentsInitialized_) {
|
||||
talentsInitialized_ = true;
|
||||
activeTalentSpec_ = data.talentSpec;
|
||||
|
||||
// Show message to player about active spec
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue