mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- 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:
parent
e637fe3ea7
commit
4e5d5d0f2e
1 changed files with 13 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue