fix(Core): Crashfix. (#10744)

Fixes #10601
Fixes #10733
This commit is contained in:
UltraNix
2022-02-22 17:15:50 +01:00
committed by GitHub
parent f21f04c761
commit 4509a36e91
2 changed files with 29 additions and 10 deletions

View File

@@ -2197,7 +2197,12 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
summon->SetHomePosition(pos);
summon->InitStats(duration);
AddToMap(summon->ToCreature(), summon->GetOwnerGUID().IsPlayer() || (summoner && summoner->GetTransport()));
if (!AddToMap(summon->ToCreature(), summon->GetOwnerGUID().IsPlayer() || (summoner && summoner->GetTransport())))
{
delete summon;
return nullptr;
}
summon->InitSummon();
//ObjectAccessor::UpdateObjectVisibility(summon);

View File

@@ -857,16 +857,30 @@ public:
{
PreventHitEffect(effIndex);
uint32 entry = GetSpellInfo()->Effects[effIndex].MiscValue;
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(GetSpellInfo()->Effects[effIndex].MiscValueB);
int32 duration = GetSpellInfo()->GetDuration();
if (!GetOriginalCaster() || !properties)
return;
if (TempSummon* summon = GetCaster()->GetMap()->SummonCreature(entry, *GetHitDest(), properties, duration, GetOriginalCaster(), GetSpellInfo()->Id))
if (Unit* caster = GetCaster())
{
summon->SetCreatorGUID(GetOriginalCaster()->GetGUID());
summon->HandleSpellClick(GetCaster());
Unit* originalCaster = GetOriginalCaster();
if (!originalCaster)
{
return;
}
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(GetSpellInfo()->Effects[effIndex].MiscValueB);
if (!properties)
{
return;
}
uint32 entry = GetSpellInfo()->Effects[effIndex].MiscValue;
int32 duration = GetSpellInfo()->GetDuration();
if (TempSummon* summon = caster->GetMap()->SummonCreature(entry, *GetHitDest(), properties, duration, originalCaster, GetSpellInfo()->Id))
{
if (summon->IsInMap(caster))
{
summon->SetCreatorGUID(originalCaster->GetGUID());
summon->HandleSpellClick(caster);
}
}
}
}