- 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.
This commit is contained in:
Christoph Oelckers 2018-11-30 00:06:20 +01:00
parent 7b63e088e1
commit 3922f817fb
6 changed files with 8 additions and 8 deletions

View file

@ -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; static VMFunction *func = nullptr;
if (func == nullptr) PClass::FindFunction(&func, NAME_Inventory, NAME_CallTryPickup); 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]; VMReturn ret[2];
int res; int res;
AActor *tret; AActor *tret;

View file

@ -73,8 +73,6 @@ public:
virtual void Serialize(FSerializer &arc) override; virtual void Serialize(FSerializer &arc) override;
virtual void Tick() override; virtual void Tick() override;
bool CallTryPickup(AActor *toucher, AActor **toucher_return = NULL); // Wrapper for script function.
void DepleteOrDestroy (); // virtual on the script side. void DepleteOrDestroy (); // virtual on the script side.
bool DoRespawn(); bool DoRespawn();
@ -98,4 +96,6 @@ public:
FSoundIDNoInit PickupSound; FSoundIDNoInit PickupSound;
}; };
bool CallTryPickup(AInventory *item, AActor *toucher, AActor **toucher_return = nullptr);
#endif //__A_PICKUPS_H__ #endif //__A_PICKUPS_H__

View file

@ -4150,7 +4150,7 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo
} }
gift->flags |= MF_DROPPED; gift->flags |= MF_DROPPED;
gift->ClearCounters(); gift->ClearCounters();
if (!gift->CallTryPickup(thing)) if (!CallTryPickup(gift, thing))
{ {
gift->Destroy(); gift->Destroy();
return false; return false;

View file

@ -972,7 +972,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
item->IntVar(NAME_AmmoGive1) = 40; item->IntVar(NAME_AmmoGive1) = 40;
} }
item->flags |= MF_DROPPED; item->flags |= MF_DROPPED;
if (!item->CallTryPickup(player->mo)) if (!CallTryPickup(item, player->mo))
{ {
item->Destroy(); item->Destroy();
takestuff = false; takestuff = false;

View file

@ -926,7 +926,7 @@ AInventory *AActor::GiveInventoryType (PClassActor *type)
if (type != NULL) if (type != NULL)
{ {
item = static_cast<AInventory *>(Spawn (type)); item = static_cast<AInventory *>(Spawn (type));
if (!item->CallTryPickup (this)) if (!CallTryPickup (item, this))
{ {
item->Destroy (); item->Destroy ();
return NULL; return NULL;

View file

@ -980,7 +980,7 @@ void APlayerPawn::GiveDeathmatchInventory()
if (key->special1 != 0) if (key->special1 != 0)
{ {
key = (AInventory*)Spawn(PClassActor::AllActorClasses[i]); key = (AInventory*)Spawn(PClassActor::AllActorClasses[i]);
if (!key->CallTryPickup (this)) if (!CallTryPickup (key, this))
{ {
key->Destroy (); key->Destroy ();
} }