[7248] Check battlemaster_entry data at loading. Code cleanups. Author: zhenya

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-09 20:09:03 -06:00
parent 91356d97d5
commit b8d4c24359
9 changed files with 55 additions and 48 deletions
+3 -3
View File
@@ -582,7 +582,7 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
++count; ++count;
} }
} }
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr) for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{ {
AuctionEntry *Aentry = itr->second; AuctionEntry *Aentry = itr->second;
if( Aentry && Aentry->bidder == pl->GetGUIDLow() ) if( Aentry && Aentry->bidder == pl->GetGUIDLow() )
@@ -629,7 +629,7 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
uint32 count = 0; uint32 count = 0;
uint32 totalcount = 0; uint32 totalcount = 0;
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr) for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{ {
AuctionEntry *Aentry = itr->second; AuctionEntry *Aentry = itr->second;
if( Aentry && Aentry->owner == _player->GetGUIDLow() ) if( Aentry && Aentry->owner == _player->GetGUIDLow() )
@@ -695,7 +695,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
wstrToLower(wsearchedname); wstrToLower(wsearchedname);
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr) for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{ {
AuctionEntry *Aentry = itr->second; AuctionEntry *Aentry = itr->second;
Item *item = objmgr.GetAItem(Aentry->item_guidlow); Item *item = objmgr.GetAItem(Aentry->item_guidlow);
+1
View File
@@ -146,6 +146,7 @@ enum BattleGroundTypeId
BATTLEGROUND_DS = 10, BATTLEGROUND_DS = 10,
BATTLEGROUND_RV = 11 BATTLEGROUND_RV = 11
}; };
#define MAX_BATTLEGROUND_TYPE_ID 12
// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time // handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time
enum BattleGroundQueueTypeId enum BattleGroundQueueTypeId
+6 -6
View File
@@ -369,14 +369,14 @@ typedef std::list<VendorItemCount> VendorItemCounts;
struct TrainerSpell struct TrainerSpell
{ {
uint32 spell; uint32 spell;
uint32 spellcost; uint32 spellCost;
uint32 reqskill; uint32 reqSkill;
uint32 reqskillvalue; uint32 reqSkillValue;
uint32 reqlevel; uint32 reqLevel;
uint32 learned_spell; uint32 learnedSpell;
// helpers // helpers
bool IsCastable() const { return learned_spell != spell; } bool IsCastable() const { return learnedSpell != spell; }
}; };
typedef std::vector<TrainerSpell*> TrainerSpellList; typedef std::vector<TrainerSpell*> TrainerSpellList;
+1 -1
View File
@@ -742,7 +742,7 @@ void WorldSession::SendListInventory( uint64 vendorguid )
float discountMod = _player->GetReputationPriceDiscount(pCreature); float discountMod = _player->GetReputationPriceDiscount(pCreature);
for(int i = 0; i < numitems; i++ ) for(int i = 0; i < numitems; ++i )
{ {
if(VendorItem const* crItem = vItems->GetItem(i)) if(VendorItem const* crItem = vItems->GetItem(i))
{ {
+8 -8
View File
@@ -166,25 +166,25 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle )
{ {
TrainerSpell const* tSpell = *itr; TrainerSpell const* tSpell = *itr;
if(!_player->IsSpellFitByClassAndRace(tSpell->learned_spell)) if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell))
continue; continue;
++count; ++count;
bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->learned_spell); bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->learnedSpell);
SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->learned_spell); SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->learnedSpell);
uint32 req_spell = spellmgr.GetSpellRequired(tSpell->spell); uint32 req_spell = spellmgr.GetSpellRequired(tSpell->spell);
data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case) data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case)
data << uint8(_player->GetTrainerSpellState(tSpell)); data << uint8(_player->GetTrainerSpellState(tSpell));
data << uint32(floor(tSpell->spellcost * fDiscountMod)); 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 ? 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 << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state
data << uint8(tSpell->reqlevel); data << uint8(tSpell->reqLevel);
data << uint32(tSpell->reqskill); data << uint32(tSpell->reqSkill);
data << uint32(tSpell->reqskillvalue); data << uint32(tSpell->reqSkillValue);
data << uint32(chain_node && chain_node->prev ? chain_node->prev : req_spell); data << uint32(chain_node && chain_node->prev ? chain_node->prev : req_spell);
data << uint32(chain_node && chain_node->prev ? req_spell : 0); data << uint32(chain_node && chain_node->prev ? req_spell : 0);
data << uint32(0); data << uint32(0);
@@ -235,7 +235,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
return; return;
// apply reputation discount // apply reputation discount
uint32 nSpellCost = uint32(floor(trainer_spell->spellcost * _player->GetReputationPriceDiscount(unit))); uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement // check money requirement
if(_player->GetMoney() < nSpellCost ) if(_player->GetMoney() < nSpellCost )
+14 -8
View File
@@ -46,6 +46,7 @@
#include "Util.h" #include "Util.h"
#include "WaypointManager.h" #include "WaypointManager.h"
#include "InstanceData.h" //for condition_instance_data #include "InstanceData.h" //for condition_instance_data
#include "BattleGround.h"
INSTANTIATE_SINGLETON_1(ObjectMgr); INSTANTIATE_SINGLETON_1(ObjectMgr);
@@ -6749,6 +6750,11 @@ void ObjectMgr::LoadBattleMastersEntry()
uint32 entry = fields[0].GetUInt32(); uint32 entry = fields[0].GetUInt32();
uint32 bgTypeId = fields[1].GetUInt32(); uint32 bgTypeId = fields[1].GetUInt32();
if (bgTypeId >= MAX_BATTLEGROUND_TYPE_ID)
{
sLog.outErrorDb("Table `battlemaster_entry` contain entry %u for not existed battleground type %u, ignored.",entry,bgTypeId);
continue;
}
mBattleMastersMap[entry] = bgTypeId; mBattleMastersMap[entry] = bgTypeId;
@@ -7501,16 +7507,16 @@ void ObjectMgr::LoadTrainerSpell()
TrainerSpell* pTrainerSpell = new TrainerSpell(); TrainerSpell* pTrainerSpell = new TrainerSpell();
pTrainerSpell->spell = spell; pTrainerSpell->spell = spell;
pTrainerSpell->spellcost = fields[2].GetUInt32(); pTrainerSpell->spellCost = fields[2].GetUInt32();
pTrainerSpell->reqskill = fields[3].GetUInt32(); pTrainerSpell->reqSkill = fields[3].GetUInt32();
pTrainerSpell->reqskillvalue = fields[4].GetUInt32(); pTrainerSpell->reqSkillValue = fields[4].GetUInt32();
pTrainerSpell->reqlevel = fields[5].GetUInt32(); pTrainerSpell->reqLevel = fields[5].GetUInt32();
if(!pTrainerSpell->reqlevel) if(!pTrainerSpell->reqLevel)
pTrainerSpell->reqlevel = spellinfo->spellLevel; pTrainerSpell->reqLevel = spellinfo->spellLevel;
// calculate learned spell for profession case when stored cast-spell // calculate learned spell for profession case when stored cast-spell
pTrainerSpell->learned_spell = spell; pTrainerSpell->learnedSpell = spell;
for(int i = 0; i <3; ++i) for(int i = 0; i <3; ++i)
{ {
if(spellinfo->Effect[i]!=SPELL_EFFECT_LEARN_SPELL) if(spellinfo->Effect[i]!=SPELL_EFFECT_LEARN_SPELL)
@@ -7518,7 +7524,7 @@ void ObjectMgr::LoadTrainerSpell()
if(SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i])) if(SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i]))
{ {
pTrainerSpell->learned_spell = spellinfo->EffectTriggerSpell[i]; pTrainerSpell->learnedSpell = spellinfo->EffectTriggerSpell[i];
break; break;
} }
} }
+7 -7
View File
@@ -3674,22 +3674,22 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell
if (!trainer_spell) if (!trainer_spell)
return TRAINER_SPELL_RED; return TRAINER_SPELL_RED;
if (!trainer_spell->learned_spell) if (!trainer_spell->learnedSpell)
return TRAINER_SPELL_RED; return TRAINER_SPELL_RED;
// known spell // known spell
if(HasSpell(trainer_spell->learned_spell)) if(HasSpell(trainer_spell->learnedSpell))
return TRAINER_SPELL_GRAY; return TRAINER_SPELL_GRAY;
// check race/class requirement // check race/class requirement
if(!IsSpellFitByClassAndRace(trainer_spell->learned_spell)) if(!IsSpellFitByClassAndRace(trainer_spell->learnedSpell))
return TRAINER_SPELL_RED; return TRAINER_SPELL_RED;
// check level requirement // check level requirement
if(getLevel() < trainer_spell->reqlevel) if(getLevel() < trainer_spell->reqLevel)
return TRAINER_SPELL_RED; return TRAINER_SPELL_RED;
if(SpellChainNode const* spell_chain = spellmgr.GetSpellChainNode(trainer_spell->learned_spell)) if(SpellChainNode const* spell_chain = spellmgr.GetSpellChainNode(trainer_spell->learnedSpell))
{ {
// check prev.rank requirement // check prev.rank requirement
if(spell_chain->prev && !HasSpell(spell_chain->prev)) if(spell_chain->prev && !HasSpell(spell_chain->prev))
@@ -3704,11 +3704,11 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell
} }
// check skill requirement // check skill requirement
if(trainer_spell->reqskill && GetBaseSkillValue(trainer_spell->reqskill) < trainer_spell->reqskillvalue) if(trainer_spell->reqSkill && GetBaseSkillValue(trainer_spell->reqSkill) < trainer_spell->reqSkillValue)
return TRAINER_SPELL_RED; return TRAINER_SPELL_RED;
// exist, already checked at loading // exist, already checked at loading
SpellEntry const* spell = sSpellStore.LookupEntry(trainer_spell->learned_spell); SpellEntry const* spell = sSpellStore.LookupEntry(trainer_spell->learnedSpell);
// secondary prof. or not prof. spell // secondary prof. or not prof. spell
uint32 skill = spell->EffectMiscValue[1]; uint32 skill = spell->EffectMiscValue[1];
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7246" #define REVISION_NR "7248"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__