From 0e72a381a99c437116a75b6fe743f6b9b44417df Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Mon, 13 Nov 2023 17:53:16 +0700 Subject: [PATCH] widget instead of a message for the "idrate" cheat (#1254) Because of the monospaced font. * remove extern fps * don't report voxels if not found * add guard for VX_NearbySprites() --- src/hu_stuff.c | 33 ++++++++++++++++++++++++++++++--- src/i_video.h | 1 + src/m_cheat.c | 4 ---- src/p_user.c | 6 ------ src/r_main.c | 13 ++++--------- src/r_main.h | 2 +- src/r_things.c | 3 +-- src/r_voxel.c | 6 ++++++ src/r_voxel.h | 2 ++ 9 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index f4628de8..8d7e24b8 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -35,7 +35,9 @@ #include "p_map.h" // crosshair (linetarget) #include "m_misc2.h" #include "m_swap.h" +#include "i_video.h" // fps #include "r_main.h" +#include "r_voxel.h" #include "u_scanner.h" // global heads up display controls @@ -119,9 +121,10 @@ static hu_multiline_t w_monsec; //jff 2/16/98 new kill/secret widget for hud static hu_multiline_t w_sttime; // time above status bar static hu_multiline_t w_coord; static hu_multiline_t w_fps; +static hu_multiline_t w_rate; #define MAX_HUDS 3 -#define MAX_WIDGETS 10 +#define MAX_WIDGETS 15 static hu_widget_t doom_widgets[MAX_HUDS][MAX_WIDGETS] = { { @@ -151,6 +154,7 @@ static hu_widget_t boom_widgets[MAX_HUDS][MAX_WIDGETS] = { {&w_sttime, align_left, align_top}, {&w_coord, align_right, align_top}, {&w_fps, align_right, align_top}, + {&w_rate, align_left, align_top}, {NULL} }, { {&w_armor, align_left, align_bottom}, @@ -163,6 +167,7 @@ static hu_widget_t boom_widgets[MAX_HUDS][MAX_WIDGETS] = { {&w_sttime, align_left, align_bottom}, {&w_coord, align_right, align_top}, {&w_fps, align_right, align_top}, + {&w_rate, align_left, align_top}, {NULL} }, { {&w_health, align_right, align_top}, @@ -175,6 +180,7 @@ static hu_widget_t boom_widgets[MAX_HUDS][MAX_WIDGETS] = { {&w_sttime, align_left, align_bottom}, {&w_coord , align_right, align_top}, {&w_fps, align_right, align_top}, + {&w_rate, align_left, align_top}, {NULL} } }; @@ -548,6 +554,7 @@ static void HU_widget_build_ammo (void); static void HU_widget_build_armor (void); static void HU_widget_build_coord (void); static void HU_widget_build_fps (void); +static void HU_widget_build_rate (void); static void HU_widget_build_health (void); static void HU_widget_build_keys (void); static void HU_widget_build_frag (void); @@ -652,6 +659,10 @@ void HU_Start(void) &boom_font, colrngs[hudcolor_xyco], NULL, HU_widget_build_fps); + HUlib_init_multiline(&w_rate, (voxels_found ? 2 : 1), + &boom_font, colrngs[hudcolor_xyco], + NULL, HU_widget_build_rate); + HU_set_centered_message(); HU_disable_all_widgets(); @@ -1232,12 +1243,26 @@ static void HU_widget_build_coord (void) static void HU_widget_build_fps (void) { char hud_fpsstr[HU_MAXLINELENGTH/4]; - extern int fps; sprintf(hud_fpsstr,"\x1b%c%d \x1b%cFPS", '0'+CR_GRAY, fps, '0'+CR_ORIG); HUlib_add_string_to_cur_line(&w_fps, hud_fpsstr); } +static void HU_widget_build_rate (void) +{ + char hud_ratestr[HU_MAXLINELENGTH]; + + sprintf(hud_ratestr, "Sprites %4d Segs %4d Visplanes %4d FPS %3d", + rendered_vissprites, rendered_segs, rendered_visplanes, fps); + HUlib_add_string_to_cur_line(&w_rate, hud_ratestr); + + if (voxels_found) + { + sprintf(hud_ratestr, " Voxels %4d", rendered_voxels); + HUlib_add_string_to_cur_line(&w_rate, hud_ratestr); + } +} + // Crosshair boolean hud_crosshair_health; @@ -1627,6 +1652,7 @@ void HU_Ticker(void) } HU_cond_build_widget(&w_fps, plr->cheats & CF_SHOWFPS); + HU_cond_build_widget(&w_rate, plr->cheats & CF_RENDERSTATS); if (hud_displayed && scaledviewheight == SCREENHEIGHT && @@ -1888,7 +1914,8 @@ static const multiline_names_t {"monsec", "stats", &w_monsec}, {"sttime", "time", &w_sttime}, {"coord", "coords", &w_coord}, - {"fps", "rate", &w_fps}, + {"fps", NULL, &w_fps}, + {"rate", NULL, &w_rate}, {NULL}, }; diff --git a/src/i_video.h b/src/i_video.h index ac12c3c1..691f456f 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -75,6 +75,7 @@ extern boolean uncapped, default_uncapped; // [FG] uncapped rendering frame rate extern boolean fullscreen; extern boolean exclusive_fullscreen; extern int fpslimit; // when uncapped, limit framerate to this value +extern int fps; extern boolean integer_scaling; // [FG] force integer scales extern boolean vga_porch_flash; // emulate VGA "porch" behaviour extern int widescreen; // widescreen mode diff --git a/src/m_cheat.c b/src/m_cheat.c index 2b575fd9..99bb51e3 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -665,7 +665,6 @@ static void cheat_clev(char *buf) // killough 2/7/98: simplified using dprintf and made output more user-friendly static void cheat_mypos() { - plyr->cheats &= ~CF_RENDERSTATS; plyr->cheats ^= CF_MAPCOORDS; if ((plyr->cheats & CF_MAPCOORDS) == 0) plyr->message = ""; @@ -1162,10 +1161,7 @@ static void cheat_nuke() static void cheat_rate() { - plyr->cheats &= ~CF_MAPCOORDS; plyr->cheats ^= CF_RENDERSTATS; - if ((plyr->cheats & CF_RENDERSTATS) == 0) - plyr->message = ""; } //----------------------------------------------------------------------------- diff --git a/src/p_user.c b/src/p_user.c index 08803959..fba3c56e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -525,12 +525,6 @@ void P_PlayerThink (player_t* player) if (player->powers[pw_ironfeet] > 0) // killough player->powers[pw_ironfeet]--; - if (player->cheats & CF_RENDERSTATS) - { - extern void R_ShowRenderingStats(); - R_ShowRenderingStats(); - } - if (player->cheats & CF_MAPCOORDS) { extern void cheat_mypos_print(); diff --git a/src/r_main.c b/src/r_main.c index 44fa6483..e18cd4aa 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -713,20 +713,14 @@ void R_SetupFrame (player_t *player) // R_ShowStats // -int rendered_visplanes, rendered_segs, rendered_vissprites; - -void R_ShowRenderingStats(void) -{ - extern int fps; - displaymsg("Segs %d, Visplanes %d, Sprites %d, FPS %d", - rendered_segs, rendered_visplanes, rendered_vissprites, fps); -} +int rendered_visplanes, rendered_segs, rendered_vissprites, rendered_voxels; static void R_ClearStats(void) { rendered_visplanes = 0; rendered_segs = 0; rendered_vissprites = 0; + rendered_voxels = 0; } int autodetect_hom = 0; // killough 2/7/98: HOM autodetection flag @@ -824,7 +818,8 @@ void R_RenderPlayerView (player_t* player) // The head node is the last node output. R_RenderBSPNode (numnodes-1); - VX_NearbySprites (); + if (voxels_found) + VX_NearbySprites (); // [FG] update automap while playing if (automap_on) diff --git a/src/r_main.h b/src/r_main.h index 165f9c77..61783901 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -45,7 +45,7 @@ extern fixed_t viewheightfrac; // [FG] sprite clipping optimizations // Rendering stats // -extern int rendered_visplanes, rendered_segs, rendered_vissprites; +extern int rendered_visplanes, rendered_segs, rendered_vissprites, rendered_voxels; // // Lighting LUT. diff --git a/src/r_things.c b/src/r_things.c index c64b018d..e1511484 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -297,6 +297,7 @@ void R_InitSprites(char **namelist) void R_ClearSprites (void) { + rendered_vissprites = num_vissprite; num_vissprite = 0; // killough } @@ -1173,8 +1174,6 @@ void R_DrawMasked(void) } } - rendered_vissprites = num_vissprite; - // draw all vissprites back to front for (i = num_vissprite ;--i>=0; ) diff --git a/src/r_voxel.c b/src/r_voxel.c index 78a7f82f..c1d440fd 100644 --- a/src/r_voxel.c +++ b/src/r_voxel.c @@ -53,6 +53,8 @@ static struct Voxel * all_voxels[NUMSPRITES][MAX_FRAMES]; static int vx_rotate_items = 1; +boolean voxels_found = false; + // bits in the `face` byte of a slab enum VoxelFace @@ -272,6 +274,9 @@ static boolean VX_Load (int spr, int frame) // Note: this may return NULL struct Voxel * v = VX_Decode (buf, len); + if (v != NULL) + voxels_found = true; + all_voxels[spr][frame] = v; Z_Free (buf); @@ -353,6 +358,7 @@ static int VX_NewVisVoxel (void) void VX_ClearVoxels (void) { + rendered_voxels = num_visvoxels; num_visvoxels = 0; } diff --git a/src/r_voxel.h b/src/r_voxel.h index 8ec92d14..a3f2e6c4 100644 --- a/src/r_voxel.h +++ b/src/r_voxel.h @@ -27,4 +27,6 @@ boolean VX_ProjectVoxel (mobj_t * thing); void VX_DrawVoxel (vissprite_t * vis); +extern boolean voxels_found; + #endif /* __R_VOXEL__ */