From 5a4dad12056defcf9e0a58f47264e418f726ea1e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 9 Jul 2010 01:57:46 +0000 Subject: [PATCH] - 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) --- src/m_cheat.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 45175c50a..b50c908e8 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -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) { - bool giveall; + enum { ALL_NO, ALL_YES, ALL_YESYES } giveall; int i; const PClass *type; @@ -616,9 +616,17 @@ void cht_Give (player_t *player, const char *name, int amount) 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) { @@ -643,9 +651,6 @@ void cht_Give (player_t *player, const char *name, int amount) player->health = deh.GodHealth; } } - - if (!giveall) - return; } 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)) { AWeapon *def = (AWeapon*)GetDefaultByType (type); - if (!(def->WeaponFlags & WIF_CHEATNOTWEAPON)) + if (giveall == ALL_YESYES || !(def->WeaponFlags & WIF_CHEATNOTWEAPON)) { 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(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); if (def->Icon.isValid()) { - GiveSpawner (player, type, 1); + GiveSpawner (player, type, amount <= 0 ? def->MaxAmount : amount); } } }