From 9f6e9c109ecaa7ba1a02fe84444c92bf9ea1bad4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 29 Sep 2022 03:53:30 -0700 Subject: [PATCH] Let savecheckpoint work online, work at all Actually respawns you at this location! :smiley: Uses object Z position instead of floor height. --- src/d_netcmd.c | 20 ++++++++++++++++++++ src/m_cheat.c | 12 ++++++------ src/m_cheat.h | 1 + 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6827d860f..4678d86c2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2114,6 +2114,12 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...) switch (cheat) { + case CHEAT_SAVECHECKPOINT: + COPY(WRITEFIXED, fixed_t); // x + COPY(WRITEFIXED, fixed_t); // y + COPY(WRITEFIXED, fixed_t); // z + break; + case CHEAT_RINGS: case CHEAT_LIVES: // If you're confused why 'int' instead of @@ -5719,6 +5725,20 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) break; } + case CHEAT_SAVECHECKPOINT: { + fixed_t x = READFIXED(*cp); + fixed_t y = READFIXED(*cp); + fixed_t z = READFIXED(*cp); + + player->starpostx = x>>FRACBITS; + player->starposty = y>>FRACBITS; + player->starpostz = z>>FRACBITS; + + CV_CheaterWarning(targetPlayer, va("temporary checkpoint created at %d, %d, %d", + x / FRACUNIT, y / FRACUNIT, z / FRACUNIT)); + break; + } + case CHEAT_RINGS: { SINT8 rings = READSINT8(*cp); diff --git a/src/m_cheat.c b/src/m_cheat.c index 4888c502c..9830ebcec 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -659,15 +659,15 @@ void Command_Dumplua_f(void) void Command_Savecheckpoint_f(void) { + mobj_t *thing = players[consoleplayer].mo; + REQUIRE_DEVMODE; REQUIRE_INLEVEL; - REQUIRE_SINGLEPLAYER; - players[consoleplayer].starpostx = players[consoleplayer].mo->x; - players[consoleplayer].starposty = players[consoleplayer].mo->y; - players[consoleplayer].starpostz = players[consoleplayer].mo->floorz; - - CONS_Printf(M_GetText("Temporary checkpoint created at %d, %d, %d\n"), players[consoleplayer].starpostx, players[consoleplayer].starposty, players[consoleplayer].starpostz); + if (!P_MobjWasRemoved(thing)) + { + D_Cheat(consoleplayer, CHEAT_SAVECHECKPOINT, thing->x, thing->y, thing->z); + } } // Like M_GetAllEmeralds() but for console devmode junkies. diff --git a/src/m_cheat.h b/src/m_cheat.h index 7c086da34..c217d7f01 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -26,6 +26,7 @@ extern "C" { typedef enum { CHEAT_NOCLIP, CHEAT_GOD, + CHEAT_SAVECHECKPOINT, CHEAT_RINGS, CHEAT_LIVES, CHEAT_SCALE,