diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index d753a17dfc..d2b0ffd906 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 a46aadae01..daa266909f 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 e5efe602ed..e7f536b0da 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 0579b85d74..45163e81c2 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: