From 13e6718153c8453848edd3135035b53f1fd340d4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 13 Dec 2022 10:36:45 +0100 Subject: [PATCH] - added mapSpawned member to DDukeActor Duke uses the owner a lot to check if an actor was spawned at map start or in-game, but that depends a lot on stale pointers being maintained, which our garbage collected system does not allow. So this field now serves as a more reliable stand-in for these cases. No actual changes yet. --- source/games/duke/src/premap_d.cpp | 1 + source/games/duke/src/premap_r.cpp | 1 + source/games/duke/src/savegame.cpp | 1 + source/games/duke/src/types.h | 1 + source/games/duke/src/vmexports.cpp | 1 + wadsrc/static/zscript/games/duke/dukeactor.zs | 1 + 6 files changed, 6 insertions(+) diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 2c63b5b4d..3e4f9c7f2 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -259,6 +259,7 @@ void cacheit_d(void) //--------------------------------------------------------------------------- void spriteinit_d(DDukeActor* actor, TArray& actors) { + actor->mapSpawned = true; bool res = initspriteforspawn(actor); if (res) spawninit_d(nullptr, actor, &actors); } diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 24c882dda..e73a8cc94 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -399,6 +399,7 @@ void cacheit_r(void) void spriteinit_r(DDukeActor* actor, TArray& actors) { + actor->mapSpawned = true; bool res = initspriteforspawn(actor); if (res) spawninit_r(nullptr, actor, &actors); } diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index aa9e221a0..085ef4d9b 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -270,6 +270,7 @@ void DDukeActor::Serialize(FSerializer& arc) ("actorstayput", actorstayput) ("basepicnum", basepicnum) ("timetosleep", timetosleep) + ("mapspawned", mapSpawned) ("floorz", floorz) ("ceilingz", ceilingz) ("lastvx", ovel.X) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 9856f1351..e5c05852f 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -47,6 +47,7 @@ public: short attackertype, hitextra; short tempval, basepicnum; unsigned short timetosleep; + bool mapSpawned; DVector2 ovel; DAngle hitang; double floorz, ceilingz; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 73aec18e5..af8f63f6a 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -224,6 +224,7 @@ DEFINE_FIELD(DDukeActor, hitextra) DEFINE_FIELD(DDukeActor, movflag) DEFINE_FIELD(DDukeActor, tempval) DEFINE_FIELD(DDukeActor, timetosleep) +DEFINE_FIELD(DDukeActor, mapSpawned) DEFINE_FIELD(DDukeActor, floorz) DEFINE_FIELD(DDukeActor, ceilingz) DEFINE_FIELD(DDukeActor, saved_ammo) diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 8cb51f034..4c640bca1 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -125,6 +125,7 @@ class DukeActor : CoreActor native native int16 /*attackertype, hitang,*/ hitextra, movflag; native int16 tempval; /*, dispicnum;*/ native int16 timetosleep; + native bool mapSpawned; native double floorz, ceilingz; native int saved_ammo; native int palvals;