From 3922f817fb6ab9a6e90053ffbfb7ea43fae71070 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 20f6b9f484..da49bcab9a 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -260,11 +260,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 9960d7a0cb..aace9f5715 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. bool DoRespawn(); @@ -98,4 +96,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 b43fdd33cf..62db8b13b5 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -4150,7 +4150,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 1d8c48055b..69e726dc3c 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -972,7 +972,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 654e1f0ae2..752dccd153 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -926,7 +926,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 179819fd78..573a059921 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -980,7 +980,7 @@ void APlayerPawn::GiveDeathmatchInventory() if (key->special1 != 0) { key = (AInventory*)Spawn(PClassActor::AllActorClasses[i]); - if (!key->CallTryPickup (this)) + if (!CallTryPickup (key, this)) { key->Destroy (); }