fix(Core): potential crashes/bugs reported by static analysis #2 (#2622)

This commit is contained in:
Kaev
2020-02-03 07:52:27 +01:00
committed by GitHub
parent 8cfdfd0af0
commit 2fa9f5c249
30 changed files with 148 additions and 229 deletions

View File

@@ -365,7 +365,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
// Load creature equipment
if (!data || data->equipmentId == 0) // use default from the template
LoadEquipment();
else if (data && data->equipmentId != 0) // override, 0 means no equipment
else
{
m_originalEquipmentId = data->equipmentId;
LoadEquipment(data->equipmentId);

View File

@@ -214,9 +214,8 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
std::string title = quest->GetTitle();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
data << title;
}
}
@@ -241,9 +240,8 @@ void PlayerMenu::SendPointOfInterest(uint32 poiId) const
std::string name = poi->Name;
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId))
ObjectMgr::GetLocaleString(localeData->Name, locale, name);
if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId))
ObjectMgr::GetLocaleString(localeData->Name, locale, name);
WorldPacket data(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 20); // guess size
data << uint32(poi->Flags);
@@ -322,9 +320,8 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string
std::string title = quest->GetTitle();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
data << uint32(questID);
data << uint32(qmi.QuestIcon);
@@ -362,16 +359,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
std::string questAreaDescription = quest->GetAreaDescription();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
}
}
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
}
WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size
data << uint64(npcGUID);
@@ -474,19 +468,16 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
questObjectiveText[i] = quest->ObjectiveText[i];
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]);
}
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]);
}
WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100); // guess size
@@ -603,14 +594,11 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
std::string RewardText = quest->GetOfferRewardText();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
}
if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size
data << uint64(npcGUID);
@@ -699,14 +687,11 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
std::string requestItemsText = quest->GetRequestItemsText();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
if (QuestRequestItemsLocale const* questRequestItemsLocale = sObjectMgr->GetQuestRequestItemsLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questRequestItemsLocale->CompletionText, locale, requestItemsText);
}
if (QuestRequestItemsLocale const* questRequestItemsLocale = sObjectMgr->GetQuestRequestItemsLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questRequestItemsLocale->CompletionText, locale, requestItemsText);
if (!quest->GetReqItemsCount() && canComplete)
{

View File

@@ -85,7 +85,7 @@ void TempSummon::Update(uint32 diff)
case TEMPSUMMON_CORPSE_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE || m_deathState == DEAD)
if (m_deathState == CORPSE)
{
UnSummon();
return;
@@ -95,17 +95,12 @@ void TempSummon::Update(uint32 diff)
}
case TEMPSUMMON_DEAD_DESPAWN:
{
if (m_deathState == DEAD)
{
UnSummon();
return;
}
break;
}
case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE || m_deathState == DEAD)
if (m_deathState == CORPSE)
{
UnSummon();
return;
@@ -127,13 +122,6 @@ void TempSummon::Update(uint32 diff)
}
case TEMPSUMMON_TIMED_OR_DEAD_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == DEAD)
{
UnSummon();
return;
}
if (!IsInCombat() && IsAlive())
{
if (m_timer <= diff)

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
@@ -443,7 +443,7 @@ void Pet::Update(uint32 diff)
if (IsWithinLOSInMap(tempspellTarget) && GetDistance(tempspellTarget) < max_range)
{
if (tempspellTarget && !GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo) && !HasSpellCooldown(tempspell))
if (!GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo) && !HasSpellCooldown(tempspell))
{
StopMoving();
GetMotionMaster()->Clear(false);
@@ -711,8 +711,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetLevel(petlevel);
SetCanModifyStats(true);
Unit *m_owner = GetOwner();
if (!m_owner) // just to be sure, asynchronous now
Unit *owner = GetOwner();
if (!owner) // just to be sure, asynchronous now
{
DespawnOrUnsummon(1000);
return false;
@@ -720,20 +720,20 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
//Determine pet type
PetType petType = MAX_PET_TYPE;
if (IsPet() && m_owner->GetTypeId() == TYPEID_PLAYER)
if (IsPet() && owner->GetTypeId() == TYPEID_PLAYER)
{
if (m_owner->getClass() == CLASS_WARLOCK ||
m_owner->getClass() == CLASS_SHAMAN || // Fire Elemental
m_owner->getClass() == CLASS_DEATH_KNIGHT || // Risen Ghoul
m_owner->getClass() == CLASS_MAGE) // Water Elemental with glyph
if (owner->getClass() == CLASS_WARLOCK ||
owner->getClass() == CLASS_SHAMAN || // Fire Elemental
owner->getClass() == CLASS_DEATH_KNIGHT || // Risen Ghoul
owner->getClass() == CLASS_MAGE) // Water Elemental with glyph
petType = SUMMON_PET;
else if (m_owner->getClass() == CLASS_HUNTER)
else if (owner->getClass() == CLASS_HUNTER)
{
petType = HUNTER_PET;
m_unitTypeMask |= UNIT_MASK_HUNTER_PET;
}
else
sLog->outError("Unknown type pet %u is summoned by player class %u", GetEntry(), m_owner->getClass());
sLog->outError("Unknown type pet %u is summoned by player class %u", GetEntry(), owner->getClass());
}
uint32 creature_ID = (petType == HUNTER_PET) ? 1 : cinfo->Entry;
@@ -743,7 +743,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(petlevel*50));
uint32 attackTime = BASE_ATTACK_TIME;
if (m_owner->getClass() != CLASS_HUNTER && cinfo->BaseAttackTime >= 1000)
if (owner->getClass() != CLASS_HUNTER && cinfo->BaseAttackTime >= 1000)
attackTime = cinfo->BaseAttackTime;
SetAttackTime(BASE_ATTACK, attackTime);
@@ -796,8 +796,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
// remove elite bonuses included in DB values
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class);
// xinef: multiply base values by creature_template factors!
float factorHealth = m_owner->GetTypeId() == TYPEID_PLAYER ? std::min(1.0f, cinfo->ModHealth) : cinfo->ModHealth;
float factorMana = m_owner->GetTypeId() == TYPEID_PLAYER ? std::min(1.0f, cinfo->ModMana) : cinfo->ModMana;
float factorHealth = owner->GetTypeId() == TYPEID_PLAYER ? std::min(1.0f, cinfo->ModHealth) : cinfo->ModHealth;
float factorMana = owner->GetTypeId() == TYPEID_PLAYER ? std::min(1.0f, cinfo->ModMana) : cinfo->ModMana;
SetCreateHealth(std::max<uint32>(1, stats->BaseHealth[cinfo->expansion]*factorHealth));
SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, GetCreateHealth());
@@ -840,7 +840,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
case NPC_FELGUARD:
{
// xinef: Glyph of Felguard, so ugly im crying... no appropriate spell
if (AuraEffect* aurEff = m_owner->GetAuraEffectDummy(SPELL_GLYPH_OF_FELGUARD))
if (AuraEffect* aurEff = owner->GetAuraEffectDummy(SPELL_GLYPH_OF_FELGUARD))
SetModifierValue(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, 1.0f + float(aurEff->GetAmount() / 100.0f));
break;
@@ -972,7 +972,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
}
case NPC_MIRROR_IMAGE: // Mirror Image
{
SetDisplayId(m_owner->GetDisplayId());
SetDisplayId(owner->GetDisplayId());
if (!pInfo)
{
SetCreateMana(28 + 30*petlevel);
@@ -1007,8 +1007,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
AddAura(SPELL_HUNTER_PET_SCALING_04, this);
AddAura(SPELL_PET_AVOIDANCE, this);
SetCreateHealth(4 * petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - 30 - (petlevel / 4) + m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel - 30 + (petlevel / 4) + m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f));
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - 30 - (petlevel / 4) + owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel - 30 + (petlevel / 4) + owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f));
SetReactState(REACT_DEFENSIVE);
break;
}
@@ -1043,12 +1043,12 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
// xinef: fixes orc death knight command racial
if (m_owner->getRace() == RACE_ORC)
CastSpell(this, SPELL_ORC_RACIAL_COMMAND, true, NULL, NULL, m_owner->GetGUID());
if (owner->getRace() == RACE_ORC)
CastSpell(this, SPELL_ORC_RACIAL_COMMAND, true, NULL, NULL, owner->GetGUID());
// Avoidance, Night of the Dead
if (Aura *aur = AddAura(SPELL_NIGHT_OF_THE_DEAD_AVOIDANCE, this))
if (AuraEffect *aurEff = m_owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2718, 0))
if (AuraEffect *aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2718, 0))
if (aur->GetEffect(0))
aur->GetEffect(0)->SetAmount(-aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue());

