- 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:
parent
f625b92704
commit
2cad1c2c19
28 changed files with 107 additions and 89 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue