V547 Expression 'm_deathState != CORPSE' is always false. Creature.cpp 668

V595 The 'itemproto' pointer was utilized before it was verified against nullptr. Check lines: 590, 598. LootMgr.cpp 590
V595 The 'm_WorldMap' pointer was utilized before it was verified against nullptr. Check lines: 2006, 2030. Creature.cpp 2006
V595 The 'unitOwner' pointer was utilized before it was verified against nullptr. Check lines: 429, 459. Summon.cpp 429
This commit is contained in:
Zyres
2023-07-09 00:11:28 +02:00
parent e0573bfae9
commit aee0d46dc3
3 changed files with 35 additions and 29 deletions

View File

@@ -587,7 +587,11 @@ LootItem::LootItem(LootStoreItem const& li)
itemId = li.itemId;
itemproto = li.itemproto;
count = Util::getRandomUInt(li.mincount, li.maxcount);
iRandomProperty = sLootMgr.GetRandomProperties(itemproto);
if (iRandomProperty = sLootMgr.GetRandomProperties(itemproto))
is_ffa = itemproto->Flags & ITEM_FLAG_FREE_FOR_ALL;
else
is_ffa = false;
iRandomSuffix = sLootMgr.GetRandomSuffix(itemproto);
roll = nullptr;
@@ -595,7 +599,6 @@ LootItem::LootItem(LootStoreItem const& li)
is_passed = false;
is_looted = false;
is_blocked = false;
is_ffa = itemproto && itemproto->Flags & ITEM_FLAG_FREE_FOR_ALL;
is_underthreshold = false;
needs_quest = li.needs_quest;
}

View File

@@ -661,17 +661,12 @@ void Creature::Update(unsigned long time_passed)
{
if (m_respawnTime <= now)
respawn();
}
break;
} break;
case CORPSE:
{
if (m_deathState != CORPSE)
break;
if (m_corpseRemoveTime <= now)
OnRemoveCorpse();
}
break;
} break;
default:
break;
}
@@ -1993,17 +1988,16 @@ void Creature::OnPushToWorld()
if (m_spawn)
{
if (m_spawn->channel_target_creature)
{
sEventMgr.AddEvent(this, &Creature::ChannelLinkUpCreature, m_spawn->channel_target_creature, EVENT_CREATURE_CHANNEL_LINKUP, 1000, 5, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); // only 5 attempts
}
if (m_spawn->channel_target_go)
{
sEventMgr.AddEvent(this, &Creature::ChannelLinkUpGO, m_spawn->channel_target_go, EVENT_CREATURE_CHANNEL_LINKUP, 1000, 5, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); // only 5 attempts
}
}
m_aiInterface->m_is_in_instance = (!m_WorldMap->getBaseMap()->getMapInfo()->isNonInstanceMap()) ? true : false;
if (m_WorldMap)
m_aiInterface->m_is_in_instance = (!m_WorldMap->getBaseMap()->getMapInfo()->isNonInstanceMap()) ? true : false;
else
m_aiInterface->m_is_in_instance = false;
if (this->HasItems())
{
@@ -2022,9 +2016,7 @@ void Creature::OnPushToWorld()
if (mEvent != nullptr)
{
if (mEvent->mEventScript != nullptr)
{
mEvent->mEventScript->OnCreaturePushToWorld(mEvent, this);
}
}
if (m_WorldMap && m_WorldMap->getScript())

View File

@@ -417,22 +417,30 @@ void TotemSummon::load(CreatureProperties const* creatureProperties, Unit* unitO
{
Summon::load(creatureProperties, unitOwner, position, duration, spellId);
const MySQLStructure::TotemDisplayIds* displayIds = nullptr;
// Summoner
if (unitOwner)
{
setCreatedByGuid(unitOwner->getGuid());
setSummonedByGuid(unitOwner->getGuid());
setFaction(unitOwner->getFactionTemplate());
displayIds = sMySQLStore.getTotemDisplayId(unitOwner->getRace(), creature_properties->Male_DisplayID);
setLevel(unitOwner->getLevel());
}
else
{
setLevel(1);
}
uint32_t displayId;
const auto displayIds = sMySQLStore.getTotemDisplayId(unitOwner->getRace(), creature_properties->Male_DisplayID);
if (displayIds != nullptr)
displayId = displayIds->race_specific_id;
else
displayId = creature_properties->Male_DisplayID;
setLevel(unitOwner->getLevel());
setRace(0);
setClass(1); // Creature class warrior
setGender(GENDER_NONE);
@@ -446,21 +454,24 @@ void TotemSummon::load(CreatureProperties const* creatureProperties, Unit* unitO
setModCastSpeed(1.0f);
setDynamicFlags(0);
for (uint8_t school = 0; school < TOTAL_SPELL_SCHOOLS; school++)
if (unitOwner)
{
ModDamageDone[school] = unitOwner->GetDamageDoneMod(school);
m_healDoneMod[school] = unitOwner->m_healDoneMod[school];
}
for (uint8_t school = 0; school < TOTAL_SPELL_SCHOOLS; school++)
{
ModDamageDone[school] = unitOwner->GetDamageDoneMod(school);
m_healDoneMod[school] = unitOwner->m_healDoneMod[school];
}
m_aiInterface->Init(this, unitOwner);
m_aiInterface->Init(this, unitOwner);
setAItoUse(false);
setAItoUse(false);
if (unitOwner != nullptr && unitOwner->isPlayer())
{
uint32_t slot = m_Properties->Slot;
if (slot >= SUMMON_SLOT_TOTEM_FIRE && slot < SUMMON_SLOT_MINIPET)
dynamic_cast<Player*>(unitOwner)->sendTotemCreatedPacket(static_cast<uint8_t>(slot - SUMMON_SLOT_TOTEM_FIRE), getGuid(), getTimeLeft(), getCreatedBySpellId());
if (unitOwner->isPlayer())
{
uint32_t slot = m_Properties->Slot;
if (slot >= SUMMON_SLOT_TOTEM_FIRE && slot < SUMMON_SLOT_MINIPET)
dynamic_cast<Player*>(unitOwner)->sendTotemCreatedPacket(static_cast<uint8_t>(slot - SUMMON_SLOT_TOTEM_FIRE), getGuid(), getTimeLeft(), getCreatedBySpellId());
}
}
}