Skip to content

Commit

Permalink
Fix(?) an issue that causes debris anims with AttachedSystem to expir…
Browse files Browse the repository at this point in the history
…e immediately
  • Loading branch information
Starkku committed Feb 26, 2024
1 parent db55d1e commit 884765e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Ext/Anim/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ void AnimExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)

void AnimExt::ExtData::InitializeConstants()
{
CreateAttachedSystem();
// Something about creating this in constructor messes with debris anims, so it has to be done for them later.
if (!this->OwnerObject()->HasExtras)
CreateAttachedSystem();
}

// =============================
Expand Down
14 changes: 12 additions & 2 deletions src/Ext/Anim/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ DEFINE_HOOK(0x4242E1, AnimClass_AI_TrailerAnim, 0x5)
return SkipGameCode;
}

// Deferred creation of attached particle systems for debris anims.
DEFINE_HOOK(0x423939, AnimClass_BounceAI_AttachedSystem, 0x6)
{
GET(AnimClass*, pThis, EBP);

AnimExt::ExtMap.Find(pThis)->CreateAttachedSystem();

return 0;
}

DEFINE_HOOK(0x423CC7, AnimClass_AI_HasExtras_Expired, 0x6)
{
enum { SkipGameCode = 0x423EFD };
Expand Down Expand Up @@ -186,8 +196,8 @@ DEFINE_HOOK(0x422CAB, AnimClass_DrawIt_XDrawOffset, 0x5)
GET(AnimClass* const, pThis, ECX);
GET_STACK(Point2D*, pCoord, STACK_OFFSET(0x100, 0x4));

if (auto const pThisTypeExt = AnimTypeExt::ExtMap.Find(pThis->Type))
pCoord->X += pThisTypeExt->XDrawOffset;
if (auto const pTypeExt = AnimTypeExt::ExtMap.Find(pThis->Type))
pCoord->X += pTypeExt->XDrawOffset;

return 0;
}
Expand Down

0 comments on commit 884765e

Please sign in to comment.