- 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
1 changed files with 13 additions and 9 deletions

View File

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