- Don't give health for "give all".

- "Give artifacts" and "give puzzlepieces" now use the amount value to decide how much of each
  item to give you. 0 means to give you the max. The old behavior can be obtained by explicitly
  stating 1. (Since "give all" encompasses these as well, this also applies to that.)
- Added "give everything" cheat to give everything. This is like "give all" but ignores the
  WIF_CHEATNOTWEAPON flag. (Note that this flag has valid uses, but that doesn't stop people
  from abusing it anyway.)

SVN r2418 (trunk)
This commit is contained in:
Randy Heit 2010-07-09 01:57:46 +00:00
parent e379658143
commit 5a4dad1205

View file

@ -604,7 +604,7 @@ void GiveSpawner (player_t *player, const PClass *type, int amount)
void cht_Give (player_t *player, const char *name, int amount) void cht_Give (player_t *player, const char *name, int amount)
{ {
bool giveall; enum { ALL_NO, ALL_YES, ALL_YESYES } giveall;
int i; int i;
const PClass *type; const PClass *type;
@ -616,9 +616,17 @@ void cht_Give (player_t *player, const char *name, int amount)
return; return;
} }
giveall = (stricmp (name, "all") == 0); giveall = ALL_NO;
if (stricmp (name, "all") == 0)
{
giveall = ALL_YES;
}
else if (stricmp (name, "everything") == 0)
{
giveall = ALL_YES;
}
if (giveall || stricmp (name, "health") == 0) if (stricmp (name, "health") == 0)
{ {
if (amount > 0) if (amount > 0)
{ {
@ -643,9 +651,6 @@ void cht_Give (player_t *player, const char *name, int amount)
player->health = deh.GodHealth; player->health = deh.GodHealth;
} }
} }
if (!giveall)
return;
} }
if (giveall || stricmp (name, "backpack") == 0) if (giveall || stricmp (name, "backpack") == 0)
@ -760,7 +765,7 @@ void cht_Give (player_t *player, const char *name, int amount)
player->weapons.LocateWeapon(type, NULL, NULL)) player->weapons.LocateWeapon(type, NULL, NULL))
{ {
AWeapon *def = (AWeapon*)GetDefaultByType (type); AWeapon *def = (AWeapon*)GetDefaultByType (type);
if (!(def->WeaponFlags & WIF_CHEATNOTWEAPON)) if (giveall == ALL_YESYES || !(def->WeaponFlags & WIF_CHEATNOTWEAPON))
{ {
GiveSpawner (player, type, 1); GiveSpawner (player, type, 1);
} }
@ -786,7 +791,7 @@ void cht_Give (player_t *player, const char *name, int amount)
!type->IsDescendantOf (RUNTIME_CLASS(APowerup)) && !type->IsDescendantOf (RUNTIME_CLASS(APowerup)) &&
!type->IsDescendantOf (RUNTIME_CLASS(AArmor))) !type->IsDescendantOf (RUNTIME_CLASS(AArmor)))
{ {
GiveSpawner (player, type, 1); GiveSpawner (player, type, amount <= 0 ? def->MaxAmount : amount);
} }
} }
} }
@ -804,7 +809,7 @@ void cht_Give (player_t *player, const char *name, int amount)
AInventory *def = (AInventory*)GetDefaultByType (type); AInventory *def = (AInventory*)GetDefaultByType (type);
if (def->Icon.isValid()) if (def->Icon.isValid())
{ {
GiveSpawner (player, type, 1); GiveSpawner (player, type, amount <= 0 ? def->MaxAmount : amount);
} }
} }
} }