mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-02 02:23:49 +00:00
chore(Core/Misc): nullptr cleanup (#11467)
This commit is contained in:
@@ -728,7 +728,7 @@ void Item::AddToUpdateQueueOf(Player* player)
|
||||
if (IsInUpdateQueue())
|
||||
return;
|
||||
|
||||
ASSERT(player != nullptr);
|
||||
ASSERT(player);
|
||||
|
||||
if (player->GetGUID() != GetOwnerGUID())
|
||||
{
|
||||
@@ -748,7 +748,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
|
||||
if (!IsInUpdateQueue())
|
||||
return;
|
||||
|
||||
ASSERT(player != nullptr);
|
||||
ASSERT(player);
|
||||
|
||||
if (player->GetGUID() != GetOwnerGUID())
|
||||
{
|
||||
|
||||
@@ -2266,7 +2266,7 @@ bool Player::IsGroupVisibleFor(Player const* p) const
|
||||
|
||||
bool Player::IsInSameGroupWith(Player const* p) const
|
||||
{
|
||||
return p == this || (GetGroup() != nullptr &&
|
||||
return p == this || (GetGroup() &&
|
||||
GetGroup() == p->GetGroup() &&
|
||||
GetGroup()->SameSubGroup(this, p));
|
||||
}
|
||||
@@ -3739,7 +3739,7 @@ void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
{
|
||||
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
||||
{
|
||||
if (m_items[i] == nullptr)
|
||||
if (!m_items[i])
|
||||
continue;
|
||||
|
||||
m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
|
||||
@@ -3747,14 +3747,14 @@ void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
|
||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (m_items[i] == nullptr)
|
||||
if (!m_items[i])
|
||||
continue;
|
||||
|
||||
m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
|
||||
}
|
||||
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||
{
|
||||
if (m_items[i] == nullptr)
|
||||
if (!m_items[i])
|
||||
continue;
|
||||
|
||||
m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
|
||||
@@ -3770,7 +3770,7 @@ void Player::DestroyForPlayer(Player* target, bool onDeath) const
|
||||
|
||||
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) // xinef: previously INVENTORY_SLOT_BAG_END
|
||||
{
|
||||
if (m_items[i] == nullptr)
|
||||
if (!m_items[i])
|
||||
continue;
|
||||
|
||||
m_items[i]->DestroyForPlayer(target);
|
||||
@@ -3780,14 +3780,14 @@ void Player::DestroyForPlayer(Player* target, bool onDeath) const
|
||||
{
|
||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (m_items[i] == nullptr)
|
||||
if (!m_items[i])
|
||||
continue;
|
||||
|
||||
m_items[i]->DestroyForPlayer(target);
|
||||
}
|
||||
for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||
{
|
||||
if (m_items[i] == nullptr)
|
||||
if (!m_items[i])
|
||||
continue;
|
||||
|
||||
m_items[i]->DestroyForPlayer(target);
|
||||
@@ -4976,7 +4976,7 @@ float Player::GetMeleeCritFromAgility()
|
||||
|
||||
GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass - 1);
|
||||
GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
|
||||
if (critBase == nullptr || critRatio == nullptr)
|
||||
if (!critBase || !critRatio)
|
||||
return 0.0f;
|
||||
|
||||
float crit = critBase->base + GetStat(STAT_AGILITY) * critRatio->ratio;
|
||||
@@ -5024,7 +5024,7 @@ void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing)
|
||||
|
||||
// Dodge per agility is proportional to crit per agility, which is available from DBC files
|
||||
GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
|
||||
if (dodgeRatio == nullptr || pclass > MAX_CLASSES)
|
||||
if (!dodgeRatio || pclass > MAX_CLASSES)
|
||||
return;
|
||||
|
||||
// TODO: research if talents/effects that increase total agility by x% should increase non-diminishing part
|
||||
@@ -5046,7 +5046,7 @@ float Player::GetSpellCritFromIntellect()
|
||||
|
||||
GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass - 1);
|
||||
GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
|
||||
if (critBase == nullptr || critRatio == nullptr)
|
||||
if (!critBase || !critRatio)
|
||||
return 0.0f;
|
||||
|
||||
float crit = critBase->base + GetStat(STAT_INTELLECT) * critRatio->ratio;
|
||||
@@ -5098,7 +5098,7 @@ float Player::OCTRegenHPPerSpirit()
|
||||
|
||||
GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
|
||||
GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
|
||||
if (baseRatio == nullptr || moreRatio == nullptr)
|
||||
if (!baseRatio || !moreRatio)
|
||||
return 0.0f;
|
||||
|
||||
// Formula from PaperDollFrame script
|
||||
@@ -5121,7 +5121,7 @@ float Player::OCTRegenMPPerSpirit()
|
||||
|
||||
// GtOCTRegenMPEntry const* baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
|
||||
GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1);
|
||||
if (moreRatio == nullptr)
|
||||
if (!moreRatio)
|
||||
return 0.0f;
|
||||
|
||||
// Formula get from PaperDollFrame script
|
||||
@@ -6043,7 +6043,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
|
||||
}
|
||||
}
|
||||
|
||||
if (uVictim != nullptr)
|
||||
if (uVictim)
|
||||
{
|
||||
if (groupsize > 1)
|
||||
honor_f /= groupsize;
|
||||
@@ -9779,7 +9779,7 @@ void Player::DropModCharge(SpellModifier* mod, Spell* spell)
|
||||
|
||||
void Player::SetSpellModTakingSpell(Spell* spell, bool apply)
|
||||
{
|
||||
if (apply && m_spellModTakingSpell != nullptr)
|
||||
if (apply && m_spellModTakingSpell)
|
||||
{
|
||||
LOG_INFO("misc", "Player::SetSpellModTakingSpell (A1) - {}, {}", spell->m_spellInfo->Id, m_spellModTakingSpell->m_spellInfo->Id);
|
||||
return;
|
||||
@@ -11216,7 +11216,7 @@ void Player::SetSelection(ObjectGuid guid)
|
||||
|
||||
void Player::SetGroup(Group* group, int8 subgroup)
|
||||
{
|
||||
if (group == nullptr)
|
||||
if (!group)
|
||||
m_group.unlink();
|
||||
else
|
||||
{
|
||||
@@ -12750,7 +12750,7 @@ void Player::RemoveFromBattlegroundOrBattlefieldRaid()
|
||||
|
||||
void Player::SetOriginalGroup(Group* group, int8 subgroup)
|
||||
{
|
||||
if (group == nullptr)
|
||||
if (!group)
|
||||
m_originalGroup.unlink();
|
||||
else
|
||||
{
|
||||
@@ -13164,7 +13164,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
|
||||
// Xinef: exploit protection, dont allow to loot normal items if player is not master loot and not below loot threshold
|
||||
// Xinef: only quest, ffa and conditioned items
|
||||
if (!item->is_underthreshold && loot->roundRobinPlayer && !GetLootGUID().IsItem() && GetGroup() && GetGroup()->GetLootMethod() == MASTER_LOOT && GetGUID() != GetGroup()->GetMasterLooterGuid())
|
||||
if (qitem == nullptr && ffaitem == nullptr && conditem == nullptr)
|
||||
if (!qitem && !ffaitem && !conditem)
|
||||
{
|
||||
SendLootRelease(GetLootGUID());
|
||||
return;
|
||||
|
||||
@@ -7331,7 +7331,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction trans)
|
||||
if (item->GetState() != ITEM_REMOVED)
|
||||
{
|
||||
Item* test = GetItemByPos(item->GetBagSlot(), item->GetSlot());
|
||||
if (test == nullptr)
|
||||
if (!test)
|
||||
{
|
||||
ObjectGuid::LowType bagTestGUID = 0;
|
||||
if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot()))
|
||||
|
||||
@@ -8943,7 +8943,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
|
||||
// All ok. Check current trigger spell
|
||||
SpellInfo const* triggerEntry = sSpellMgr->GetSpellInfo(trigger_spell_id);
|
||||
if (triggerEntry == nullptr)
|
||||
if (!triggerEntry)
|
||||
{
|
||||
// Don't cast unknown spell
|
||||
LOG_ERROR("entities.unit", "Unit::HandleProcTriggerSpell: Spell {} (effIndex: {}) has unknown TriggerSpell {}. Unhandled custom case?", auraSpellInfo->Id, triggeredByAura->GetEffIndex(), trigger_spell_id);
|
||||
@@ -9386,7 +9386,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
}
|
||||
|
||||
// try detect target manually if not set
|
||||
if (target == nullptr)
|
||||
if (!target)
|
||||
target = !(procFlags & (PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS)) && triggerEntry->IsPositive() ? this : victim;
|
||||
|
||||
if (cooldown)
|
||||
@@ -15761,7 +15761,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
continue;
|
||||
|
||||
// If not trigger by default and spellProcEvent == nullptr - skip
|
||||
if (!isTriggerAura[aurEff->GetAuraType()] && triggerData.spellProcEvent == nullptr)
|
||||
if (!isTriggerAura[aurEff->GetAuraType()] && !triggerData.spellProcEvent)
|
||||
continue;
|
||||
|
||||
switch (aurEff->GetAuraType())
|
||||
|
||||
Reference in New Issue
Block a user