From 1f5ff06b9123ae119fbbce8130714e35c2f32636 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 16 Oct 2023 23:41:52 +0200 Subject: [PATCH] GC stuff plus one leftover commented out fragment. --- source/games/blood/src/blood.cpp | 6 +++--- source/games/blood/src/loadsave.cpp | 1 + source/games/blood/src/nnextcdud.cpp | 14 ++++++++++++++ source/games/blood/src/nnextcdud.h | 10 ++++------ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 77b47ee36..d7402014a 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -59,8 +59,9 @@ IMPLEMENT_CLASS(DBloodActor, false, true) IMPLEMENT_POINTERS_START(DBloodActor) #ifdef NOONE_EXTENSIONS IMPLEMENT_POINTER(prevmarker) -IMPLEMENT_POINTER(ownerActor) +IMPLEMENT_POINTER(customDude) #endif +IMPLEMENT_POINTER(ownerActor) IMPLEMENT_POINTER(xspr.burnSource) IMPLEMENT_POINTER(xspr.target) IMPLEMENT_POINTERS_END @@ -105,8 +106,7 @@ size_t DBloodActor::PropagateMark() if (hit.ceilhit.type == kHitSprite) GC::Mark(hit.ceilhit.hitActor); if (hit.florhit.type == kHitSprite) GC::Mark(hit.florhit.hitActor); #ifdef NOONE_EXTENSIONS - condition[0].Mark(); - condition[1].Mark(); + for(auto& cond : condition) cond.Mark(); #endif return Super::PropagateMark(); } diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index 1f2f16085..89e9bf117 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -460,6 +460,7 @@ void DBloodActor::Serialize(FSerializer& arc) { arc//("spritemass", spriteMass) // should always be cached and not written out. ("prevmarker", prevmarker) + ("customdude", customDude) .Array("conditions", condition, 4); } diff --git a/source/games/blood/src/nnextcdud.cpp b/source/games/blood/src/nnextcdud.cpp index e5efe602e..e7f536b0d 100644 --- a/source/games/blood/src/nnextcdud.cpp +++ b/source/games/blood/src/nnextcdud.cpp @@ -4452,6 +4452,20 @@ size_t DCustomDude::PropagateMark() return pSlaves.Size() + Super::PropagateMark(); } +void DCustomDude::OnDestroy() +{ + // free all allocations now and sever the link to the dude actor. + pSpr = nullptr; + pSlaves.Reset(); + for (auto& ef : effects) + { + ef.pAnims.Reset(); + ef.pFrames.Reset(); + ef.pStates.Reset(); + } + Super::Destroy(); +} + END_BLD_NS #endif \ No newline at end of file diff --git a/source/games/blood/src/nnextcdud.h b/source/games/blood/src/nnextcdud.h index 0579b85d7..45163e81c 100644 --- a/source/games/blood/src/nnextcdud.h +++ b/source/games/blood/src/nnextcdud.h @@ -983,12 +983,9 @@ class CUSTOMDUDE_EFFECT } else if (nID >= kCudeFXEffectCallbackBase) { -#pragma message("Fix " __FUNCTION__ " for custom callbacks") -#if 0 - nID = gCdudeCustomCallback[nID - kCudeFXEffectCallbackBase]; - evKill(pSpr->index, OBJ_SPRITE, (CALLBACK_ID)nID); - evPost(pSpr->index, OBJ_SPRITE, 0, (CALLBACK_ID)nID); -#endif + auto func = *gCdudeCustomCallback[nID - kCudeFXEffectCallbackBase]; + evKillActor(pSpr, func); + evPostActor(pSpr, 0, func); } else { @@ -1195,6 +1192,7 @@ class DCustomDude : public DObject HAS_OBJECT_POINTERS size_t PropagateMark() override; + void OnDestroy(); // Note: we will likely have to write out the entire shit here to make this savegame robust... public: