Skip to content

Commit 43252c7

Browse files
authored
Fix potential crash originating from HookSpellCast (#822)
1 parent b6c8982 commit 43252c7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Code/client/Games/Skyrim/Magic/ActorMagicCaster.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ void TP_MAKE_THISCALL(HookSpellCast, ActorMagicCaster, bool abSuccess, int32_t a
1818
{
1919
spdlog::debug("HookSpellCast, abSuccess: {}, auiTargetCount: {}, apSpell: {:X}", abSuccess, auiTargetCount, (uint64_t)apSpell);
2020

21-
// TODO(cosideci): why is this here?
21+
// Note: these if guards is how the game does it too
22+
if (!apThis->pCasterActor)
23+
return;
2224
if (!abSuccess)
2325
return;
26+
if (!apSpell && !apThis->pCurrentSpell)
27+
return;
2428

2529
if (apThis->pCasterActor->GetExtension()->IsRemote())
2630
return;

Code/client/Games/Skyrim/Magic/ActorMagicCaster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ struct ActorMagicCaster : MagicCaster
2828
uint32_t uiFlags;
2929
};
3030

31+
static_assert(offsetof(ActorMagicCaster, pCasterActor) == 0xB8);
32+
static_assert(offsetof(ActorMagicCaster, pMagicNode) == 0xC0);
3133
static_assert(sizeof(ActorMagicCaster) == 0x100);

0 commit comments

Comments
 (0)