From a7909c16e5598e91596356d97b043528d390bbbb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Nov 2018 00:06:20 +0100 Subject: [PATCH] - made CallTryPickup a global function. This one still gets called in too many places but stands in the way of moving Inventory fully to the script side. --- src/g_inventory/a_pickups.cpp | 4 ++-- src/g_inventory/a_pickups.h | 4 ++-- src/p_actionfunctions.cpp | 2 +- src/p_conversation.cpp | 2 +- src/p_mobj.cpp | 2 +- src/p_user.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index 840221c62..da5b92eec 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -289,11 +289,11 @@ DEFINE_ACTION_FUNCTION(AInventory, DoRespawn) // //=========================================================================== -bool AInventory::CallTryPickup(AActor *toucher, AActor **toucher_return) +bool CallTryPickup(AInventory *item, AActor *toucher, AActor **toucher_return) { static VMFunction *func = nullptr; if (func == nullptr) PClass::FindFunction(&func, NAME_Inventory, NAME_CallTryPickup); - VMValue params[2] = { (DObject*)this, toucher }; + VMValue params[2] = { (DObject*)item, toucher }; VMReturn ret[2]; int res; AActor *tret; diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 4981e81c3..8bea1d3f4 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -73,8 +73,6 @@ public: virtual void Serialize(FSerializer &arc) override; virtual void Tick() override; - bool CallTryPickup(AActor *toucher, AActor **toucher_return = NULL); // Wrapper for script function. - void DepleteOrDestroy (); // virtual on the script side. PalEntry CallGetBlend(); // virtual on the script side. bool GetNoTeleportFreeze(); // virtual on the script side. @@ -100,4 +98,6 @@ public: FSoundIDNoInit PickupSound; }; +bool CallTryPickup(AInventory *item, AActor *toucher, AActor **toucher_return = nullptr); + #endif //__A_PICKUPS_H__ diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index d8d9c0630..6f26eff21 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -4165,7 +4165,7 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo } gift->flags |= MF_DROPPED; gift->ClearCounters(); - if (!gift->CallTryPickup(thing)) + if (!CallTryPickup(gift, thing)) { gift->Destroy(); return false; diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 1cc313ec3..058e2e6d7 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -979,7 +979,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply item->IntVar(NAME_AmmoGive1) = 40; } item->flags |= MF_DROPPED; - if (!item->CallTryPickup(player->mo)) + if (!CallTryPickup(item, player->mo)) { item->Destroy(); takestuff = false; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a94731978..fe48ebcd5 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -940,7 +940,7 @@ AInventory *AActor::GiveInventoryType (PClassActor *type) if (type != NULL) { item = static_cast(Spawn (type)); - if (!item->CallTryPickup (this)) + if (!CallTryPickup (item, this)) { item->Destroy (); return NULL; diff --git a/src/p_user.cpp b/src/p_user.cpp index ebfe9ecec..0b54d33e6 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -967,7 +967,7 @@ void APlayerPawn::GiveDeathmatchInventory() if (key->special1 != 0) { key = (AInventory*)Spawn(PClassActor::AllActorClasses[i]); - if (!key->CallTryPickup (this)) + if (!CallTryPickup (key, this)) { key->Destroy (); }