From 21a31c7a51bd774a200b4a38779f97cb82309430 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 Apr 2023 00:37:12 -0700 Subject: [PATCH 1/5] devmode: offset with showfps and showping --- src/st_stuff.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 6c66d069d..9f4ff882f 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -446,15 +446,25 @@ void ST_drawDebugInfo(void) if (!stplyr->mo) return; + if (cv_ticrate.value) + { + height -= 20; + } + + if (cv_showping.value) + { + height -= 20; + } + if (cht_debug & DBG_BASIC) { const fixed_t d = AngleFixed(stplyr->mo->angle); - V_DrawRightAlignedString(320, 168, V_MONOSPACE, va("X: %6d", stplyr->mo->x>>FRACBITS)); - V_DrawRightAlignedString(320, 176, V_MONOSPACE, va("Y: %6d", stplyr->mo->y>>FRACBITS)); - V_DrawRightAlignedString(320, 184, V_MONOSPACE, va("Z: %6d", stplyr->mo->z>>FRACBITS)); - V_DrawRightAlignedString(320, 192, V_MONOSPACE, va("A: %6d", FixedInt(d))); + 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 = 152; + height -= 40; } if (cht_debug & DBG_DETAILED) From 39ea73a4ada341c73736a09c96e18f45863cf8b0 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 Apr 2023 00:37:58 -0700 Subject: [PATCH 2/5] devmode render: display skybox portal, visplane and drawseg counts on HUD - Skybox portal count moved from console print to HUD - Displays visplane count and drawseg count --- src/r_main.c | 4 ++++ src/r_main.h | 9 +++++++++ src/r_plane.c | 3 +++ src/r_portal.c | 2 +- src/r_segs.c | 2 ++ src/st_stuff.c | 17 +++++++++++++++++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 4f07cb1c9..1b8fd6110 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -126,6 +126,8 @@ int ps_numsprites = 0; int ps_numdrawnodes = 0; int ps_numpolyobjects = 0; +struct RenderStats g_renderstats; + static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -1525,6 +1527,8 @@ void R_RenderPlayerView(void) framecount++; validcount++; + memset(&g_renderstats, 0, sizeof g_renderstats); + // Clear buffers. R_ClearPlanes(); if (viewmorph[viewssnum].use) diff --git a/src/r_main.h b/src/r_main.h index 786b1eaf6..567577f07 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -106,6 +106,15 @@ extern int ps_numsprites; extern int ps_numdrawnodes; extern int ps_numpolyobjects; +struct RenderStats +{ + size_t visplanes; + size_t drawsegs; + size_t skybox_portals; +}; + +extern struct RenderStats g_renderstats; + // // REFRESH - the actual rendering functions. // diff --git a/src/r_plane.c b/src/r_plane.c index be4ecd02d..57de53ea9 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -341,6 +341,9 @@ static visplane_t *new_visplane(unsigned hash) } check->next = visplanes[hash]; visplanes[hash] = check; + + g_renderstats.visplanes++; + return check; } diff --git a/src/r_portal.c b/src/r_portal.c index e66d4343c..86c727e1e 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -312,5 +312,5 @@ void Portal_AddSkyboxPortals (const player_t *player) } } - CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count); + g_renderstats.skybox_portals = count; } diff --git a/src/r_segs.c b/src/r_segs.c index 74800fb21..c4f41ba11 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -3024,4 +3024,6 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->bsilheight = twosidedmidtexture ? INT32_MAX: INT32_MIN; } ds_p++; + + g_renderstats.drawsegs++; } diff --git a/src/st_stuff.c b/src/st_stuff.c index 9f4ff882f..5dde5c826 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -434,6 +434,18 @@ static void ST_drawMusicDebug(INT32 *height) } } +static void ST_drawRenderDebug(INT32 *height) +{ + const struct RenderStats *i = &g_renderstats; + + ST_pushDebugString(height, va(" Visplanes: %4s", sizeu1(i->visplanes))); + ST_pushDebugString(height, va(" Drawsegs: %4s", sizeu1(i->drawsegs))); + + ST_pushRow(height); + + ST_pushDebugString(height, va("Skybox Portals: %4s", sizeu1(i->skybox_portals))); +} + void ST_drawDebugInfo(void) { INT32 height = 192; @@ -516,6 +528,11 @@ void ST_drawDebugInfo(void) ST_drawMusicDebug(&height); } + if (cht_debug & DBG_RENDER) + { + ST_drawRenderDebug(&height); + } + if (cht_debug & DBG_MEMORY) V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10))); } From dc18fa745a881ae483b49daa18eba713a01bbcf4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 Apr 2023 00:47:30 -0700 Subject: [PATCH 3/5] Overhaul teleport command, let it work in netgames Old syntax with -x, -y, -z, -ang, -aim parameters is simply replaced with 3 argument syntax like rteleport. Before - teleport -x 100 -y 50 -z 25 After - teleport 100 50 25 The lost angle, aiming and star post features can be added back in separate commands. --- src/d_netcmd.c | 24 ++++-- src/m_cheat.c | 216 ++----------------------------------------------- src/m_cheat.h | 1 + 3 files changed, 26 insertions(+), 215 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index bf9416ce9..1ab532025 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2032,6 +2032,7 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...) break; case CHEAT_RELATIVE_TELEPORT: + case CHEAT_TELEPORT: COPY(WRITEFIXED, fixed_t); COPY(WRITEFIXED, fixed_t); COPY(WRITEFIXED, fixed_t); @@ -5699,7 +5700,8 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) break; } - case CHEAT_RELATIVE_TELEPORT: { + case CHEAT_RELATIVE_TELEPORT: + case CHEAT_TELEPORT: { fixed_t x = READFIXED(*cp); fixed_t y = READFIXED(*cp); fixed_t z = READFIXED(*cp); @@ -5714,10 +5716,17 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) if (!P_MobjWasRemoved(player->mo)) { P_MapStart(); - P_SetOrigin(player->mo, - player->mo->x + x, - player->mo->y + y, - player->mo->z + z); + if (cheat == CHEAT_RELATIVE_TELEPORT) + { + P_SetOrigin(player->mo, + player->mo->x + x, + player->mo->y + y, + player->mo->z + z); + } + else + { + P_SetOrigin(player->mo, x, y, z); + } P_MapEnd(); S_StartSound(player->mo, sfx_mixup); @@ -5727,7 +5736,10 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) strlcpy(t[1], M_Ftrim(f[1]), sizeof t[1]); strlcpy(t[2], M_Ftrim(f[2]), sizeof t[2]); - CV_CheaterWarning(targetPlayer, va("relative teleport by %d%s, %d%s, %d%s", + CV_CheaterWarning(targetPlayer, va("%s %d%s, %d%s, %d%s", + cheat == CHEAT_RELATIVE_TELEPORT + ? "relative teleport by" + : "teleport to", (int)f[0], t[0], (int)f[1], t[1], (int)f[2], t[2])); break; } diff --git a/src/m_cheat.c b/src/m_cheat.c index cbeefafb6..ac66a5c97 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -327,223 +327,21 @@ void Command_RTeleport_f(void) void Command_Teleport_f(void) { - fixed_t intx, inty, intz; - size_t i; - player_t *p = &players[consoleplayer]; - subsector_t *ss; + float x = atof(COM_Argv(1)); + float y = atof(COM_Argv(2)); + float z = atof(COM_Argv(3)); REQUIRE_CHEATS; REQUIRE_INLEVEL; - REQUIRE_SINGLEPLAYER; // TODO: make multiplayer compatible - if (COM_Argc() < 3 || COM_Argc() > 11) + if (COM_Argc() != 4) { - CONS_Printf(M_GetText("teleport -x -y -z -ang -aim : teleport to a location\nteleport -sp : teleport to specified checkpoint\n")); + CONS_Printf(M_GetText("teleport : teleport to a location\n")); return; } - if (!p->mo) - return; - - i = COM_CheckParm("-sp"); - if (i) - { - INT32 starpostnum = atoi(COM_Argv(i + 1)); // starpost number - INT32 starpostpath = atoi(COM_Argv(i + 2)); // quick, dirty way to distinguish between paths - - if (starpostnum < 0 || starpostpath < 0) - { - CONS_Alert(CONS_NOTICE, M_GetText("Negative starpost indexing is not valid.\n")); - return; - } - - if (!starpostnum) // spawnpoints... - { - mapthing_t *mt; - fixed_t offset; - - if (starpostpath >= numcoopstarts) - { - CONS_Alert(CONS_NOTICE, M_GetText("Player %d spawnpoint not found (%d max).\n"), starpostpath+1, numcoopstarts-1); - return; - } - - mt = playerstarts[starpostpath]; // Given above check, should never be NULL. - intx = mt->x<y<z<sector->ceilingheight - ss->sector->floorheight < p->mo->height) - { - CONS_Alert(CONS_NOTICE, M_GetText("Spawnpoint not in a valid location.\n")); - return; - } - - // Flagging a player's ambush will make them start on the ceiling - // Objectflip inverts - if (!!(mt->args[0]) ^ !!(mt->options & MTF_OBJECTFLIP)) - intz = ss->sector->ceilingheight - p->mo->height - offset; - else - intz = ss->sector->floorheight + offset; - - if (mt->options & MTF_OBJECTFLIP) // flip the player! - { - p->mo->eflags |= MFE_VERTICALFLIP; - p->mo->flags2 |= MF2_OBJECTFLIP; - } - else - { - p->mo->eflags &= ~MFE_VERTICALFLIP; - p->mo->flags2 &= ~MF2_OBJECTFLIP; - } - - p->mo->angle = p->drawangle = FixedAngle(mt->angle<mo->angle); - } - else // scan the thinkers to find starposts... - { - mobj_t *mo2 = NULL; - thinker_t *th; - - INT32 starpostmax = 0; - intz = starpostpath; // variable reuse - counting down for selection purposes - - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) - { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_STARPOST) - continue; - - if (mo2->health != starpostnum) - { - if (mo2->health > starpostmax) - starpostmax = mo2->health; - continue; - } - - if (intz--) - continue; - - break; - } - - if (th == &thlist[THINK_MOBJ]) - { - if (intz == starpostpath) - CONS_Alert(CONS_NOTICE, M_GetText("No starpost of position %d found (%d max).\n"), starpostnum, starpostmax); - else - CONS_Alert(CONS_NOTICE, M_GetText("Starpost of position %d, %d not found (%d, %d max).\n"), starpostnum, starpostpath, starpostmax, (starpostpath-intz)-1); - return; - } - - ss = R_PointInSubsectorOrNull(mo2->x, mo2->y); - if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height) - { - CONS_Alert(CONS_NOTICE, M_GetText("Starpost not in a valid location.\n")); - return; - } - - intx = mo2->x; - inty = mo2->y; - intz = mo2->z; - - if (mo2->flags2 & MF2_OBJECTFLIP) // flip the player! - { - p->mo->eflags |= MFE_VERTICALFLIP; - p->mo->flags2 |= MF2_OBJECTFLIP; - } - else - { - p->mo->eflags &= ~MFE_VERTICALFLIP; - p->mo->flags2 &= ~MF2_OBJECTFLIP; - } - - p->mo->angle = p->drawangle = mo2->angle; - P_SetPlayerAngle(p, p->mo->angle); - } - - CONS_Printf(M_GetText("Teleporting to checkpoint %d, %d...\n"), starpostnum, starpostpath); - } - else - { - i = COM_CheckParm("-nop"); // undocumented stupid addition to allow pivoting on the spot with -ang and -aim - if (i) - { - intx = p->mo->x; - inty = p->mo->y; - } - else - { - i = COM_CheckParm("-x"); - if (i) - intx = atoi(COM_Argv(i + 1))<sector->ceilingheight - ss->sector->floorheight < p->mo->height) - { - CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n")); - return; - } - i = COM_CheckParm("-z"); - if (i) - { - intz = atoi(COM_Argv(i + 1))<sector->floorheight) - intz = ss->sector->floorheight; - if (intz > ss->sector->ceilingheight - p->mo->height) - intz = ss->sector->ceilingheight - p->mo->height; - } - else - intz = ((p->mo->eflags & MFE_VERTICALFLIP) ? ss->sector->ceilingheight : ss->sector->floorheight); - - i = COM_CheckParm("-ang"); - if (i) - { - p->drawangle = p->mo->angle = FixedAngle(atoi(COM_Argv(i + 1))<mo->angle); - } - - i = COM_CheckParm("-aim"); - if (i) - { - angle_t aim = FixedAngle(atoi(COM_Argv(i + 1))<= ANGLE_90 && aim <= ANGLE_270) - { - CONS_Alert(CONS_NOTICE, M_GetText("Not a valid aiming angle (between +/-90).\n")); - return; - } - localaiming[0] = p->aiming = aim; - } - - CONS_Printf(M_GetText("Teleporting to %d, %d, %d...\n"), FixedInt(intx), FixedInt(inty), FixedInt(intz)); - } - - P_MapStart(); - if (!P_SetOrigin(p->mo, intx, inty, intz)) - CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n")); - else - S_StartSound(p->mo, sfx_mixup); - P_MapEnd(); + D_Cheat(consoleplayer, CHEAT_TELEPORT, + FLOAT_TO_FIXED(x), FLOAT_TO_FIXED(y), FLOAT_TO_FIXED(z)); } void Command_Skynum_f(void) diff --git a/src/m_cheat.h b/src/m_cheat.h index b272400fe..92e25243a 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -33,6 +33,7 @@ typedef enum { CHEAT_FLIP, CHEAT_HURT, CHEAT_RELATIVE_TELEPORT, + CHEAT_TELEPORT, CHEAT_DEVMODE, CHEAT_GIVEITEM, CHEAT_SCORE, From 5b2d791cf6d3eb748f0ce2a03ff6d60a426af01e Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 Apr 2023 01:01:17 -0700 Subject: [PATCH 4/5] Add goto command, teleport to a waypoint --- src/d_netcmd.c | 1 + src/m_cheat.c | 24 ++++++++++++++++++++++++ src/m_cheat.h | 1 + 3 files changed, 26 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1ab532025..1c974fa7a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1098,6 +1098,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("skynum", Command_Skynum_f); COM_AddCommand("weather", Command_Weather_f); COM_AddCommand("grayscale", Command_Grayscale_f); + COM_AddCommand("goto", Command_Goto_f); CV_RegisterVar(&cv_renderhitbox); CV_RegisterVar(&cv_devmode_screen); diff --git a/src/m_cheat.c b/src/m_cheat.c index ac66a5c97..dff5d27c2 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -579,6 +579,30 @@ void Command_Grayscale_f(void) COM_ImmedExecute("toggle palette \"\" GRAYPAL"); } +void Command_Goto_f(void) +{ + const INT32 id = atoi(COM_Argv(1)); + const waypoint_t *wayp = K_GetWaypointFromID(id); + + REQUIRE_CHEATS; + REQUIRE_INLEVEL; + + if (COM_Argc() != 2) + { + CONS_Printf(M_GetText("goto : teleport to a waypoint\n")); + return; + } + + if (wayp == NULL) + { + CONS_Alert(CONS_WARNING, "goto %d: no waypoint with that ID\n", id); + return; + } + + D_Cheat(consoleplayer, CHEAT_TELEPORT, + wayp->mobj->x, wayp->mobj->y, wayp->mobj->z); +} + // // OBJECTPLACE (and related variables) // diff --git a/src/m_cheat.h b/src/m_cheat.h index 92e25243a..a7a1c020c 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -83,6 +83,7 @@ void Command_RTeleport_f(void); void Command_Skynum_f(void); void Command_Weather_f(void); void Command_Grayscale_f(void); +void Command_Goto_f(void); #ifdef _DEBUG void Command_CauseCfail_f(void); #endif From 05b0ecb5b60d1a5b62d5ab3df4d45641026a68a6 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 8 Apr 2023 01:19:44 -0700 Subject: [PATCH 5/5] Add angle command, set your angle precisely --- src/d_netcmd.c | 15 +++++++++++++++ src/m_cheat.c | 11 +++++++++++ src/m_cheat.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1c974fa7a..a02242625 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1099,6 +1099,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("weather", Command_Weather_f); COM_AddCommand("grayscale", Command_Grayscale_f); COM_AddCommand("goto", Command_Goto_f); + COM_AddCommand("angle", Command_Angle_f); CV_RegisterVar(&cv_renderhitbox); CV_RegisterVar(&cv_devmode_screen); @@ -2051,6 +2052,10 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...) case CHEAT_SCORE: COPY(WRITEUINT32, UINT32); break; + + case CHEAT_ANGLE: + COPY(WRITEANGLE, angle_t); + break; } #undef COPY @@ -5790,6 +5795,16 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) break; } + case CHEAT_ANGLE: { + angle_t angle = READANGLE(*cp); + float anglef = FIXED_TO_FLOAT(AngleFixed(angle)); + + P_SetPlayerAngle(player, angle); + + CV_CheaterWarning(targetPlayer, va("angle = %d%s", (int)anglef, M_Ftrim(anglef))); + break; + } + case NUMBER_OF_CHEATS: break; } diff --git a/src/m_cheat.c b/src/m_cheat.c index dff5d27c2..d4e774f43 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -603,6 +603,17 @@ void Command_Goto_f(void) wayp->mobj->x, wayp->mobj->y, wayp->mobj->z); } +void Command_Angle_f(void) +{ + const float anglef = atof(COM_Argv(1)); + const angle_t angle = FixedAngle(FLOAT_TO_FIXED(anglef)); + + REQUIRE_CHEATS; + REQUIRE_INLEVEL; + + D_Cheat(consoleplayer, CHEAT_ANGLE, angle); +} + // // OBJECTPLACE (and related variables) // diff --git a/src/m_cheat.h b/src/m_cheat.h index a7a1c020c..d3c808d3e 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -37,6 +37,7 @@ typedef enum { CHEAT_DEVMODE, CHEAT_GIVEITEM, CHEAT_SCORE, + CHEAT_ANGLE, NUMBER_OF_CHEATS } cheat_t; @@ -84,6 +85,7 @@ void Command_Skynum_f(void); void Command_Weather_f(void); void Command_Grayscale_f(void); void Command_Goto_f(void); +void Command_Angle_f(void); #ifdef _DEBUG void Command_CauseCfail_f(void); #endif