aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-31 21:33:26 -0700
committermaximius <none@none>2009-10-31 21:33:26 -0700
commit037d69cc043acb093e4dd3b6f03f7024400181cf (patch)
tree258a6bc43b09a4943869018ae4e065d1ed8e013a /src
parent425597d522284557279556f12d2f3d9834b3a346 (diff)
*Cleanup, and beda0979614d redux
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Player.cpp522
-rw-r--r--src/game/Player.h18
2 files changed, 241 insertions, 299 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 166bf33d26f..aa4faee20a5 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -2489,7 +2489,7 @@ void Player::GiveXP(uint32 xp, Unit* victim)
// Current player experience not update (must be update by caller)
void Player::GiveLevel(uint32 level)
{
- if ( level == getLevel() )
+ if (level == getLevel())
return;
PlayerLevelInfo info;
@@ -2525,7 +2525,7 @@ void Player::GiveLevel(uint32 level)
SetLevel(level);
- UpdateSkillsForLevel ();
+ UpdateSkillsForLevel();
// save base values (bonuses already included in stored stats
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
@@ -2594,7 +2594,7 @@ void Player::InitTalentForLevel()
}
// else update amount of free points
else
- SetFreeTalentPoints(talentPointsForLevel-m_usedTalentCount);
+ SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount);
}
if(!GetSession()->PlayerLoading())
@@ -2603,7 +2603,7 @@ void Player::InitTalentForLevel()
void Player::InitStatsForLevel(bool reapplyMods)
{
- if(reapplyMods) //reapply stats values only on .reset stats (level) command
+ if (reapplyMods) //reapply stats values only on .reset stats (level) command
_RemoveAllStatBonuses();
PlayerClassLevelInfo classInfo;
@@ -2644,7 +2644,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetUInt32Value(index, 0);
SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0);
- for (uint8 i = 0; i < 7; i++)
+ for (uint8 i = 0; i < 7; ++i)
{
SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, 0);
SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, 0);
@@ -2652,22 +2652,22 @@ void Player::InitStatsForLevel(bool reapplyMods)
}
//reset attack power, damage and attack speed fields
- SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f );
- SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f ); // offhand attack time
- SetFloatValue(UNIT_FIELD_RANGEDATTACKTIME, 2000.0f );
-
- SetFloatValue(UNIT_FIELD_MINDAMAGE, 0.0f );
- SetFloatValue(UNIT_FIELD_MAXDAMAGE, 0.0f );
- SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, 0.0f );
- SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, 0.0f );
- SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f );
- SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f );
-
- SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0 );
- SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0 );
+ SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f);
+ SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f); // offhand attack time
+ SetFloatValue(UNIT_FIELD_RANGEDATTACKTIME, 2000.0f);
+
+ SetFloatValue(UNIT_FIELD_MINDAMAGE, 0.0f);
+ SetFloatValue(UNIT_FIELD_MAXDAMAGE, 0.0f);
+ SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, 0.0f);
+ SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, 0.0f);
+ SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f);
+ SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f);
+
+ SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0);
+ SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0);
SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER,0.0f);
- SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0 );
- SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0 );
+ SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0);
+ SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0);
SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER,0.0f);
// Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
@@ -2691,7 +2691,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetResistanceBuffMods(SpellSchools(0), true, 0.0f);
SetResistanceBuffMods(SpellSchools(0), false, 0.0f);
// set other resistance to original value (0)
- for (uint8 i = 1; i < MAX_SPELL_SCHOOL; i++)
+ for (uint8 i = 1; i < MAX_SPELL_SCHOOL; ++i)
{
SetResistance(SpellSchools(i), 0);
SetResistanceBuffMods(SpellSchools(i), true, 0.0f);
@@ -2706,13 +2706,13 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f);
}
// Reset no reagent cost field
- for (uint8 i = 0; i < 3; i++)
+ for (uint8 i = 0; i < 3; ++i)
SetUInt32Value(PLAYER_NO_REAGENT_COST_1 + i, 0);
// Init data for form but skip reapply item mods for form
InitDataForForm(reapplyMods);
// save new stats
- for (uint8 i = POWER_MANA; i < MAX_POWERS; i++)
+ for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
SetMaxPower(Powers(i), uint32(GetCreatePowers(Powers(i))));
SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later
@@ -2738,9 +2738,9 @@ void Player::InitStatsForLevel(bool reapplyMods)
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
// restore if need some important flags
- SetUInt32Value(PLAYER_FIELD_BYTES2, 0 ); // flags empty by default
+ SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default
- if(reapplyMods) //reapply stats values only on .reset stats (level) command
+ if (reapplyMods) // reapply stats values only on .reset stats (level) command
_ApplyAllStatBonuses();
// set current level health and mana/energy to maximum after applying all mods.
@@ -7272,16 +7272,16 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change)
_Spell const& spellData = proto->Spells[i];
// no spell
- if(!spellData.SpellId )
+ if (!spellData.SpellId)
continue;
// wrong triggering type
- if(apply && spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP)
+ if (apply && spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP)
continue;
// check if it is valid spell
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellData.SpellId);
- if(!spellproto)
+ if (!spellproto)
continue;
ApplyEquipSpell(spellproto,item,apply,form_change);
@@ -7290,17 +7290,17 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change)
void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change)
{
- if(apply)
+ if (apply)
{
// Cannot be used in this stance/form
- if(GetErrorAtShapeshiftedCast(spellInfo, m_form) != SPELL_CAST_OK)
+ if (GetErrorAtShapeshiftedCast(spellInfo, m_form) != SPELL_CAST_OK)
return;
- if(form_change) // check aura active state from other form
+ if (form_change) // check aura active state from other form
{
AuraMap const& auras = GetAuras();
for (AuraMap::const_iterator itr = auras.lower_bound(spellInfo->Id); itr != auras.upper_bound(spellInfo->Id); ++itr)
- if(!item || itr->second->GetCastItemGUID()==item->GetGUID())
+ if (!item || itr->second->GetCastItemGUID()==item->GetGUID())
return;
}
@@ -7317,8 +7317,8 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
return; // and remove only not compatible at form change
}
- if(item)
- RemoveAurasDueToItemSpell(item,spellInfo->Id); // un-apply all spells , not only at-equipped
+ if (item)
+ RemoveAurasDueToItemSpell(item,spellInfo->Id); // un-apply all spells, not only at-equipped
else
RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case)
}
@@ -7326,7 +7326,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
void Player::UpdateEquipSpellsAtFormChange()
{
- for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
if(m_items[i] && !m_items[i]->IsBroken())
{
@@ -7355,18 +7355,18 @@ void Player::UpdateEquipSpellsAtFormChange()
}
void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx)
{
- if(!target || !target->isAlive() || target == this)
+ if (!target || !target->isAlive() || target == this)
return;
- for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
+ for (UINT8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
{
// If usable, try to cast item spell
- if (Item * item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i))
- if(!item->IsBroken())
+ if (Item * item = GetItemByPos(INVENTORY_SLOT_BAG_0,i))
+ if (!item->IsBroken())
if (ItemPrototype const *proto = item->GetProto())
{
// Additional check for weapons
- if (proto->Class==ITEM_CLASS_WEAPON)
+ if (proto->Class == ITEM_CLASS_WEAPON)
{
// offhand item cannot proc from main hand hit etc
EquipmentSlots slot;
@@ -7381,12 +7381,10 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
continue;
// Check if item is useable (forms or disarm)
if (attType == BASE_ATTACK)
- {
- if (!((Player*)this)->IsUseEquipedWeapon(true))
+ if (!IsUseEquipedWeapon(true))
continue;
- }
}
- ((Player*)this)->CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
+ CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
}
}
}
@@ -7397,36 +7395,36 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
//if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
{
- for (int i = 0; i < 5; i++)
+ for (uint8 i = 0; i < 5; ++i)
{
_Spell const& spellData = proto->Spells[i];
// no spell
- if(!spellData.SpellId )
+ if (!spellData.SpellId)
continue;
// wrong triggering type
- if(spellData.SpellTrigger != ITEM_SPELLTRIGGER_CHANCE_ON_HIT)
+ if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_CHANCE_ON_HIT)
continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellData.SpellId);
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("WORLD: unknown Item spellid %i", spellData.SpellId);
continue;
}
// not allow proc extra attack spell at extra attack
- if( m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS) )
+ if (m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS))
return;
float chance = spellInfo->procChance;
- if(spellData.SpellPPMRate)
+ if (spellData.SpellPPMRate)
{
- if(spellData.SpellId == 52781) // Persuasive Strike
+ if (spellData.SpellId == 52781) // Persuasive Strike
{
- switch(target->GetEntry())
+ switch (target->GetEntry())
{
default:
return;
@@ -7439,7 +7437,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
uint32 WeaponSpeed = GetAttackTime(attType);
chance = GetPPMProcChance(WeaponSpeed, spellData.SpellPPMRate, spellInfo);
}
- else if(chance > 100.0f)
+ else if (chance > 100.0f)
{
chance = GetWeaponProcChance();
}
@@ -7450,12 +7448,12 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
}
// item combat enchantments
- for (int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
+ for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
{
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if(!pEnchant) continue;
- for (int s=0; s<3; s++)
+ for (uint8 s = 0; s < 3; ++s)
{
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
continue;
@@ -7511,13 +7509,13 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
{
ItemPrototype const* proto = item->GetProto();
// special learning case
- if(proto->Spells[0].SpellId==SPELL_ID_GENERIC_LEARN || proto->Spells[0].SpellId==SPELL_ID_GENERIC_LEARN_PET)
+ if (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN || proto->Spells[0].SpellId==SPELL_ID_GENERIC_LEARN_PET)
{
uint32 learn_spell_id = proto->Spells[0].SpellId;
uint32 learning_spell_id = proto->Spells[1].SpellId;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(learn_spell_id);
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring ",proto->ItemId, learn_spell_id);
SendEquipError(EQUIP_ERR_NONE,item,NULL);
@@ -7533,19 +7531,19 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
}
// use triggered flag only for items with many spell casts and for not first cast
- int count = 0;
+ uint8 count = 0;
// item spells casted at use
- for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
_Spell const& spellData = proto->Spells[i];
// no spell
- if(!spellData.SpellId)
+ if (!spellData.SpellId)
continue;
// wrong triggering type
- if( spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE && spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)
+ if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE && spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)
continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellData.SpellId);
@@ -7565,12 +7563,13 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
}
// Item enchantments spells casted at use
- for (int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
+ for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
{
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
- if(!pEnchant) continue;
- for (int s=0; s<3; s++)
+ if (!pEnchant)
+ continue;
+ for (uint8 s = 0; s < 3; ++s)
{
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL)
continue;
@@ -7597,43 +7596,43 @@ void Player::_RemoveAllItemMods()
{
sLog.outDebug("_RemoveAllItemMods start.");
- for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if(m_items[i])
+ if (m_items[i])
{
ItemPrototype const *proto = m_items[i]->GetProto();
- if(!proto)
+ if (!proto)
continue;
// item set bonuses not dependent from item broken state
- if(proto->ItemSet)
+ if (proto->ItemSet)
RemoveItemsSetItem(this,proto);
- if(m_items[i]->IsBroken())
+ if (m_items[i]->IsBroken())
continue;
- ApplyItemEquipSpell(m_items[i],false);
+ ApplyItemEquipSpell(m_items[i], false);
ApplyEnchantment(m_items[i], false);
}
}
- for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if(m_items[i])
+ if (m_items[i])
{
- if(m_items[i]->IsBroken())
+ if (m_items[i]->IsBroken())
continue;
ItemPrototype const *proto = m_items[i]->GetProto();
- if(!proto)
+ if (!proto)
continue;
uint32 attacktype = Player::GetAttackBySlot(i);
- if(attacktype < MAX_ATTACK)
+ if (attacktype < MAX_ATTACK)
_ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),false);
_ApplyItemBonuses(proto,i, false);
- if( i == EQUIPMENT_SLOT_RANGED )
+ if (i == EQUIPMENT_SLOT_RANGED)
_ApplyAmmoBonuses();
}
}
@@ -7645,41 +7644,41 @@ void Player::_ApplyAllItemMods()
{
sLog.outDebug("_ApplyAllItemMods start.");
- for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if(m_items[i])
+ if (m_items[i])
{
- if(m_items[i]->IsBroken())
+ if (m_items[i]->IsBroken())
continue;
ItemPrototype const *proto = m_items[i]->GetProto();
- if(!proto)
+ if (!proto)
continue;
uint32 attacktype = Player::GetAttackBySlot(i);
- if(attacktype < MAX_ATTACK)
+ if (attacktype < MAX_ATTACK)
_ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),true);
_ApplyItemBonuses(proto,i, true);
- if( i == EQUIPMENT_SLOT_RANGED )
+ if (i == EQUIPMENT_SLOT_RANGED)
_ApplyAmmoBonuses();
}
}
- for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if(m_items[i])
+ if (m_items[i])
{
ItemPrototype const *proto = m_items[i]->GetProto();
- if(!proto)
+ if (!proto)
continue;
// item set bonuses not dependent from item broken state
- if(proto->ItemSet)
+ if (proto->ItemSet)
AddItemsSetItem(this,m_items[i]);
- if(m_items[i]->IsBroken())
+ if (m_items[i]->IsBroken())
continue;
ApplyItemEquipSpell(m_items[i],true);
@@ -7692,15 +7691,15 @@ void Player::_ApplyAllItemMods()
void Player::_ApplyAllLevelScaleItemMods(bool apply)
{
- for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if(m_items[i])
+ if (m_items[i])
{
- if(m_items[i]->IsBroken())
+ if (m_items[i]->IsBroken())
continue;
ItemPrototype const *proto = m_items[i]->GetProto();
- if(!proto)
+ if (!proto)
continue;
_ApplyItemBonuses(proto,i, apply, true);
@@ -7712,50 +7711,50 @@ void Player::_ApplyAmmoBonuses()
{
// check ammo
uint32 ammo_id = GetUInt32Value(PLAYER_AMMO_ID);
- if(!ammo_id)
+ if (!ammo_id)
return;
float currentAmmoDPS;
ItemPrototype const *ammo_proto = objmgr.GetItemPrototype( ammo_id );
- if( !ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto))
+ if (!ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto))
currentAmmoDPS = 0.0f;
else
- currentAmmoDPS = ( ammo_proto->Damage[0].DamageMin + ammo_proto->Damage[0].DamageMax ) / 2;
+ currentAmmoDPS = (ammo_proto->Damage[0].DamageMin + ammo_proto->Damage[0].DamageMax) / 2;
- if(currentAmmoDPS == GetAmmoDPS())
+ if (currentAmmoDPS == GetAmmoDPS())
return;
m_ammoDPS = currentAmmoDPS;
- if(CanModifyStats())
+ if (CanModifyStats())
UpdateDamagePhysical(RANGED_ATTACK);
}
bool Player::CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const
{
- if(!ammo_proto)
+ if (!ammo_proto)
return false;
// check ranged weapon
Item *weapon = GetWeaponForAttack( RANGED_ATTACK );
- if(!weapon || weapon->IsBroken() )
+ if (!weapon || weapon->IsBroken())
return false;
ItemPrototype const* weapon_proto = weapon->GetProto();
- if(!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON )
+ if (!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON )
return false;
// check ammo ws. weapon compatibility
- switch(weapon_proto->SubClass)
+ switch (weapon_proto->SubClass)
{
case ITEM_SUBCLASS_WEAPON_BOW:
case ITEM_SUBCLASS_WEAPON_CROSSBOW:
- if(ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW)
+ if (ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW)
return false;
break;
case ITEM_SUBCLASS_WEAPON_GUN:
- if(ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET)
+ if (ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET)
return false;
break;
default:
@@ -7773,7 +7772,7 @@ void Player::RemovedInsignia(Player* looterPlr)
return;
// If not released spirit, do it !
- if(m_deathTimer > 0)
+ if (m_deathTimer > 0)
{
m_deathTimer = 0;
BuildPlayerRepop();
@@ -7812,7 +7811,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
if (uint64 lguid = GetLootGUID())
m_session->DoLootRelease(lguid);
- Loot *loot = 0;
+ Loot *loot = 0;
PermissionTypes permission = ALL_PERMISSION;
sLog.outDebug("Player::SendLoot");
@@ -7860,7 +7859,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
}
else if (IS_ITEM_GUID(guid))
{
- Item *item = GetItemByGuid( guid );
+ Item *item = GetItemByGuid(guid);
if (!item)
{
@@ -7875,7 +7874,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
item->m_lootGenerated = true;
loot->clear();
- switch(loot_type)
+ switch (loot_type)
{
case LOOT_DISENCHANTING:
loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this,true);
@@ -7897,7 +7896,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
{
Corpse *bones = ObjectAccessor::GetCorpse(*this, guid);
- if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) )
+ if (!bones || !(loot_type == LOOT_CORPSE || loot_type == LOOT_INSIGNIA) || bones->GetType() != CORPSE_BONES)
{
SendLootRelease(guid);
return;
@@ -7910,12 +7909,12 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
bones->lootForBody = true;
uint32 pLevel = bones->loot.gold;
bones->loot.clear();
- if(BattleGround *bg = GetBattleGround())
- if(bg->GetTypeID() == BATTLEGROUND_AV)
+ if (BattleGround *bg = GetBattleGround())
+ if (bg->GetTypeID() == BATTLEGROUND_AV)
loot->FillLoot(1, LootTemplates_Creature, this, true);
// It may need a better formula
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
- bones->loot.gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) );
+ bones->loot.gold = uint32(urand(50, 150) * 0.016f * pow(float(pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY));
}
if (bones->lootRecipient != this)
@@ -7926,7 +7925,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
Creature *creature = GetMap()->GetCreature(guid);
// must be in range and creature must be alive for pickpocket and must be dead for another loot
- if (!creature || creature->isAlive()!=(loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE))
+ if (!creature || creature->isAlive() != (loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE))
{
SendLootRelease(guid);
return;
@@ -8043,7 +8042,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
SetLootGUID(guid);
// LOOT_INSIGNIA and LOOT_FISHINGHOLE unsupported by client
- switch(loot_type)
+ switch (loot_type)
{
case LOOT_INSIGNIA: loot_type = LOOT_SKINNING; break;
case LOOT_FISHINGHOLE: loot_type = LOOT_FISHING; break;
@@ -8098,10 +8097,10 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
uint32 mapid = GetMapId();
OutdoorPvP * pvp = sOutdoorPvPMgr.GetOutdoorPvPToZoneId(zoneid);
- sLog.outDebug("Sending SMSG_INIT_WORLD_STATES to Map:%u, Zone: %u", mapid, zoneid);
+ sLog.outDebug("Sending SMSG_INIT_WORLD_STATES to Map: %u, Zone: %u", mapid, zoneid);
// may be exist better way to do this...
- switch(zoneid)
+ switch (zoneid)
{
case 0:
case 1:
@@ -8240,7 +8239,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
break;
case 1377: // Silithus
{
- if(pvp && pvp->GetTypeId() == OUTDOOR_PVP_SI)
+ if (pvp && pvp->GetTypeId() == OUTDOOR_PVP_SI)
pvp->FillInitialWorldStates(data);
else
{
@@ -8647,7 +8646,7 @@ void Player::SendTalentWipeConfirm(uint64 guid)
void Player::SendPetSkillWipeConfirm()
{
Pet* pet = GetPet();
- if(!pet)
+ if (!pet)
return;
WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8+4));
data << pet->GetGUID();
@@ -8662,16 +8661,16 @@ void Player::SendPetSkillWipeConfirm()
void Player::SetVirtualItemSlot( uint8 i, Item* item)
{
assert(i < 3);
- if(i < 2 && item)
+ if (i < 2 && item)
{
- if(!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
+ if (!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
return;
uint32 charges = item->GetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT);
- if(charges == 0)
+ if (charges == 0)
return;
- if(charges > 1)
+ if (charges > 1)
item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT,charges-1);
- else if(charges <= 1)
+ else if (charges <= 1)
{
ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false);
item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT);
@@ -8717,7 +8716,7 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
slots[1] = NULL_SLOT;
slots[2] = NULL_SLOT;
slots[3] = NULL_SLOT;
- switch( proto->InventoryType )
+ switch (proto->InventoryType)
{
case INVTYPE_HEAD:
slots[0] = EQUIPMENT_SLOT_HEAD;
@@ -8769,7 +8768,7 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
// suggest offhand slot only if know dual wielding
// (this will be replace mainhand weapon at auto equip instead unwonted "you don't known dual wielding" ...
- if(CanDualWield())
+ if (CanDualWield())
slots[1] = EQUIPMENT_SLOT_OFFHAND;
break;
};
@@ -8781,7 +8780,14 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
break;
case INVTYPE_2HWEAPON:
slots[0] = EQUIPMENT_SLOT_MAINHAND;
- if (CanDualWield() && CanTitanGrip() && proto && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF)
+ if (Item *mhWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND))
+ if (ItemPrototype const *mhWeaponProto = mhWeapon->GetProto())
+ if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF)
+ {
+ const_cast<Player *>(this)->AutoUnequipOffhandIfNeed(true);
+ break;
+ }
+ if (CanDualWield() && CanTitanGrip() && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF)
slots[1] = EQUIPMENT_SLOT_OFFHAND;
break;
case INVTYPE_TABARD:
@@ -8835,40 +8841,30 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
}
break;
}
- default :
+ default:
return NULL_SLOT;
}
- if( slot != NULL_SLOT )
+ if (slot != NULL_SLOT)
{
- if( swap || !GetItemByPos( INVENTORY_SLOT_BAG_0, slot ) )
- {
- for (uint8 i = 0; i < 4; i++)
- {
- if ( slots[i] == slot )
+ if (swap || !GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
+ for (uint8 i = 0; i < 4; ++i)
+ if (slots[i] == slot)
return slot;
- }
- }
}
else
{
// search free slot at first
- for (uint8 i = 0; i < 4; i++)
- {
- if ( slots[i] != NULL_SLOT && !GetItemByPos( INVENTORY_SLOT_BAG_0, slots[i] ) )
- {
+ for (uint8 i = 0; i < 4; ++i)
+ if (slots[i] != NULL_SLOT && !GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i]))
// in case 2hand equipped weapon (without titan grip) offhand slot empty but not free
- if(slots[i]!=EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed())
+ if(slots[i] != EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed())
return slots[i];
- }
- }
// if not found free and can swap return first appropriate from used
- for (uint8 i = 0; i < 4; i++)
- {
- if ( slots[i] != NULL_SLOT && swap )
+ for (uint8 i = 0; i < 4; ++i)
+ if (slots[i] != NULL_SLOT && swap)
return slots[i];
- }
}
// no free position
@@ -8877,126 +8873,97 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap
uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const
{
- Item *pItem;
uint32 tempcount = 0;
uint8 res = EQUIP_ERR_OK;
- for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++)
- {
- pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem->GetEntry() == item )
- {
- uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false);
- if(ires==EQUIP_ERR_OK)
+ for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
+ if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ if (pItem->GetEntry() == item)
+ {
+ uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false);
+ if (ires == EQUIP_ERR_OK)
+ {
+ tempcount += pItem->GetCount();
+ if (tempcount >= count)
+ return EQUIP_ERR_OK;
+ }
+ else
+ res = ires;
+ }
+
+ for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
+ if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem->GetEntry() == item)
{
tempcount += pItem->GetCount();
- if( tempcount >= count )
+ if (tempcount >= count)
return EQUIP_ERR_OK;
}
- else
- res = ires;
- }
- }
- for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
- {
- pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem->GetEntry() == item )
- {
- tempcount += pItem->GetCount();
- if( tempcount >= count )
- return EQUIP_ERR_OK;
- }
- }
+
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
- {
- pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem->GetEntry() == item )
- {
- tempcount += pItem->GetCount();
- if( tempcount >= count )
- return EQUIP_ERR_OK;
- }
- }
- Bag *pBag;
- for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
- {
- pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
- {
- for (uint32 j = 0; j < pBag->GetBagSize(); j++)
+ if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem->GetEntry() == item)
{
- pItem = GetItemByPos( i, j );
- if( pItem && pItem->GetEntry() == item )
- {
- tempcount += pItem->GetCount();
- if( tempcount >= count )
- return EQUIP_ERR_OK;
- }
+ tempcount += pItem->GetCount();
+ if(tempcount >= count)
+ return EQUIP_ERR_OK;
}
- }
- }
+
+ for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
+ if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
+ if (Item *pItem = GetItemByPos(i, j))
+ if (pItem->GetEntry() == item)
+ {
+ tempcount += pItem->GetCount();
+ if (tempcount >= count)
+ return EQUIP_ERR_OK;
+ }
// not found req. item count and have unequippable items
return res;
}
-uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) const
+uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const
{
uint32 count = 0;
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
- {
- Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem != skipItem && pItem->GetEntry() == item )
- count += pItem->GetCount();
- }
+ if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem != skipItem && pItem->GetEntry() == item)
+ count += pItem->GetCount();
+
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
- {
- Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem != skipItem && pItem->GetEntry() == item )
- count += pItem->GetCount();
- }
- for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
- {
- Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
+ if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem != skipItem && pItem->GetEntry() == item)
+ count += pItem->GetCount();
+
+ for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
+ if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
count += pBag->GetItemCount(item,skipItem);
- }
if(skipItem && skipItem->GetProto()->GemProperties)
- {
- for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
- {
- Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color )
- count += pItem->GetGemCountWithID(item);
- }
- }
+ for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
+ if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem != skipItem && pItem->GetProto()->Socket[0].Color)
+ count += pItem->GetGemCountWithID(item);
- if(inBankAlso)
+ if (inBankAlso)
{
- for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++)
- {
- Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem != skipItem && pItem->GetEntry() == item )
- count += pItem->GetCount();
- }
- for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
- {
- Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
+ for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
+ if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem != skipItem && pItem->GetEntry() == item)
+ count += pItem->GetCount();
+
+ for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
+ if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i))
count += pBag->GetItemCount(item,skipItem);
- }
- if(skipItem && skipItem->GetProto()->GemProperties)
- {
- for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++)
- {
- Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color )
- count += pItem->GetGemCountWithID(item);
- }
- }
+ if (skipItem && skipItem->GetProto()->GemProperties)
+ for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
+ if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ if (pItem != skipItem && pItem->GetProto()->Socket[0].Color)
+ count += pItem->GetGemCountWithID(item);
}
return count;
@@ -9004,45 +8971,29 @@ uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) cons
Item* Player::GetItemByGuid( uint64 guid ) const
{
- for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++)
- {
- Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem->GetGUID() == guid )
- return pItem;
- }
+ for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
+ if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ if (pItem->GetGUID() == guid)
+ return pItem;
+
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
- {
- Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pItem && pItem->GetGUID() == guid )
- return pItem;
- }
+ if (Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i))
+ if (pItem->GetGUID() == guid)
+ return pItem;
- for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
- {
- Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
- {
- for (uint32 j = 0; j < pBag->GetBagSize(); j++)
- {
- Item* pItem = pBag->GetItemByPos( j );
- if( pItem && pItem->GetGUID() == guid )
- return pItem;
- }
- }
- }
- for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
- {
- Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i );
- if( pBag )
- {
- for (uint32 j = 0; j < pBag->GetBagSize(); j++)
- {
- Item* pItem = pBag->GetItemByPos( j );
- if( pItem && pItem->GetGUID() == guid )
- return pItem;
- }
- }
- }
+ for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
+ if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
+ if (Item* pItem = pBag->GetItemByPos(j))
+ if (pItem->GetGUID() == guid)
+ return pItem;
+
+ for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
+ if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
+ if (Item* pItem = pBag->GetItemByPos(j))
+ if (pItem->GetGUID() == guid)
+ return pItem;
return NULL;
}
@@ -9056,19 +9007,18 @@ Item* Player::GetItemByPos( uint16 pos ) const
Item* Player::GetItemByPos( uint8 bag, uint8 slot ) const
{
- if( bag == INVENTORY_SLOT_BAG_0 && ( slot < BANK_SLOT_BAG_END || (slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END )) )
+ if (bag == INVENTORY_SLOT_BAG_0 && ( slot < BANK_SLOT_BAG_END || (slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) ))
return m_items[slot];
else if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END)
- || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END) )
+ || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END))
{
- Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
- if ( pBag )
+ if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag))
return pBag->GetItemByPos(slot);
}
return NULL;
}
-Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) const
+Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= false*/) const
{
uint16 slot;
switch (attackType)
@@ -9083,10 +9033,10 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) cons
if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON)
return NULL;
- if(!useable)
+ if (!useable)
return item;
- if( item->IsBroken() || IsInFeralForm())
+ if (item->IsBroken() || IsInFeralForm())
return NULL;
return item;
@@ -9098,10 +9048,10 @@ Item* Player::GetShield(bool useable) const
if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR)
return NULL;
- if(!useable)
+ if (!useable)
return item;
- if( item->IsBroken())
+ if (item->IsBroken())
return NULL;
return item;
@@ -19979,14 +19929,14 @@ void Player::AddItemDurations( Item *item )
}
}
-void Player::AutoUnequipOffhandIfNeed()
+void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/)
{
- Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND );
+ Item *offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
if(!offItem)
return;
// need unequip offhand for 2h-weapon without TitanGrip (in any from hands)
- if (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))
+ if (!force && (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed())))
return;
ItemPosCountVec off_dest;
diff --git a/src/game/Player.h b/src/game/Player.h
index 244d80ec697..3b7b8143a74 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1125,7 +1125,7 @@ class MANGOS_DLL_SPEC Player : public Unit
Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update );
Item* EquipNewItem( uint16 pos, uint32 item, bool update );
Item* EquipItem( uint16 pos, Item *pItem, bool update );
- void AutoUnequipOffhandIfNeed();
+ void AutoUnequipOffhandIfNeed(bool force = false);
bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false);
void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG,NULL_SLOT,loot_id,store,broadcast); }
@@ -1854,15 +1854,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetCanParry(bool value);
bool CanBlock() const { return m_canBlock; }
void SetCanBlock(bool value);
- bool CanTitanGrip() const
- {
- Item *mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND );
-
- if (mainItem && ( mainItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mainItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ))
- return false;
-
- return m_canTitanGrip ;
- }
+ bool CanTitanGrip() const { return m_canTitanGrip; }
void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
@@ -1929,7 +1921,7 @@ class MANGOS_DLL_SPEC Player : public Unit
bool InBattleGroundQueue() const
{
- for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
+ for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
return true;
return false;
@@ -1938,14 +1930,14 @@ class MANGOS_DLL_SPEC Player : public Unit
BattleGroundQueueTypeId GetBattleGroundQueueTypeId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueTypeId; }
uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const
{
- for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
+ for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
return i;
return PLAYER_MAX_BATTLEGROUND_QUEUES;
}
bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
{
- for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
+ for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
return false;