- Fixed: The Heretic "take weapons" cheat did not remove all the weapons at

once. This is because destroying one weapon has a potential to destroy a
  sister weapon as well. If the sister weapon is the next one in line (as it
  typically is), it would process that one, not realizing it was no longer
  part of the inventory, and stop because its Inventory link was NULL.


SVN r1610 (trunk)
This commit is contained in:
Randy Heit 2009-05-26 17:35:30 +00:00
parent e637fe3ea7
commit 4e5d5d0f2e

View file

@ -391,20 +391,24 @@ void cht_DoCheat (player_t *player, int cheat)
{
return;
}
// Take away all weapons that are either non-wimpy or use ammo.
for (item = player->mo->Inventory; item != NULL; )
{
AInventory *next = item->Inventory;
if (item->IsKindOf (RUNTIME_CLASS(AWeapon)))
// Take away all weapons that are either non-wimpy or use ammo.
AInventory **invp = &player->mo->Inventory, **lastinvp;
for (item = *invp; item != NULL; item = *invp)
{
AWeapon *weap = static_cast<AWeapon *> (item);
if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) ||
weap->AmmoType1 != NULL)
lastinvp = invp;
invp = &(*invp)->Inventory;
if (item->IsKindOf (RUNTIME_CLASS(AWeapon)))
{
item->Destroy ();
AWeapon *weap = static_cast<AWeapon *> (item);
if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) ||
weap->AmmoType1 != NULL)
{
item->Destroy ();
invp = lastinvp;
}
}
}
item = next;
}
msg = GStrings("TXT_CHEATIDKFA");
break;