From 2cad1c2c199f566ecc5dee4b9902bc984c0bd988 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 13 Sep 2008 22:08:41 +0000 Subject: [PATCH] - Moved IF_ALWAYSPICKUP and GiveQuest into CallTryPickup so that they are automatically used by all inventory classes. - The previous change made it necessary to replace all TryPickup calls with another function that just calls TryPickup. - Fixed: AInventory::TryPickup can change the toucher so this must be reported to subclasses calling the super function. Changed TryPickup to pass the toucher pointer by reference. SVN r1221 (trunk) --- docs/rh-log.txt | 7 +++++ src/d_dehacked.cpp | 4 +-- src/d_dehacked.h | 2 +- src/g_hexen/a_boostarmor.cpp | 4 +-- src/g_hexen/a_clericholy.cpp | 4 +-- src/g_hexen/a_fighterplayer.cpp | 6 ++-- src/g_hexen/a_fighterquietus.cpp | 4 +-- src/g_hexen/a_healingradius.cpp | 2 +- src/g_hexen/a_hexenglobal.h | 6 ++-- src/g_hexen/a_magestaff.cpp | 4 +-- src/g_hexen/a_summon.cpp | 2 +- src/g_shared/a_artifacts.cpp | 2 +- src/g_shared/a_pickups.cpp | 49 +++++++++++++++++++------------ src/g_shared/a_pickups.h | 11 +++---- src/g_shared/a_weaponpiece.cpp | 4 +-- src/g_shared/a_weaponpiece.h | 2 +- src/g_shared/a_weapons.cpp | 9 +++--- src/g_strife/a_strifeglobal.h | 6 ++-- src/g_strife/a_strifeitems.cpp | 40 ++++++++++++------------- src/g_strife/a_strifeweapons.cpp | 2 +- src/g_strife/a_thingstoblowup.cpp | 2 +- src/m_cheat.cpp | 8 ++--- src/p_acs.cpp | 2 +- src/p_conversation.cpp | 2 +- src/p_mobj.cpp | 4 +-- src/p_user.cpp | 4 +-- src/thingdef/olddecorations.cpp | 2 +- src/thingdef/thingdef_codeptr.cpp | 2 +- 28 files changed, 107 insertions(+), 89 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 875725ccd..8e74bf25e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,11 @@ September 13, 2008 (Changes by Graf Zahl) +- Moved IF_ALWAYSPICKUP and GiveQuest into CallTryPickup so that they are + automatically used by all inventory classes. +- The previous change made it necessary to replace all TryPickup calls with + another function that just calls TryPickup. +- Fixed: AInventory::TryPickup can change the toucher so this must be reported + to subclasses calling the super function. Changed TryPickup to pass the + toucher pointer by reference. - Prefixed all names of CQ decorations with Chex after seeing some conflicts with PWADs. - Removed Chex Quest actors that were just unaltered duplicates of Doom's. diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 470bf9d67..78651f93c 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2614,7 +2614,7 @@ void FinishDehPatch () void ModifyDropAmount(AInventory *inv, int dropamount); -bool ADehackedPickup::TryPickup (AActor *toucher) +bool ADehackedPickup::TryPickup (AActor *&toucher) { const PClass *type = DetermineType (); if (type == NULL) @@ -2634,7 +2634,7 @@ bool ADehackedPickup::TryPickup (AActor *toucher) { ModifyDropAmount(RealPickup, 0); } - if (!RealPickup->TryPickup (toucher)) + if (!RealPickup->CallTryPickup (toucher)) { RealPickup->Destroy (); RealPickup = NULL; diff --git a/src/d_dehacked.h b/src/d_dehacked.h index 2b9e995f6..6967c083d 100644 --- a/src/d_dehacked.h +++ b/src/d_dehacked.h @@ -45,7 +45,7 @@ public: const char *PickupMessage (); bool ShouldRespawn (); bool ShouldStay (); - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); void PlayPickupSound (AActor *toucher); void DoPickupSpecial (AActor *toucher); void Serialize(FArchive &arc); diff --git a/src/g_hexen/a_boostarmor.cpp b/src/g_hexen/a_boostarmor.cpp index 785332144..ca7c6c9dc 100644 --- a/src/g_hexen/a_boostarmor.cpp +++ b/src/g_hexen/a_boostarmor.cpp @@ -31,7 +31,7 @@ bool AArtiBoostArmor::Use (bool pickup) armor->flags |= MF_DROPPED; armor->health = i; armor->Amount = 1; - if (!armor->TryPickup (Owner)) + if (!armor->CallTryPickup (Owner)) { armor->Destroy (); } @@ -48,7 +48,7 @@ bool AArtiBoostArmor::Use (bool pickup) armor->flags |= MF_DROPPED; armor->SaveAmount = 50; armor->MaxSaveAmount = 300; - if (!armor->TryPickup (Owner)) + if (!armor->CallTryPickup (Owner)) { armor->Destroy (); return false; diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index 976bcac7e..a77c4befa 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -27,12 +27,12 @@ class AClericWeaponPiece : public AWeaponPiece { DECLARE_CLASS (AClericWeaponPiece, AWeaponPiece) protected: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AClericWeaponPiece) -bool AClericWeaponPiece::TryPickup (AActor *toucher) +bool AClericWeaponPiece::TryPickup (AActor *&toucher) { if (!toucher->IsKindOf (PClass::FindClass(NAME_MagePlayer)) && !toucher->IsKindOf (PClass::FindClass(NAME_FighterPlayer))) diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index 18f1843bd..014b159bf 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -17,7 +17,7 @@ IMPLEMENT_CLASS (AFighterWeapon) IMPLEMENT_CLASS (AClericWeapon) IMPLEMENT_CLASS (AMageWeapon) -bool AFighterWeapon::TryPickup (AActor *toucher) +bool AFighterWeapon::TryPickup (AActor *&toucher) { // The Doom and Hexen players are not excluded from pickup in case // somebody wants to use these weapons with either of those games. @@ -42,7 +42,7 @@ bool AFighterWeapon::TryPickup (AActor *toucher) // Cleric Weapon Base Class ------------------------------------------------- -bool AClericWeapon::TryPickup (AActor *toucher) +bool AClericWeapon::TryPickup (AActor *&toucher) { // The Doom and Hexen players are not excluded from pickup in case // somebody wants to use these weapons with either of those games. @@ -67,7 +67,7 @@ bool AClericWeapon::TryPickup (AActor *toucher) // Mage Weapon Base Class --------------------------------------------------- -bool AMageWeapon::TryPickup (AActor *toucher) +bool AMageWeapon::TryPickup (AActor *&toucher) { // The Doom and Hexen players are not excluded from pickup in case // somebody wants to use these weapons with either of those games. diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index 7067d1c24..e5b2d880b 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -21,12 +21,12 @@ class AFighterWeaponPiece : public AWeaponPiece { DECLARE_CLASS (AFighterWeaponPiece, AWeaponPiece) protected: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AFighterWeaponPiece) -bool AFighterWeaponPiece::TryPickup (AActor *toucher) +bool AFighterWeaponPiece::TryPickup (AActor *&toucher) { if (!toucher->IsKindOf (PClass::FindClass(NAME_ClericPlayer)) && !toucher->IsKindOf (PClass::FindClass(NAME_MagePlayer))) diff --git a/src/g_hexen/a_healingradius.cpp b/src/g_hexen/a_healingradius.cpp index eceb926ee..e5fcca835 100644 --- a/src/g_hexen/a_healingradius.cpp +++ b/src/g_hexen/a_healingradius.cpp @@ -48,7 +48,7 @@ bool AArtiHealingRadius::Use (bool pickup) AHexenArmor *armor = Spawn (0,0,0, NO_REPLACE); armor->health = j; armor->Amount = 1; - if (!armor->TryPickup (players[i].mo)) + if (!armor->CallTryPickup (players[i].mo)) { armor->Destroy (); } diff --git a/src/g_hexen/a_hexenglobal.h b/src/g_hexen/a_hexenglobal.h index 96acbe14c..a942998fe 100644 --- a/src/g_hexen/a_hexenglobal.h +++ b/src/g_hexen/a_hexenglobal.h @@ -16,21 +16,21 @@ class AFighterWeapon : public AWeapon { DECLARE_CLASS (AFighterWeapon, AWeapon); public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; class AClericWeapon : public AWeapon { DECLARE_CLASS (AClericWeapon, AWeapon); public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; class AMageWeapon : public AWeapon { DECLARE_CLASS (AMageWeapon, AWeapon); public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; #endif //__A_HEXENGLOBAL_H__ diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index e3bfa356f..2e9ae8b3b 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -26,12 +26,12 @@ class AMageWeaponPiece : public AWeaponPiece { DECLARE_CLASS (AMageWeaponPiece, AWeaponPiece) protected: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AMageWeaponPiece) -bool AMageWeaponPiece::TryPickup (AActor *toucher) +bool AMageWeaponPiece::TryPickup (AActor *&toucher) { if (!toucher->IsKindOf (PClass::FindClass(NAME_ClericPlayer)) && !toucher->IsKindOf (PClass::FindClass(NAME_FighterPlayer))) diff --git a/src/g_hexen/a_summon.cpp b/src/g_hexen/a_summon.cpp index b7fcac6bf..ae6c85a6f 100644 --- a/src/g_hexen/a_summon.cpp +++ b/src/g_hexen/a_summon.cpp @@ -69,7 +69,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) { mo->tracer = self->tracer; // Pointer to master AInventory *power = Spawn (0, 0, 0, NO_REPLACE); - power->TryPickup (self->tracer); + power->CallTryPickup (self->tracer); if (self->tracer->player != NULL) { mo->FriendPlayer = int(self->tracer->player - players + 1); diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 3ea52cccb..1ab1af8f0 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -60,7 +60,7 @@ bool APowerupGiver::Use (bool pickup) } power->ItemFlags |= ItemFlags & (IF_ALWAYSPICKUP|IF_ADDITIVETIME); - if (power->TryPickup (Owner)) + if (power->CallTryPickup (Owner)) { return true; } diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index e555bd394..e1531a6ae 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -891,7 +891,7 @@ void AInventory::Touch (AActor *toucher) toucher = toucher->player->mo; } - if (!TryPickup (toucher)) + if (!CallTryPickup (toucher)) return; if (!(ItemFlags & IF_QUIET)) @@ -1163,13 +1163,14 @@ void AInventory::GiveQuest (AActor *toucher) toucher->GiveInventoryType (QuestItemClasses[quest-1]); } } + //=========================================================================== // // AInventory :: TryPickup // //=========================================================================== -bool AInventory::TryPickup (AActor *toucher) +bool AInventory::TryPickup (AActor *&toucher) { AActor *newtoucher = toucher; // in case changed by the powerup @@ -1201,7 +1202,7 @@ bool AInventory::TryPickup (AActor *toucher) bool usegood = Use (true); toucher->RemoveInventory (this); - if (usegood || (ItemFlags & IF_ALWAYSPICKUP)) + if (usegood) { GoAwayAndDie (); } @@ -1248,11 +1249,30 @@ bool AInventory::TryPickup (AActor *toucher) } } } - - GiveQuest(newtoucher); return true; } +//=========================================================================== +// +// AInventory :: TryPickup +// +//=========================================================================== + +bool AInventory::CallTryPickup (AActor *toucher) +{ + bool res = TryPickup(toucher); + + if (!res && (ItemFlags & IF_ALWAYSPICKUP)) + { + res = true; + GoAwayAndDie(); + } + + if (res) GiveQuest(toucher); + return res; +} + + //=========================================================================== // // CCMD printinv @@ -1344,7 +1364,7 @@ bool ACustomInventory::Use (bool pickup) // //=========================================================================== -bool ACustomInventory::TryPickup (AActor *toucher) +bool ACustomInventory::TryPickup (AActor *&toucher) { FState *pickupstate = FindState(NAME_Pickup); bool useok = CallStateChain (toucher, pickupstate); @@ -1352,9 +1372,8 @@ bool ACustomInventory::TryPickup (AActor *toucher) { useok = Super::TryPickup (toucher); } - else if (useok || ItemFlags & IF_ALWAYSPICKUP) + else if (useok) { - GiveQuest (toucher); GoAwayAndDie(); } return useok; @@ -1389,7 +1408,7 @@ const char *AHealth::PickupMessage () // //=========================================================================== -bool AHealth::TryPickup (AActor *other) +bool AHealth::TryPickup (AActor *&other) { player_t *player = other->player; int max = MaxAmount; @@ -1422,13 +1441,6 @@ bool AHealth::TryPickup (AActor *other) } if (player->health >= max) { - // You should be able to pick up the Doom health bonus even if - // you are already full on health. - if (ItemFlags & IF_ALWAYSPICKUP) - { - GoAwayAndDie (); - return true; - } return false; } player->health += Amount; @@ -1441,7 +1453,7 @@ bool AHealth::TryPickup (AActor *other) else { PrevHealth = INT_MAX; - if (P_GiveBody(other, Amount) || ItemFlags & IF_ALWAYSPICKUP) + if (P_GiveBody(other, Amount)) { GoAwayAndDie (); return true; @@ -1693,10 +1705,9 @@ IMPLEMENT_CLASS (AMapRevealer) // //=========================================================================== -bool AMapRevealer::TryPickup (AActor *toucher) +bool AMapRevealer::TryPickup (AActor *&toucher) { level.flags |= LEVEL_ALLMAP; - GiveQuest (toucher); GoAwayAndDie (); return true; } diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index e97d792bb..3eb16da46 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -118,7 +118,7 @@ public: virtual bool ShouldRespawn (); virtual bool ShouldStay (); virtual void Hide (); - virtual bool TryPickup (AActor *toucher); + bool CallTryPickup (AActor *toucher); virtual void DoPickupSpecial (AActor *toucher); virtual bool SpecialDropAction (AActor *dropper); virtual bool DrawPowerup (int x, int y); @@ -166,6 +166,7 @@ public: virtual PalEntry GetBlend (); protected: + virtual bool TryPickup (AActor *&toucher); void GiveQuest(AActor * toucher); private: @@ -182,7 +183,7 @@ public: // This is used when an inventory item's use state sequence is executed. bool CallStateChain (AActor *actor, FState *state); - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); bool Use (bool pickup); bool SpecialDropAction (AActor *dropper); }; @@ -235,7 +236,7 @@ public: virtual bool HandlePickup (AInventory *item); virtual AInventory *CreateCopy (AActor *other); virtual AInventory *CreateTossable (); - virtual bool TryPickup (AActor *toucher); + virtual bool TryPickup (AActor *&toucher); virtual bool PickupForAmmo (AWeapon *ownedWeapon); virtual bool Use (bool pickup); virtual void Destroy(); @@ -300,7 +301,7 @@ class AHealth : public AInventory int PrevHealth; public: - virtual bool TryPickup (AActor *other); + virtual bool TryPickup (AActor *&other); virtual const char *PickupMessage (); }; @@ -404,7 +405,7 @@ class AMapRevealer : public AInventory { DECLARE_CLASS (AMapRevealer, AInventory) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; // A backpack gives you one clip of each ammo and doubles your diff --git a/src/g_shared/a_weaponpiece.cpp b/src/g_shared/a_weaponpiece.cpp index 6167b40f4..08ea113ac 100644 --- a/src/g_shared/a_weaponpiece.cpp +++ b/src/g_shared/a_weaponpiece.cpp @@ -21,7 +21,7 @@ void AWeaponPiece::Serialize (FArchive &arc) // //========================================================================== -bool AWeaponPiece::TryPickup (AActor *toucher) +bool AWeaponPiece::TryPickup (AActor *&toucher) { AInventory * inv; AWeaponHolder * hold=NULL; @@ -70,7 +70,6 @@ bool AWeaponPiece::TryPickup (AActor *toucher) { // Already has the piece, check if mana needed if (!gaveAmmo) return false; - GiveQuest (toucher); GoAwayAndDie(); return true; } @@ -93,7 +92,6 @@ bool AWeaponPiece::TryPickup (AActor *toucher) FullWeapon->AmmoGive2=Defaults->AmmoGive2; } } - GiveQuest (toucher); GoAwayAndDie(); return true; } diff --git a/src/g_shared/a_weaponpiece.h b/src/g_shared/a_weaponpiece.h index 09db79dac..cae3076be 100644 --- a/src/g_shared/a_weaponpiece.h +++ b/src/g_shared/a_weaponpiece.h @@ -7,7 +7,7 @@ protected: bool PrivateShouldStay (); public: void Serialize (FArchive &arc); - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); bool ShouldStay (); virtual const char *PickupMessage (); virtual void PlayPickupSound (AActor *toucher); diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index bb1729578..bd7488111 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -57,7 +57,7 @@ void AWeapon::Serialize (FArchive &arc) // //=========================================================================== -bool AWeapon::TryPickup (AActor *toucher) +bool AWeapon::TryPickup (AActor *&toucher) { FState * ReadyState = FindState(NAME_Ready); if (ReadyState != NULL && @@ -578,12 +578,12 @@ class AWeaponGiver : public AWeapon DECLARE_CLASS(AWeaponGiver, AWeapon) public: - bool TryPickup(AActor *toucher); + bool TryPickup(AActor *&toucher); }; IMPLEMENT_CLASS(AWeaponGiver) -bool AWeaponGiver::TryPickup(AActor *toucher) +bool AWeaponGiver::TryPickup(AActor *&toucher) { FDropItem *di = GetDropItems(GetClass()); @@ -595,7 +595,8 @@ bool AWeaponGiver::TryPickup(AActor *toucher) AWeapon *weap = static_cast(Spawn(di->Name, 0, 0, 0, NO_REPLACE)); if (weap != NULL) { - bool res = weap->TryPickup(toucher); + weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only. + bool res = weap->CallTryPickup(toucher); if (!res) weap->Destroy(); else GoAwayAndDie(); return res; diff --git a/src/g_strife/a_strifeglobal.h b/src/g_strife/a_strifeglobal.h index 0407a415d..72d0cf306 100644 --- a/src/g_strife/a_strifeglobal.h +++ b/src/g_strife/a_strifeglobal.h @@ -33,21 +33,21 @@ class AUpgradeStamina : public ADummyStrifeItem { DECLARE_CLASS (AUpgradeStamina, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; class AUpgradeAccuracy : public ADummyStrifeItem { DECLARE_CLASS (AUpgradeAccuracy, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; class ASlideshowStarter : public ADummyStrifeItem { DECLARE_CLASS (ASlideshowStarter, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; class ASigil : public AWeapon diff --git a/src/g_strife/a_strifeitems.cpp b/src/g_strife/a_strifeitems.cpp index f325bc5b2..0481dca03 100644 --- a/src/g_strife/a_strifeitems.cpp +++ b/src/g_strife/a_strifeitems.cpp @@ -66,12 +66,12 @@ class AHealthTraining : public AInventory { DECLARE_CLASS (AHealthTraining, AInventory) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AHealthTraining) -bool AHealthTraining::TryPickup (AActor *toucher) +bool AHealthTraining::TryPickup (AActor *&toucher) { if (Super::TryPickup (toucher)) { @@ -80,7 +80,7 @@ bool AHealthTraining::TryPickup (AActor *toucher) if (coin != NULL) { coin->Amount = toucher->player->accuracy*5 + 300; - if (!coin->TryPickup (toucher)) + if (!coin->CallTryPickup (toucher)) { coin->Destroy (); } @@ -120,13 +120,13 @@ class APrisonPass : public AKey { DECLARE_CLASS (APrisonPass, AKey) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); bool SpecialDropAction (AActor *dropper); }; IMPLEMENT_CLASS (APrisonPass) -bool APrisonPass::TryPickup (AActor *toucher) +bool APrisonPass::TryPickup (AActor *&toucher) { Super::TryPickup (toucher); EV_DoDoor (DDoor::doorOpen, NULL, toucher, 223, 2*FRACUNIT, 0, 0, 0); @@ -165,13 +165,13 @@ class ARaiseAlarm : public ADummyStrifeItem { DECLARE_CLASS (ARaiseAlarm, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); bool SpecialDropAction (AActor *dropper); }; IMPLEMENT_CLASS (ARaiseAlarm) -bool ARaiseAlarm::TryPickup (AActor *toucher) +bool ARaiseAlarm::TryPickup (AActor *&toucher) { P_NoiseAlert (toucher, toucher); // A_WakeOracleSpectre (dword312F4); @@ -196,12 +196,12 @@ class AOpenDoor222 : public ADummyStrifeItem { DECLARE_CLASS (AOpenDoor222, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AOpenDoor222) -bool AOpenDoor222::TryPickup (AActor *toucher) +bool AOpenDoor222::TryPickup (AActor *&toucher) { EV_DoDoor (DDoor::doorOpen, NULL, toucher, 222, 2*FRACUNIT, 0, 0, 0); GoAwayAndDie (); @@ -214,13 +214,13 @@ class ACloseDoor222 : public ADummyStrifeItem { DECLARE_CLASS (ACloseDoor222, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); bool SpecialDropAction (AActor *dropper); }; IMPLEMENT_CLASS (ACloseDoor222) -bool ACloseDoor222::TryPickup (AActor *toucher) +bool ACloseDoor222::TryPickup (AActor *&toucher) { EV_DoDoor (DDoor::doorClose, NULL, toucher, 222, 2*FRACUNIT, 0, 0, 0); GoAwayAndDie (); @@ -245,13 +245,13 @@ class AOpenDoor224 : public ADummyStrifeItem { DECLARE_CLASS (AOpenDoor224, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); bool SpecialDropAction (AActor *dropper); }; IMPLEMENT_CLASS (AOpenDoor224) -bool AOpenDoor224::TryPickup (AActor *toucher) +bool AOpenDoor224::TryPickup (AActor *&toucher) { EV_DoDoor (DDoor::doorOpen, NULL, toucher, 224, 2*FRACUNIT, 0, 0, 0); GoAwayAndDie (); @@ -271,12 +271,12 @@ class AAmmoFillup : public ADummyStrifeItem { DECLARE_CLASS (AAmmoFillup, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AAmmoFillup) -bool AAmmoFillup::TryPickup (AActor *toucher) +bool AAmmoFillup::TryPickup (AActor *&toucher) { const PClass * clip = PClass::FindClass(NAME_ClipOfBullets); if (clip != NULL) @@ -309,12 +309,12 @@ class AHealthFillup : public ADummyStrifeItem { DECLARE_CLASS (AHealthFillup, ADummyStrifeItem) public: - bool TryPickup (AActor *toucher); + bool TryPickup (AActor *&toucher); }; IMPLEMENT_CLASS (AHealthFillup) -bool AHealthFillup::TryPickup (AActor *toucher) +bool AHealthFillup::TryPickup (AActor *&toucher) { static const int skillhealths[5] = { -100, -75, -50, -50, -100 }; @@ -331,7 +331,7 @@ bool AHealthFillup::TryPickup (AActor *toucher) IMPLEMENT_CLASS (AUpgradeStamina) -bool AUpgradeStamina::TryPickup (AActor *toucher) +bool AUpgradeStamina::TryPickup (AActor *&toucher) { if (toucher->player == NULL) return false; @@ -349,7 +349,7 @@ bool AUpgradeStamina::TryPickup (AActor *toucher) IMPLEMENT_CLASS (AUpgradeAccuracy) -bool AUpgradeAccuracy::TryPickup (AActor *toucher) +bool AUpgradeAccuracy::TryPickup (AActor *&toucher) { if (toucher->player == NULL || toucher->player->accuracy >= 100) return false; @@ -362,7 +362,7 @@ bool AUpgradeAccuracy::TryPickup (AActor *toucher) IMPLEMENT_CLASS (ASlideshowStarter) -bool ASlideshowStarter::TryPickup (AActor *toucher) +bool ASlideshowStarter::TryPickup (AActor *&toucher) { gameaction = ga_slideshow; if (level.levelnum == 10) diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 137487b57..8623adf68 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -1071,7 +1071,7 @@ int ASigil::GiveSigilPiece (AActor *receiver) if (sigil == NULL) { sigil = static_cast(Spawn("Sigil1", 0,0,0, NO_REPLACE)); - if (!sigil->TryPickup (receiver)) + if (!sigil->CallTryPickup (receiver)) { sigil->Destroy (); } diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index 0d26edfb7..a6e2847fd 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem) if (playeringame[i]) { AInventory *item = static_cast(Spawn (QuestItemClasses[questitem-1], 0,0,0, NO_REPLACE)); - if (!item->TryPickup (players[i].mo)) + if (!item->CallTryPickup (players[i].mo)) { item->Destroy (); } diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 5b3ecf973..793eb152c 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -577,7 +577,7 @@ void GiveSpawner (player_t *player, const PClass *type, int amount) level.total_items--; item->flags &= ~MF_COUNTITEM; } - if (!item->TryPickup (player->mo)) + if (!item->CallTryPickup (player->mo)) { item->Destroy (); } @@ -693,7 +693,7 @@ void cht_Give (player_t *player, const char *name, int amount) ABasicArmorPickup *armor = Spawn (0,0,0, NO_REPLACE); armor->SaveAmount = 100*deh.BlueAC; armor->SavePercent = gameinfo.gametype != GAME_Heretic ? FRACUNIT/2 : FRACUNIT*3/4; - if (!armor->TryPickup (player->mo)) + if (!armor->CallTryPickup (player->mo)) { armor->Destroy (); } @@ -705,7 +705,7 @@ void cht_Give (player_t *player, const char *name, int amount) AHexenArmor *armor = Spawn (0,0,0, NO_REPLACE); armor->health = i; armor->Amount = 0; - if (!armor->TryPickup (player->mo)) + if (!armor->CallTryPickup (player->mo)) { armor->Destroy (); } @@ -726,7 +726,7 @@ void cht_Give (player_t *player, const char *name, int amount) if (key->KeyNumber != 0) { key = static_cast(Spawn (PClass::m_Types[i], 0,0,0, NO_REPLACE)); - if (!key->TryPickup (player->mo)) + if (!key->CallTryPickup (player->mo)) { key->Destroy (); } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 926a7a833..dab1dbd1f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -226,7 +226,7 @@ static void DoGiveInv (AActor *actor, const PClass *info, int amount) { item->Amount = amount; } - if (!item->TryPickup (actor)) + if (!item->CallTryPickup (actor)) { item->Destroy (); } diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 8973231be..3470ebf14 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1154,7 +1154,7 @@ void P_ConversationCommand (int player, BYTE **stream) static_cast(item)->AmmoGive1 = 40; } item->flags |= MF_DROPPED; - if (!item->TryPickup (players[player].mo)) + if (!item->CallTryPickup (players[player].mo)) { item->Destroy (); Conversation_TakeStuff = false; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index cbe0b93c6..833e762e2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -790,7 +790,7 @@ AInventory *AActor::GiveInventoryType (const PClass *type) if (type != NULL) { item = static_cast(Spawn (type, 0,0,0, NO_REPLACE)); - if (!item->TryPickup (this)) + if (!item->CallTryPickup (this)) { item->Destroy (); return NULL; @@ -816,7 +816,7 @@ bool AActor::GiveAmmo (const PClass *type, int amount) { item->Amount = amount; item->flags |= MF_DROPPED; - if (!item->TryPickup (this)) + if (!item->CallTryPickup (this)) { item->Destroy (); return false; diff --git a/src/p_user.cpp b/src/p_user.cpp index fe1ed217d..73411ed7a 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -698,7 +698,7 @@ void APlayerPawn::GiveDeathmatchInventory() if (key->KeyNumber != 0) { key = static_cast(Spawn (PClass::m_Types[i], 0,0,0, NO_REPLACE)); - if (!key->TryPickup (this)) + if (!key->CallTryPickup (this)) { key->Destroy (); } @@ -1007,7 +1007,7 @@ void APlayerPawn::GiveDefaultInventory () static_cast(item)->AmmoGive1 = static_cast(item)->AmmoGive2 = 0; } - if (!item->TryPickup(this)) + if (!item->CallTryPickup(this)) { item->Destroy (); item = NULL; diff --git a/src/thingdef/olddecorations.cpp b/src/thingdef/olddecorations.cpp index 3a8be7c04..80fe983cd 100644 --- a/src/thingdef/olddecorations.cpp +++ b/src/thingdef/olddecorations.cpp @@ -78,7 +78,7 @@ public: return Respawnable && Super::ShouldRespawn(); } - bool TryPickup (AActor *toucher) + bool TryPickup (AActor *&toucher) { INTBOOL success = LineSpecials[special] (NULL, toucher, false, args[0], args[1], args[2], args[3], args[4]); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index cf19c5902..fd0b3413e 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1213,7 +1213,7 @@ static void DoGiveInventory(AActor * self, AActor * receiver, DECLARE_PARAMINFO) item->flags&=~MF_COUNTITEM; level.total_items--; } - if (!item->TryPickup (receiver)) + if (!item->CallTryPickup (receiver)) { item->Destroy (); res = false;