- 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;
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;

View file

@ -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__

View file

@ -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;

View file

@ -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;

View file

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

View file

@ -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 ();
}