From 4509a36e9180f83a420b552c785fe53f743c7ae3 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:15:50 +0100 Subject: [PATCH] fix(Core): Crashfix. (#10744) Fixes #10601 Fixes #10733 --- src/server/game/Entities/Object/Object.cpp | 7 +++- .../scripts/Northrend/zone_wintergrasp.cpp | 32 +++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index fe7dc4acb..55b89495a 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -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); diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index f602368bc..a708a8ec8 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -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); + } + } } }