From 807df33e1a6e6a5af3d28f360b9bf595c69a8d01 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Dec 2018 20:57:03 +0100 Subject: [PATCH] - scriptified AInventory::Tick. This was the last bit of code standing in the way of making AInventory a fully scripted class. All that's left to sort out is some variable accesses - the vast majority of them in SBARINFO. --- src/g_inventory/a_pickups.cpp | 42 ------------------- src/g_inventory/a_pickups.h | 2 +- src/namedef.h | 1 + wadsrc/static/zscript/inventory/inventory.txt | 39 +++++++++++++++++ 4 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index aee0b4df7..d91f1e766 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -75,48 +75,6 @@ DEFINE_FIELD(AInventory, SpawnPointClass) DEFINE_FIELD(AInventory, PickupFlash) DEFINE_FIELD(AInventory, PickupSound) -//=========================================================================== -// -// AInventory :: Tick -// -//=========================================================================== - -void AInventory::Tick () -{ - if (Owner == NULL) - { - // AActor::Tick is only handling interaction with the world - // and we don't want that for owned inventory items. - Super::Tick (); - } - else if (tics != -1) // ... but at least we have to advance the states - { - tics--; - - // you can cycle through multiple states in a tic - // [RH] Use <= 0 instead of == 0 so that spawnstates - // of 0 tics work as expected. - if (tics <= 0) - { - assert (state != NULL); - if (state == NULL) - { - Destroy(); - return; - } - if (!SetState (state->GetNextState())) - return; // freed itself - } - } - if (DropTime) - { - if (--DropTime == 0) - { - flags |= GetDefault()->flags & (MF_SPECIAL|MF_SOLID); - } - } -} - //=========================================================================== // // AInventory :: Serialize diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index a1f2fc8d9..b0469f356 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -71,7 +71,7 @@ class AInventory : public AActor public: virtual void Serialize(FSerializer &arc) override; - virtual void Tick() override; + //virtual void Tick() override; TObjPtr Owner; // Who owns this item? NULL if it's still a pickup. int Amount; // Amount of item this instance has diff --git a/src/namedef.h b/src/namedef.h index bf72bf79b..b69ff416b 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -1013,6 +1013,7 @@ xx(FOVScale) xx(YAdjust) xx(Crosshair) xx(WeaponFlags) +xx(DropTime) xx(BlueCard) xx(YellowCard) diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index 86c5527f6..337778d9c 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -49,6 +49,45 @@ class Inventory : Actor native Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG"; } + //native override void Tick(); + + override void Tick() + { + if (Owner == null) + { + // AActor::Tick is only handling interaction with the world + // and we don't want that for owned inventory items. + Super.Tick(); + } + else if (tics != -1) // ... but at least we have to advance the states + { + tics--; + + // you can cycle through multiple states in a tic + // [RH] Use <= 0 instead of == 0 so that spawnstates + // of 0 tics work as expected. + if (tics <= 0) + { + if (curstate == null) + { + Destroy(); + return; + } + if (!SetState (curstate.NextState)) + return; // freed itself + } + } + if (DropTime) + { + if (--DropTime == 0) + { + bSpecial = default.bSpecial; + bSolid = default.bSolid; + } + } + } + + native static void PrintPickupMessage (bool localview, String str); States(Actor)