aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp229
1 files changed, 114 insertions, 115 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index d1bbaebd0d6..30c79b11c95 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -812,7 +812,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
}
// if this is ammo then use it
- uint8 msg = CanUseAmmo( pItem->GetEntry() );
+ msg = CanUseAmmo( pItem->GetEntry() );
if( msg == EQUIP_ERR_OK )
SetAmmo( pItem->GetEntry() );
}
@@ -916,8 +916,8 @@ void Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
DEBUG_LOG("We are fall to death, loosing 10 percents durability");
DurabilityLossAll(0.10f,false);
// durability lost message
- WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0);
- GetSession()->SendPacket(&data);
+ WorldPacket data2(SMSG_DURABILITY_DAMAGE_DEATH, 0);
+ GetSession()->SendPacket(&data2);
}
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, 1, type);
@@ -2870,22 +2870,22 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
// replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible
if(newspell->active && !newspell->disabled && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0)
{
- for( PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr )
+ for( PlayerSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2 )
{
- if(itr->second->state == PLAYERSPELL_REMOVED) continue;
- SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr->first);
+ if(itr2->second->state == PLAYERSPELL_REMOVED) continue;
+ SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr2->first);
if(!i_spellInfo) continue;
- if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr->first) )
+ if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) )
{
- if(itr->second->active)
+ if(itr2->second->active)
{
- if(spellmgr.IsHighRankOfSpell(spell_id,itr->first))
+ if(spellmgr.IsHighRankOfSpell(spell_id,itr2->first))
{
if(IsInWorld()) // not send spell (re-/over-)learn packets at loading
{
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
- data << uint16(itr->first);
+ data << uint16(itr2->first);
data << uint16(spell_id);
GetSession()->SendPacket( &data );
}
@@ -2896,13 +2896,13 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
itr->second->state = PLAYERSPELL_CHANGED;
superceded_old = true; // new spell replace old in action bars and spell book.
}
- else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id))
+ else if(spellmgr.IsHighRankOfSpell(itr2->first,spell_id))
{
if(IsInWorld()) // not send spell (re-/over-)learn packets at loading
{
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
data << uint16(spell_id);
- data << uint16(itr->first);
+ data << uint16(itr2->first);
GetSession()->SendPacket( &data );
}
@@ -3015,14 +3015,14 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id);
SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id);
- for(SpellLearnSpellMap::const_iterator itr = spell_begin; itr != spell_end; ++itr)
+ for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2)
{
- if(!itr->second.autoLearned)
+ if(!itr2->second.autoLearned)
{
- if(!IsInWorld() || !itr->second.active) // at spells loading, no output, but allow save
- addSpell(itr->second.spell,itr->second.active,true,true,false);
+ if(!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save
+ addSpell(itr2->second.spell,itr2->second.active,true,true,false);
else // at normal learning
- learnSpell(itr->second.spell,true);
+ learnSpell(itr2->second.spell,true);
}
}
@@ -5304,15 +5304,15 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
// temporary bonuses
AuraEffectList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL);
- for(AuraEffectList::const_iterator i = mModSkill.begin(); i != mModSkill.end(); ++i)
- if ((*i)->GetMiscValue() == int32(id))
- (*i)->ApplyModifier(true);
+ for(AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
+ if ((*j)->GetMiscValue() == int32(id))
+ (*j)->ApplyModifier(true);
// permanent bonuses
AuraEffectList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT);
- for(AuraEffectList::const_iterator i = mModSkillTalent.begin(); i != mModSkillTalent.end(); ++i)
- if ((*i)->GetMiscValue() == int32(id))
- (*i)->ApplyModifier(true);
+ for(AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
+ if ((*j)->GetMiscValue() == int32(id))
+ (*j)->ApplyModifier(true);
// Learn all spells for skill
learnSkillRewardedSpells(id, currVal);
@@ -5766,11 +5766,11 @@ void Player::RewardReputation(Unit *pVictim, float rate)
donerep1 = int32(donerep1*rate);
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
- if(factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
+ if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
// Wiki: Team factions value divided by 2
- if(Rep->is_teamaward1)
+ if (factionEntry1 && Rep->is_teamaward1)
{
FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team);
if(team1_factionEntry)
@@ -5784,11 +5784,11 @@ void Player::RewardReputation(Unit *pVictim, float rate)
donerep2 = int32(donerep2*rate);
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
- if(factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
+ if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
// Wiki: Team factions value divided by 2
- if(Rep->is_teamaward2)
+ if (factionEntry2 && Rep->is_teamaward2)
{
FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team);
if(team2_factionEntry)
@@ -9836,8 +9836,8 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE;
// if swap ignore item (equipped also)
- if(uint8 res = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
- return res;
+ if(uint8 res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
+ return res2;
// check unique-equipped special item classes
if (pProto->Class == ITEM_CLASS_QUIVER)
@@ -10428,97 +10428,96 @@ Item* Player::EquipNewItem( uint16 pos, uint32 item, bool update )
Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
{
- if( pItem )
- {
- AddEnchantmentDurations(pItem);
- AddItemDurations(pItem);
- uint8 bag = pos >> 8;
- uint8 slot = pos & 255;
+ AddEnchantmentDurations(pItem);
+ AddItemDurations(pItem);
- Item *pItem2 = GetItemByPos( bag, slot );
+ uint8 bag = pos >> 8;
+ uint8 slot = pos & 255;
- if( !pItem2 )
+ Item *pItem2 = GetItemByPos( bag, slot );
+
+ if( !pItem2 )
+ {
+ VisualizeItem( slot, pItem);
+
+ if(isAlive())
{
- VisualizeItem( slot, pItem);
+ ItemPrototype const *pProto = pItem->GetProto();
- if(isAlive())
- {
- ItemPrototype const *pProto = pItem->GetProto();
+ // item set bonuses applied only at equip and removed at unequip, and still active for broken items
+ if(pProto && pProto->ItemSet)
+ AddItemsSetItem(this,pItem);
- // item set bonuses applied only at equip and removed at unequip, and still active for broken items
- if(pProto && pProto->ItemSet)
- AddItemsSetItem(this,pItem);
+ _ApplyItemMods(pItem, slot, true);
- _ApplyItemMods(pItem, slot, true);
+ if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0)
+ {
+ uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s;
- if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0)
- {
- uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s;
+ if (getClass() == CLASS_ROGUE)
+ cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s;
- if (getClass() == CLASS_ROGUE)
- cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s;
+ SpellEntry const* spellProto = sSpellStore.LookupEntry(cooldownSpell);
- SpellEntry const* spellProto = sSpellStore.LookupEntry(cooldownSpell);
+ if (!spellProto)
+ sLog.outError("Weapon switch cooldown spell %u couldn't be found in Spell.dbc", cooldownSpell);
+ else
+ {
+ m_weaponChangeTimer = spellProto->StartRecoveryTime;
- if (!spellProto)
- sLog.outError("Weapon switch cooldown spell %u couldn't be found in Spell.dbc", cooldownSpell);
- else
- {
- m_weaponChangeTimer = spellProto->StartRecoveryTime;
-
- WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4);
- data << uint64(GetGUID());
- data << uint8(1);
- data << uint32(cooldownSpell);
- data << uint32(0);
- GetSession()->SendPacket(&data);
- }
+ WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4);
+ data << uint64(GetGUID());
+ data << uint8(1);
+ data << uint32(cooldownSpell);
+ data << uint32(0);
+ GetSession()->SendPacket(&data);
}
}
+ }
- if( IsInWorld() && update )
- {
- pItem->AddToWorld();
- pItem->SendUpdateToPlayer( this );
- }
+ if( IsInWorld() && update )
+ {
+ pItem->AddToWorld();
+ pItem->SendUpdateToPlayer( this );
+ }
- ApplyEquipCooldown(pItem);
+ ApplyEquipCooldown(pItem);
- if( slot == EQUIPMENT_SLOT_MAINHAND )
- UpdateExpertise(BASE_ATTACK);
- else if( slot == EQUIPMENT_SLOT_OFFHAND )
- UpdateExpertise(OFF_ATTACK);
- }
- else
- {
- pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() );
- if( IsInWorld() && update )
- pItem2->SendUpdateToPlayer( this );
+ if( slot == EQUIPMENT_SLOT_MAINHAND )
+ UpdateExpertise(BASE_ATTACK);
+ else if( slot == EQUIPMENT_SLOT_OFFHAND )
+ UpdateExpertise(OFF_ATTACK);
+ }
+ else
+ {
+ pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() );
+ if( IsInWorld() && update )
+ pItem2->SendUpdateToPlayer( this );
- // delete item (it not in any slot currently)
- //pItem->DeleteFromDB();
- if( IsInWorld() && update )
- {
- pItem->RemoveFromWorld();
- pItem->DestroyForPlayer( this );
- }
+ // delete item (it not in any slot currently)
+ //pItem->DeleteFromDB();
+ if( IsInWorld() && update )
+ {
+ pItem->RemoveFromWorld();
+ pItem->DestroyForPlayer( this );
+ }
- RemoveEnchantmentDurations(pItem);
- RemoveItemDurations(pItem);
+ RemoveEnchantmentDurations(pItem);
+ RemoveItemDurations(pItem);
- pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
- pItem->SetState(ITEM_REMOVED, this);
- pItem2->SetState(ITEM_CHANGED, this);
+ pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
+ pItem->SetState(ITEM_REMOVED, this);
+ pItem2->SetState(ITEM_CHANGED, this);
- ApplyEquipCooldown(pItem2);
+ ApplyEquipCooldown(pItem2);
- return pItem2;
- }
+ return pItem2;
}
// only for full equip instead adding to stack
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
+
return pItem;
}
@@ -11286,7 +11285,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
// check src->dest move possibility
ItemPosCountVec sDest;
- uint16 eDest;
+ uint16 eDest = 0;
if( IsInventoryPos( dst ) )
msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true );
else if( IsBankPos( dst ) )
@@ -11306,7 +11305,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
// check dest->src move possibility
ItemPosCountVec sDest2;
- uint16 eDest2;
+ uint16 eDest2 = 0;
if( IsInventoryPos( src ) )
msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true );
else if( IsBankPos( src ) )
@@ -12334,14 +12333,14 @@ bool Player::CanAddQuest( Quest const *pQuest, bool msg )
{
uint32 count = pQuest->GetSrcItemCount();
ItemPosCountVec dest;
- uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count );
+ uint8 msg2 = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count );
// player already have max number (in most case 1) source item, no additional item needed and quest can be added.
- if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS )
+ if( msg2 == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS )
return true;
- else if( msg != EQUIP_ERR_OK )
+ else if( msg2 != EQUIP_ERR_OK )
{
- SendEquipError( msg, NULL, NULL );
+ SendEquipError( msg2, NULL, NULL );
return false;
}
}
@@ -12942,14 +12941,14 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
// each-from-all exclusive group ( < 0)
// can be start if only all quests in prev quest exclusive group completed and rewarded
- ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
+ ObjectMgr::ExclusiveQuestGroups::iterator iter2 = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup());
- assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
+ assert(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
- for(; iter != end; ++iter)
+ for(; iter2 != end; ++iter2)
{
- uint32 exclude_Id = iter->second;
+ uint32 exclude_Id = iter2->second;
// skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == prevId)
@@ -12977,14 +12976,14 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
// each-from-all exclusive group ( < 0)
// can be start if only all quests in prev quest exclusive group active
- ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
+ ObjectMgr::ExclusiveQuestGroups::iterator iter2 = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup());
- assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
+ assert(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
- for(; iter != end; ++iter)
+ for(; iter2 != end; ++iter2)
{
- uint32 exclude_Id = iter->second;
+ uint32 exclude_Id = iter2->second;
// skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == prevId)
@@ -18358,8 +18357,8 @@ void Player::AddComboPoints(Unit* target, int8 count)
else
{
if(m_comboTarget)
- if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget))
- target->RemoveComboPointHolder(GetGUIDLow());
+ if(Unit* target2 = ObjectAccessor::GetUnit(*this,m_comboTarget))
+ target2->RemoveComboPointHolder(GetGUIDLow());
m_comboTarget = target->GetGUID();
m_comboPoints = count;
@@ -18483,10 +18482,10 @@ void Player::SendInitialPacketsAfterAddToMap()
// manual send package (have code in ApplyModifier(true,true); that don't must be re-applied.
if(HasAuraType(SPELL_AURA_MOD_ROOT))
{
- WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
- data.append(GetPackGUID());
- data << (uint32)2;
- SendMessageToSet(&data,true);
+ WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
+ data2.append(GetPackGUID());
+ data2 << (uint32)2;
+ SendMessageToSet(&data2,true);
}
SendAurasForTarget(this);