From ce922225e7835dc3bd581ef3ec496e9f868b7020 Mon Sep 17 00:00:00 2001 From: Boondorl Date: Tue, 1 Apr 2025 15:20:00 -0400 Subject: [PATCH] Added OnLoad virtual Allows for things to be reinitialized where needed for Thinkers. Moved hidden state of items over to OnLoad. --- src/playsim/dthinker.cpp | 14 ++++++++++++-- src/playsim/dthinker.h | 1 + src/playsim/p_mobj.cpp | 1 - .../static/zscript/actors/inventory/inventory.zs | 10 ++++++++++ wadsrc/static/zscript/doombase.zs | 1 + 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 51cf3a670..47efc9c0d 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -355,12 +355,12 @@ void FThinkerCollection::SerializeThinkers(FSerializer &arc, bool hubLoad) else if (thinker->ObjectFlags & OF_JustSpawned) { FreshThinkers[i].AddTail(thinker); - thinker->PostSerialize(); + thinker->CallPostSerialize(); } else { Thinkers[i].AddTail(thinker); - thinker->PostSerialize(); + thinker->CallPostSerialize(); } } } @@ -773,6 +773,16 @@ void DThinker::PostSerialize() { } +void DThinker::CallPostSerialize() +{ + PostSerialize(); + IFOVERRIDENVIRTUALPTRNAME(this, NAME_Thinker, OnLoad) + { + VMValue params[] = { this }; + VMCall(func, params, 1, nullptr, 0); + } +} + //========================================================================== // // diff --git a/src/playsim/dthinker.h b/src/playsim/dthinker.h index 78dcd1520..03e9ecc91 100644 --- a/src/playsim/dthinker.h +++ b/src/playsim/dthinker.h @@ -104,6 +104,7 @@ public: virtual void PostBeginPlay (); // Called just before the first tick virtual void CallPostBeginPlay(); // different in actor. virtual void PostSerialize(); + void CallPostSerialize(); void Serialize(FSerializer &arc) override; size_t PropagateMark(); diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 4149c8da2..3db0e3506 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -217,7 +217,6 @@ void AActor::Serialize(FSerializer &arc) A("angles", Angles) A("frame", frame) A("scale", Scale) - A("nolocalrender", NoLocalRender) // Note: This will probably be removed later since a better solution is needed A("renderstyle", RenderStyle) A("renderflags", renderflags) A("renderflags2", renderflags2) diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index 607c4f7c4..40a89cb08 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -85,6 +85,11 @@ class Inventory : Actor Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG"; } + + override void OnLoad() + { + UpdateLocalPickupStatus(); + } //native override void Tick(); @@ -1113,6 +1118,11 @@ class Inventory : Actor return pickedUp[client.PlayerNumber()]; } + void UpdateLocalPickupStatus() + { + DisableLocalRendering(consoleplayer, pickedUp[consoleplayer]); + } + // When items are dropped, clear their local pick ups. void ClearLocalPickUps() { diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index c4582c15e..4c8295cec 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -187,6 +187,7 @@ class Thinker : Object native play virtual native void Tick(); virtual native void PostBeginPlay(); + virtual void OnLoad() {} native void ChangeStatNum(int stat); static clearscope int Tics2Seconds(int tics)