From 7d7110ead73e16b872edc33de46d03dbcff8f845 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Nov 2023 05:52:26 -0800 Subject: [PATCH] Let devmode work in replays, let teleport commands work in replay freecam --- src/d_netcmd.c | 29 +++++++++++++++++++++++++++++ src/m_cheat.c | 13 ++++++++----- src/st_stuff.c | 26 +++++++++++++++++++------- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 94da8531c..e259c76a2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1464,6 +1464,17 @@ void D_SendPlayerConfig(UINT8 n) static camera_t *LocalMutableCamera(INT32 playernum) { + if (demo.playback) + { + // TODO: could have splitscreen support + if (!camera[0].freecam) + { + return NULL; + } + + return &camera[0]; + } + if (G_IsPartyLocal(playernum)) { UINT8 viewnum = G_PartyPosition(playernum); @@ -1523,6 +1534,24 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...) return; } + if (demo.playback && cheat == CHEAT_DEVMODE) + { + // There is no networking in demos, but devmode is + // too useful to be inaccessible! + // TODO: maybe allow everything, even though it would + // desync replays? May be useful for debugging. + va_start(ap, cheat); + cht_debug = va_arg(ap, UINT32); + va_end(ap); + return; + } + + // sanity check + if (demo.playback) + { + return; + } + WRITEUINT8(p, playernum); WRITEUINT8(p, cheat); diff --git a/src/m_cheat.c b/src/m_cheat.c index e91e445fd..af1ad9812 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -281,6 +281,9 @@ boolean cht_Interpret(const char *password) { CONS_Printf(M_GetText("OBJECTPLACE must be enabled.\n")); return; } #define REQUIRE_INLEVEL if (gamestate != GS_LEVEL || demo.playback)\ +{ CONS_Printf(M_GetText("You must be in a level (and not a replay) to use this.\n")); return; } + +#define REQUIRE_INLEVEL_OR_REPLAY if (gamestate != GS_LEVEL)\ { CONS_Printf(M_GetText("You must be in a level to use this.\n")); return; } #define REQUIRE_SINGLEPLAYER if (netgame)\ @@ -357,7 +360,7 @@ void Command_RTeleport_f(void) float z = atof(COM_Argv(3)); REQUIRE_CHEATS; - REQUIRE_INLEVEL; + REQUIRE_INLEVEL_OR_REPLAY; if (COM_Argc() != 4) { @@ -376,7 +379,7 @@ void Command_Teleport_f(void) float z = atof(COM_Argv(3)); REQUIRE_CHEATS; - REQUIRE_INLEVEL; + REQUIRE_INLEVEL_OR_REPLAY; if (COM_Argc() != 4) { @@ -611,7 +614,7 @@ void Command_Goto_f(void) const waypoint_t *wayp = K_GetWaypointFromID(id); REQUIRE_CHEATS; - REQUIRE_INLEVEL; + REQUIRE_INLEVEL_OR_REPLAY; if (COM_Argc() != 2) { @@ -635,7 +638,7 @@ void Command_Angle_f(void) const angle_t angle = FixedAngle(FLOAT_TO_FIXED(anglef)); REQUIRE_CHEATS; - REQUIRE_INLEVEL; + REQUIRE_INLEVEL_OR_REPLAY; D_Cheat(consoleplayer, CHEAT_ANGLE, angle); } @@ -657,7 +660,7 @@ void Command_RespawnAt_f(void) void Command_GotoSkybox_f(void) { REQUIRE_CHEATS; - REQUIRE_INLEVEL; + REQUIRE_INLEVEL_OR_REPLAY; mobj_t *skybox = players[consoleplayer].skybox.viewpoint; diff --git a/src/st_stuff.c b/src/st_stuff.c index c02ad0c8e..ab0f45e19 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -452,10 +452,10 @@ void ST_drawDebugInfo(void) { INT32 height = 192; - const UINT8 screen = cv_devmode_screen.value - 1; + const UINT8 screen = min(r_splitscreen, cv_devmode_screen.value - 1); // devmode_screen = 1..4 - stplyr = &players[displayplayers[min(r_splitscreen, screen)]]; + stplyr = &players[displayplayers[screen]]; if (!stplyr->mo) return; @@ -472,11 +472,23 @@ void ST_drawDebugInfo(void) if (cht_debug & DBG_BASIC) { - const fixed_t d = AngleFixed(stplyr->mo->angle); - V_DrawRightAlignedString(320, height - 24, V_MONOSPACE, va("X: %6d", stplyr->mo->x>>FRACBITS)); - V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Y: %6d", stplyr->mo->y>>FRACBITS)); - V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Z: %6d", stplyr->mo->z>>FRACBITS)); - V_DrawRightAlignedString(320, height, V_MONOSPACE, va("A: %6d", FixedInt(d))); + camera_t *cam = &camera[screen]; + if (stplyr->spectator || cam->freecam) + { + const fixed_t d = AngleFixed(cam->angle); + V_DrawRightAlignedString(320, height - 24, V_MONOSPACE, va("X: %6d", cam->x>>FRACBITS)); + V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Y: %6d", cam->y>>FRACBITS)); + V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Z: %6d", cam->z>>FRACBITS)); + V_DrawRightAlignedString(320, height, V_MONOSPACE, va("A: %6d", FixedInt(d))); + } + else + { + const fixed_t d = AngleFixed(stplyr->mo->angle); + V_DrawRightAlignedString(320, height - 24, V_MONOSPACE, va("X: %6d", stplyr->mo->x>>FRACBITS)); + V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Y: %6d", stplyr->mo->y>>FRACBITS)); + V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Z: %6d", stplyr->mo->z>>FRACBITS)); + V_DrawRightAlignedString(320, height, V_MONOSPACE, va("A: %6d", FixedInt(d))); + } height -= 40; }