Changeset 6 for trunk/src/game/NPCHandler.cpp
- Timestamp:
- 11/19/08 13:22:12 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/NPCHandler.cpp
r2 r6 130 130 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); 131 131 132 // Lazy loading at first access133 unit->LoadTrainerSpells();134 135 132 // trainer list loaded at check; 136 133 if(!unit->isCanTrainingOf(_player,true)) … … 145 142 } 146 143 147 Creature::SpellsList const& trainer_spells = unit->GetTrainerSpells(); 148 149 WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+trainer_spells.size()*38 + strTitle.size()+1); 144 TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); 145 if(!trainer_spells) 146 { 147 sLog.outDebug( "WORLD: SendTrainerList - Training spells not found for creature (GUID: %u Entry: %u)", guid, unit->GetEntry()); 148 return; 149 } 150 151 WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+trainer_spells->spellList.size()*38 + strTitle.size()+1); 150 152 data << guid; 151 data << uint32( unit->GetTrainerType());153 data << uint32(trainer_spells->trainerType); 152 154 153 155 size_t count_pos = data.wpos(); 154 data << uint32(trainer_spells .size());156 data << uint32(trainer_spells->spellList.size()); 155 157 156 158 // reputation discount … … 158 160 159 161 uint32 count = 0; 160 for(Creature::SpellsList::const_iterator itr = trainer_spells.begin(); itr != trainer_spells.end(); ++itr) 161 { 162 if(!_player->IsSpellFitByClassAndRace(itr->spell->Id)) 162 for(TrainerSpellList::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr) 163 { 164 TrainerSpell const* tSpell = *itr; 165 166 if(!_player->IsSpellFitByClassAndRace(tSpell->spell)) 163 167 continue; 164 168 165 169 ++count; 166 170 167 bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell( itr->spell->Id);168 169 SpellChainNode const* chain_node = spellmgr.GetSpellChainNode( itr->spell->Id);170 171 data << uint32( itr->spell->Id);172 data << uint8(_player->GetTrainerSpellState( &*itr));173 data << uint32(floor( itr->spellcost * fDiscountMod));171 bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->spell); 172 173 SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->spell); 174 175 data << uint32(tSpell->spell); 176 data << uint8(_player->GetTrainerSpellState(tSpell)); 177 data << uint32(floor(tSpell->spellcost * fDiscountMod)); 174 178 175 179 data << uint32(primary_prof_first_rank ? 1 : 0); // primary prof. learn confirmation dialog 176 180 data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state 177 data << uint8( itr->reqlevel ? itr->reqlevel : itr->spell->spellLevel);178 data << uint32( itr->reqskill);179 data << uint32( itr->reqskillvalue);181 data << uint8(tSpell->reqlevel); 182 data << uint32(tSpell->reqskill); 183 data << uint32(tSpell->reqskillvalue); 180 184 data << uint32(chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0); 181 185 data << uint32(chain_node && chain_node->prev ? chain_node->req : 0); … … 210 214 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); 211 215 212 // Lazy loading at first access213 unit->LoadTrainerSpells();214 215 216 if(!unit->isCanTrainingOf(_player,true)) 216 217 return; 217 218 218 TrainerSpell const* trainer_spell = NULL;219 220 219 // check present spell in trainer spell list 221 Creature::SpellsList const& trainer_spells = unit->GetTrainerSpells(); 222 for(Creature::SpellsList::const_iterator itr = trainer_spells.begin(); itr != trainer_spells.end(); ++itr) 223 { 224 if(itr->spell->Id == spellId) 225 { 226 trainer_spell = &*itr; 227 break; 228 } 229 } 220 TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); 221 if(!trainer_spells) 222 return; 230 223 231 224 // not found, cheat? 225 TrainerSpell const* trainer_spell = trainer_spells->Find(spellId); 232 226 if(!trainer_spell) 233 227 return; … … 255 249 256 250 // learn explicitly to prevent lost money at lags, learning spell will be only show spell animation 257 _player->learnSpell(trainer_spell->spell ->Id);251 _player->learnSpell(trainer_spell->spell); 258 252 259 253 data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12);