From 8e2a664fadecb0c08adc6f2f76fd100cddc5c7a8 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 1 May 2009 03:58:51 +0400 Subject: [PATCH] [7740] More correct flags in trainer list data for profession ranks. Note: this is not fix problem with gren show recently learned non-first rank of primary profession. Thanks to Seizerkiller for help in reseach. --- src/game/NPCHandler.cpp | 16 +++++++++------- src/game/Player.cpp | 2 +- src/game/Player.h | 3 ++- src/shared/revision_nr.h | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index ad63584b1..05b77b4b4 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -155,6 +155,7 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) // reputation discount float fDiscountMod = _player->GetReputationPriceDiscount(unit); + bool can_learn_primary_prof = GetPlayer()->GetFreePrimaryProffesionPoints() > 0; uint32 count = 0; for(TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr) @@ -164,24 +165,25 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell)) continue; - ++count; - bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->learnedSpell); - SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->learnedSpell); + TrainerSpellState state = _player->GetTrainerSpellState(tSpell); data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case) - data << uint8(_player->GetTrainerSpellState(tSpell)); + data << uint8(state==TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state); data << uint32(floor(tSpell->spellCost * fDiscountMod)); - data << uint32(primary_prof_first_rank ? 1 : 0); // primary prof. learn confirmation dialog + data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0); + // primary prof. learn confirmation dialog data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state data << uint8(tSpell->reqLevel); data << uint32(tSpell->reqSkill); data << uint32(tSpell->reqSkillValue); - data << uint32(chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0); - data << uint32(chain_node && chain_node->prev ? chain_node->req : 0); + data << uint32(!tSpell->IsCastable() && chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0); + data << uint32(!tSpell->IsCastable() && chain_node && chain_node->prev ? chain_node->req : 0); data << uint32(0); + + ++count; } data << strTitle; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index f5f72e1c6..fa8d925c1 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3705,7 +3705,7 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell // check primary prof. limit if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell->Id) && GetFreePrimaryProffesionPoints() == 0) - return TRAINER_SPELL_RED; + return TRAINER_SPELL_GREEN_DISABLED; return TRAINER_SPELL_GREEN; } diff --git a/src/game/Player.h b/src/game/Player.h index 4eabfb5d5..04cd287fa 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -121,7 +121,8 @@ enum TrainerSpellState { TRAINER_SPELL_GREEN = 0, TRAINER_SPELL_RED = 1, - TRAINER_SPELL_GRAY = 2 + TRAINER_SPELL_GRAY = 2, + TRAINER_SPELL_GREEN_DISABLED = 10 // custom value, not send to client: formally green but learn not allowed }; enum ActionButtonUpdateState diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e8eddda82..48b563913 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7739" + #define REVISION_NR "7740" #endif // __REVISION_NR_H__