Fix trainer prerequisite checking

Issue: Trainer buttons were all greyed out because alreadyKnown was incorrectly
calculated using (state == 0 || isKnown(spellId)), which marked spells with
state=0 as 'already known' even when they weren't in the knownSpells list.
This caused prerequisite checks to fail since they only check knownSpells.

Fix: Changed alreadyKnown to only check isKnown(spellId), removing the state==0
check. Now prerequisites work correctly.

Added extensive debug logging to track:
- Known spells count and spell IDs
- Individual prerequisite checks (chain1, chain2, chain3)
- Whether spells are in initial SMSG_INITIAL_SPELLS packet

Note: Some trainers may still show greyed buttons due to server-side data issues
where prerequisite spells are marked as unavailable (state=0) even though they
haven't been learned yet. This is correct client behavior.
This commit is contained in:
Kelsi 2026-02-09 22:13:31 -08:00
parent 5e0d62c2a4
commit 01ff6db748
2 changed files with 30 additions and 11 deletions

View file

@ -3985,6 +3985,11 @@ void GameHandler::handleInitialSpells(network::Packet& packet) {
knownSpells = data.spellIds;
// Debug: check if specific spells are in initial spells
bool has527 = std::find(knownSpells.begin(), knownSpells.end(), 527u) != knownSpells.end();
bool has988 = std::find(knownSpells.begin(), knownSpells.end(), 988u) != knownSpells.end();
LOG_INFO("Initial spells include: 527=", has527, " 988=", has988);
// Ensure Attack (6603) and Hearthstone (8690) are always present
if (std::find(knownSpells.begin(), knownSpells.end(), 6603u) == knownSpells.end()) {
knownSpells.insert(knownSpells.begin(), 6603u);