- 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)
This commit is contained in:
Christoph Oelckers 2008-09-13 22:08:41 +00:00
commit 2cad1c2c19
28 changed files with 107 additions and 89 deletions

View file

@ -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<AWeapon*>(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;