mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7716] Fixed some typos and possible crashes.
This commit is contained in:
parent
c2e6dd20dd
commit
c9d51a6dc7
25 changed files with 281 additions and 263 deletions
|
|
@ -759,7 +759,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() );
|
||||
}
|
||||
|
|
@ -863,8 +863,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);
|
||||
|
|
@ -2802,22 +2802,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 );
|
||||
}
|
||||
|
|
@ -2828,13 +2828,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 );
|
||||
}
|
||||
|
||||
|
|
@ -2947,14 +2947,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5226,15 +5226,15 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
|
||||
// temporary bonuses
|
||||
AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL);
|
||||
for(AuraList::const_iterator i = mModSkill.begin(); i != mModSkill.end(); ++i)
|
||||
if ((*i)->GetModifier()->m_miscvalue == int32(id))
|
||||
(*i)->ApplyModifier(true);
|
||||
for(AuraList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
|
||||
if ((*j)->GetModifier()->m_miscvalue == int32(id))
|
||||
(*j)->ApplyModifier(true);
|
||||
|
||||
// permanent bonuses
|
||||
AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT);
|
||||
for(AuraList::const_iterator i = mModSkillTalent.begin(); i != mModSkillTalent.end(); ++i)
|
||||
if ((*i)->GetModifier()->m_miscvalue == int32(id))
|
||||
(*i)->ApplyModifier(true);
|
||||
for(AuraList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
|
||||
if ((*j)->GetModifier()->m_miscvalue == int32(id))
|
||||
(*j)->ApplyModifier(true);
|
||||
|
||||
// Learn all spells for skill
|
||||
learnSkillRewardedSpells(id, currVal);
|
||||
|
|
@ -5685,11 +5685,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)
|
||||
|
|
@ -5703,11 +5703,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)
|
||||
|
|
@ -9556,8 +9556,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)
|
||||
|
|
@ -10148,97 +10148,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;
|
||||
|
||||
Item *pItem2 = GetItemByPos( bag, slot );
|
||||
|
||||
if( !pItem2 )
|
||||
{
|
||||
AddEnchantmentDurations(pItem);
|
||||
AddItemDurations(pItem);
|
||||
VisualizeItem( slot, pItem);
|
||||
|
||||
uint8 bag = pos >> 8;
|
||||
uint8 slot = pos & 255;
|
||||
|
||||
Item *pItem2 = GetItemByPos( bag, slot );
|
||||
|
||||
if( !pItem2 )
|
||||
if(isAlive())
|
||||
{
|
||||
VisualizeItem( slot, pItem);
|
||||
ItemPrototype const *pProto = pItem->GetProto();
|
||||
|
||||
if(isAlive())
|
||||
// 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);
|
||||
|
||||
if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0)
|
||||
{
|
||||
ItemPrototype const *pProto = pItem->GetProto();
|
||||
uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s;
|
||||
|
||||
// item set bonuses applied only at equip and removed at unequip, and still active for broken items
|
||||
if(pProto && pProto->ItemSet)
|
||||
AddItemsSetItem(this,pItem);
|
||||
if (getClass() == CLASS_ROGUE)
|
||||
cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s;
|
||||
|
||||
_ApplyItemMods(pItem, slot, true);
|
||||
SpellEntry const* spellProto = sSpellStore.LookupEntry(cooldownSpell);
|
||||
|
||||
if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0)
|
||||
if (!spellProto)
|
||||
sLog.outError("Weapon switch cooldown spell %u couldn't be found in Spell.dbc", cooldownSpell);
|
||||
else
|
||||
{
|
||||
uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s;
|
||||
m_weaponChangeTimer = spellProto->StartRecoveryTime;
|
||||
|
||||
if (getClass() == CLASS_ROGUE)
|
||||
cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s;
|
||||
|
||||
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;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
ApplyEquipCooldown(pItem);
|
||||
|
||||
if( slot == EQUIPMENT_SLOT_MAINHAND )
|
||||
UpdateExpertise(BASE_ATTACK);
|
||||
else if( slot == EQUIPMENT_SLOT_OFFHAND )
|
||||
UpdateExpertise(OFF_ATTACK);
|
||||
}
|
||||
else
|
||||
|
||||
if( IsInWorld() && update )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
ApplyEquipCooldown(pItem2);
|
||||
|
||||
return pItem2;
|
||||
pItem->AddToWorld();
|
||||
pItem->SendUpdateToPlayer( this );
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
// delete item (it not in any slot currently)
|
||||
//pItem->DeleteFromDB();
|
||||
if( IsInWorld() && update )
|
||||
{
|
||||
pItem->RemoveFromWorld();
|
||||
pItem->DestroyForPlayer( this );
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
ApplyEquipCooldown(pItem2);
|
||||
|
||||
return pItem2;
|
||||
}
|
||||
|
||||
// only for full equip instead adding to stack
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
|
||||
|
||||
return pItem;
|
||||
}
|
||||
|
||||
|
|
@ -11006,7 +11005,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 ) )
|
||||
|
|
@ -11026,7 +11025,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 ) )
|
||||
|
|
@ -12054,14 +12053,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -12662,14 +12661,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)
|
||||
|
|
@ -12697,14 +12696,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)
|
||||
|
|
@ -17782,8 +17781,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;
|
||||
|
|
@ -17909,10 +17908,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue