diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 652a41290..e95df4d75 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1995,6 +1995,13 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...) switch (cheat) { + case CHEAT_RINGS: + case CHEAT_LIVES: + // If you're confused why 'int' instead of + // 'SINT8', search online: 'default argument promotions' + COPY(WRITESINT8, int); + break; + case CHEAT_SCALE: COPY(WRITEFIXED, fixed_t); break; @@ -5495,6 +5502,28 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) break; } + case CHEAT_RINGS: { + SINT8 rings = READSINT8(*cp); + + // P_GivePlayerRings does value clamping + player->rings = 0; + P_GivePlayerRings(player, rings); + + CV_CheaterWarning(targetPlayer, va("rings = %d", rings)); + break; + } + + case CHEAT_LIVES: { + SINT8 lives = READSINT8(*cp); + + // P_GivePlayerLives does value clamping + player->lives = 0; + P_GivePlayerLives(player, lives); + + CV_CheaterWarning(targetPlayer, va("lives = %d", lives)); + break; + } + case CHEAT_SCALE: { const fixed_t smin = FRACUNIT/100; const fixed_t smax = 100*FRACUNIT; diff --git a/src/d_player.h b/src/d_player.h index debfb6675..28d126b55 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -602,7 +602,4 @@ typedef struct player_s #endif } player_t; -// Value for infinite lives -#define INFLIVES 0x7F - #endif diff --git a/src/deh_tables.c b/src/deh_tables.c index 084f347ac..fdd7d184f 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -6347,9 +6347,6 @@ struct int_const_s const INT_CONST[] = { {"PA_DRIFT",PA_DRIFT}, {"PA_HURT",PA_HURT}, - // Value for infinite lives - {"INFLIVES",INFLIVES}, - // Got Flags, for player->gotflag! // Used to be MF_ for some stupid reason, now they're GF_ to stop them looking like mobjflags {"GF_REDFLAG",GF_REDFLAG}, diff --git a/src/m_cheat.c b/src/m_cheat.c index a7c183b98..ff82ce556 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -748,13 +748,7 @@ void Command_Setrings_f(void) REQUIRE_CHEATS; REQUIRE_INLEVEL; - if (COM_Argc() > 1) - { - // P_GivePlayerRings does value clamping - players[consoleplayer].rings = 0; - P_GivePlayerRings(&players[consoleplayer], atoi(COM_Argv(1))); - players[consoleplayer].totalring -= atoi(COM_Argv(1)); //undo totalring addition done in P_GivePlayerRings - } + D_Cheat(consoleplayer, CHEAT_RINGS, atoi(COM_Argv(1))); } void Command_Setlives_f(void) @@ -762,20 +756,7 @@ void Command_Setlives_f(void) REQUIRE_CHEATS; REQUIRE_INLEVEL; - if (COM_Argc() > 1) - { - SINT8 lives = atoi(COM_Argv(1)); - if (lives == -1) - { - players[consoleplayer].lives = INFLIVES; // infinity! - } - else - { - // P_GivePlayerLives does value clamping - players[consoleplayer].lives = 0; - P_GivePlayerLives(&players[consoleplayer], atoi(COM_Argv(1))); - } - } + D_Cheat(consoleplayer, CHEAT_LIVES, atoi(COM_Argv(1))); } // diff --git a/src/m_cheat.h b/src/m_cheat.h index 080fe9997..e12366b0f 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -22,6 +22,8 @@ typedef enum { CHEAT_NOCLIP, CHEAT_GOD, + CHEAT_RINGS, + CHEAT_LIVES, CHEAT_SCALE, CHEAT_FLIP, CHEAT_HURT,