View File

@@ -7794,7 +7794,7 @@ bool Player::IsOutdoorPvPActive()
void Player::DuelComplete(DuelCompleteType type)
{
// duel not requested
if (!duel)
if (!duel || !duel->opponent || !duel->initiator)
return;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
@@ -7845,7 +7845,7 @@ void Player::DuelComplete(DuelCompleteType type)
duel->opponent->CastSpell(duel->opponent, 52994, true);
// Honor points after duel (the winner) - ImpConfig
if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL) && duel->opponent)
if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL))
duel->opponent->RewardHonor(NULL, 1, amount);
break;
@@ -8089,10 +8089,6 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply);
break;
case ITEM_MOD_CRIT_TAKEN_RATING:
ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply);
ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply);
ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply);
break;
case ITEM_MOD_RESILIENCE_RATING:
ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply);
ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply);
@@ -10200,8 +10196,6 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c
slots[0] = EQUIPMENT_SLOT_BODY;
break;
case INVTYPE_CHEST:
slots[0] = EQUIPMENT_SLOT_CHEST;
break;
case INVTYPE_ROBE:
slots[0] = EQUIPMENT_SLOT_CHEST;
break;
@@ -10242,9 +10236,13 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c
break;
}
case INVTYPE_SHIELD:
case INVTYPE_WEAPONOFFHAND:
case INVTYPE_HOLDABLE:
slots[0] = EQUIPMENT_SLOT_OFFHAND;
break;
case INVTYPE_RANGED:
case INVTYPE_RANGEDRIGHT:
case INVTYPE_THROWN:
slots[0] = EQUIPMENT_SLOT_RANGED;
break;
case INVTYPE_2HWEAPON:
@@ -10278,18 +10276,6 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c
case INVTYPE_WEAPONMAINHAND:
slots[0] = EQUIPMENT_SLOT_MAINHAND;
break;
case INVTYPE_WEAPONOFFHAND:
slots[0] = EQUIPMENT_SLOT_OFFHAND;
break;
case INVTYPE_HOLDABLE:
slots[0] = EQUIPMENT_SLOT_OFFHAND;
break;
case INVTYPE_THROWN:
slots[0] = EQUIPMENT_SLOT_RANGED;
break;
case INVTYPE_RANGEDRIGHT:
slots[0] = EQUIPMENT_SLOT_RANGED;
break;
case INVTYPE_BAG:
slots[0] = INVENTORY_SLOT_BAG_START + 0;
slots[1] = INVENTORY_SLOT_BAG_START + 1;
@@ -12491,14 +12477,11 @@ void Player::SetAmmo(uint32 item)
return;
// check ammo
if (item)
InventoryResult msg = CanUseAmmo(item);
if (msg != EQUIP_ERR_OK)
{
InventoryResult msg = CanUseAmmo(item);
if (msg != EQUIP_ERR_OK)
{
SendEquipError(msg, NULL, NULL, item);
return;
}
SendEquipError(msg, NULL, NULL, item);
return;
}
SetUInt32Value(PLAYER_AMMO_ID, item);
@@ -13895,7 +13878,7 @@ void Player::SwapItem(uint16 src, uint16 dst)
}
}
if (!released && IsBagPos(dst) && pDstItem)
if (!released && IsBagPos(dst))
{
Bag* bag = pDstItem->ToBag();
for (uint32 i = 0; i < bag->GetBagSize(); ++i)

View File

@@ -227,7 +227,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
if (pFriend && (!AccountMgr::IsPlayerAccount(security) || ((pFriend->GetTeamId() == teamId || allowTwoSideWhoList) && pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList)) && pFriend->IsVisibleGloballyFor(player))
if ((!AccountMgr::IsPlayerAccount(security) || ((pFriend->GetTeamId() == teamId || allowTwoSideWhoList) && pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList)) && pFriend->IsVisibleGloballyFor(player))
{
friendInfo.Status = FRIEND_STATUS_ONLINE;
if (pFriend->isAFK())

View File

@@ -104,37 +104,37 @@ void Totem::UnSummon(uint32 msTime)
CombatStop();
RemoveAurasDueToSpell(GetSpell(), GetGUID());
Unit *m_owner = GetOwner();
Unit *owner = GetOwner();
// clear owner's totem slot
for (uint8 i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i)
{
if (m_owner->m_SummonSlot[i] == GetGUID())
if (owner->m_SummonSlot[i] == GetGUID())
{
m_owner->m_SummonSlot[i] = 0;
owner->m_SummonSlot[i] = 0;
break;
}
}
m_owner->RemoveAurasDueToSpell(GetSpell(), GetGUID());
owner->RemoveAurasDueToSpell(GetSpell(), GetGUID());
// Remove Sentry Totem Aura
if (GetEntry() == SENTRY_TOTEM_ENTRY)
m_owner->RemoveAurasDueToSpell(SENTRY_TOTEM_SPELLID);
owner->RemoveAurasDueToSpell(SENTRY_TOTEM_SPELLID);
//remove aura all party members too
if (Player* owner = m_owner->ToPlayer())
if (Player* player = owner->ToPlayer())
{
owner->SendAutoRepeatCancel(this);
player->SendAutoRepeatCancel(this);
if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(GetUInt32Value(UNIT_CREATED_BY_SPELL)))
owner->SendCooldownEvent(spell, 0, NULL, false);
player->SendCooldownEvent(spell, 0, NULL, false);
if (Group* group = owner->GetGroup())
if (Group* group = player->GetGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* target = itr->GetSource();
if (target && target->IsInMap(owner) && group->SameSubGroup(owner, target))
if (target && target->IsInMap(player) && group->SameSubGroup(player, target))
target->RemoveAurasDueToSpell(GetSpell(), GetGUID());
}
}

View File

@@ -333,8 +333,6 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f;
break;
case CLASS_ROGUE:
val2 = level + GetStat(STAT_AGILITY) - 10.0f;
break;
case CLASS_WARRIOR:
val2 = level + GetStat(STAT_AGILITY) - 10.0f;
break;
@@ -356,22 +354,14 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
{
switch (getClass())
{
case CLASS_PALADIN:
case CLASS_DEATH_KNIGHT:
case CLASS_WARRIOR:
val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
break;
case CLASS_PALADIN:
val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
break;
case CLASS_DEATH_KNIGHT:
val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
break;
case CLASS_ROGUE:
val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
break;
case CLASS_HUNTER:
val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
break;
case CLASS_SHAMAN:
case CLASS_ROGUE:
val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
break;
case CLASS_DRUID:
@@ -457,11 +447,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
break;
}
case CLASS_MAGE:
val2 = GetStat(STAT_STRENGTH) - 10.0f;
break;
case CLASS_PRIEST:
val2 = GetStat(STAT_STRENGTH) - 10.0f;
break;
case CLASS_WARLOCK:
val2 = GetStat(STAT_STRENGTH) - 10.0f;
break;

View File

@@ -1297,8 +1297,6 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam
damageInfo->TargetState = VICTIMSTATE_IS_IMMUNE;
damageInfo->procEx |= PROC_EX_IMMUNE;
damageInfo->damage = 0;
damageInfo->cleanDamage = 0;
return;
}
@@ -3448,7 +3446,7 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const
// special handling for ICC (map 631), for non-flying pets in Gunship Battle, for trash npcs this is done via CanAIAttack
if (IS_PLAYER_GUID(c->GetOwnerGUID()) && !c->CanFly())
{
if ((c->GetTransport() && !this->GetTransport()) || (!c->GetTransport() && this->GetTransport()))
if (c->GetTransport() != this->GetTransport())
return false;
if (this->GetTransport())
{
@@ -6780,7 +6778,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
case 70664:
{
// xinef: proc only from normal Rejuvenation, and proc rejuvenation
if (!victim || procSpell->SpellIconID != 64)
if (!victim || !procSpell || procSpell->SpellIconID != 64)
return false;
Player* caster = ToPlayer();
@@ -6989,13 +6987,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
basepoints0 = int32(damage);
triggered_spell_id = procSpell->IsRankOf(sSpellMgr->GetSpellInfo(635)) ? 53652 : 53654;
if (triggered_spell_id && beaconTarget)
{
victim->CastCustomSpell(beaconTarget, triggered_spell_id, &basepoints0, NULL, NULL, true, 0, triggeredByAura, victim->GetGUID());
return true;
}
return false;
victim->CastCustomSpell(beaconTarget, triggered_spell_id, &basepoints0, NULL, NULL, true, 0, triggeredByAura, victim->GetGUID());
return true;
}
// Judgements of the Wise
if (dummySpell->SpellIconID == 3017)
@@ -7569,6 +7562,9 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Improved Water Shield
if (dummySpell->SpellIconID == 2287)
{
if (!procSpell)
return false;
// Default chance for Healing Wave and Riptide
float chance = (float)triggeredByAura->GetAmount();
@@ -8627,6 +8623,9 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
case 15337: // Improved Spirit Tap (Rank 1)
case 15338: // Improved Spirit Tap (Rank 2)
{
if (!procSpell)
return false;
if (procSpell->SpellFamilyFlags[0] & 0x800000)
if ((procSpell->Id != 58381) || !roll_chance_i(50))
return false;
@@ -8982,7 +8981,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
// try detect target manually if not set
if (target == NULL)
target = !(procFlags & (PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS)) && triggerEntry && triggerEntry->IsPositive() ? this : victim;
target = !(procFlags & (PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS)) && triggerEntry->IsPositive() ? this : victim;
if (cooldown)
{
@@ -15277,10 +15276,6 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
takeCharges = true;
break;
case SPELL_AURA_MECHANIC_IMMUNITY:
// Compare mechanic
if (procSpell && procSpell->Mechanic == uint32(triggeredByAura->GetMiscValue()))
takeCharges = true;
break;
case SPELL_AURA_MOD_MECHANIC_RESISTANCE:
// Compare mechanic
if (procSpell && procSpell->Mechanic == uint32(triggeredByAura->GetMiscValue()))
@@ -15815,7 +15810,7 @@ uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectTyp
}
// Combined Spells with Both Over Time and Direct Damage
if (overTime > 0 && CastingTime > 0 && DirectDamage)
if (overTime > 0 && DirectDamage)
{
// mainly for DoTs which are 3500 here otherwise
uint32 OriginalCastTime = spellProto->CalcCastTime();
@@ -17264,7 +17259,7 @@ void Unit::RemoveCharmedBy(Unit* charmer)
if (Creature* creature = ToCreature())
{
// Vehicle should not attack its passenger after he exists the seat
if (type != CHARM_TYPE_VEHICLE && charmer && charmer->IsAlive() && !charmer->IsFriendlyTo(creature))
if (type != CHARM_TYPE_VEHICLE && charmer->IsAlive() && !charmer->IsFriendlyTo(creature))
if (Attack(charmer, true))
GetMotionMaster()->MoveChase(charmer);
@@ -18132,7 +18127,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
{
uint8 i = 0;
bool valid = false;
while (i < MAX_SPELL_EFFECTS && !valid)
while (i < MAX_SPELL_EFFECTS)
{
if (spellEntry->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
{

View File

@@ -365,7 +365,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
}
}
if (!_me->IsInWorld() || _me->IsDuringRemoveFromWorld())
if (!_me || !_me->IsInWorld() || _me->IsDuringRemoveFromWorld())
return false;
// Xinef: moved from unit.cpp, if aura passes seatId == -1 (choose automaticly) we wont get appropriate flags