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()
This commit is contained in:
Roman Fomin 2023-11-13 17:53:16 +07:00 committed by GitHub
parent 6b0359b01e
commit 0e72a381a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 25 deletions

View File

@ -35,7 +35,9 @@
#include "p_map.h" // crosshair (linetarget) #include "p_map.h" // crosshair (linetarget)
#include "m_misc2.h" #include "m_misc2.h"
#include "m_swap.h" #include "m_swap.h"
#include "i_video.h" // fps
#include "r_main.h" #include "r_main.h"
#include "r_voxel.h"
#include "u_scanner.h" #include "u_scanner.h"
// global heads up display controls // 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_sttime; // time above status bar
static hu_multiline_t w_coord; static hu_multiline_t w_coord;
static hu_multiline_t w_fps; static hu_multiline_t w_fps;
static hu_multiline_t w_rate;
#define MAX_HUDS 3 #define MAX_HUDS 3
#define MAX_WIDGETS 10 #define MAX_WIDGETS 15
static hu_widget_t doom_widgets[MAX_HUDS][MAX_WIDGETS] = { 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_sttime, align_left, align_top},
{&w_coord, align_right, align_top}, {&w_coord, align_right, align_top},
{&w_fps, align_right, align_top}, {&w_fps, align_right, align_top},
{&w_rate, align_left, align_top},
{NULL} {NULL}
}, { }, {
{&w_armor, align_left, align_bottom}, {&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_sttime, align_left, align_bottom},
{&w_coord, align_right, align_top}, {&w_coord, align_right, align_top},
{&w_fps, align_right, align_top}, {&w_fps, align_right, align_top},
{&w_rate, align_left, align_top},
{NULL} {NULL}
}, { }, {
{&w_health, align_right, align_top}, {&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_sttime, align_left, align_bottom},
{&w_coord , align_right, align_top}, {&w_coord , align_right, align_top},
{&w_fps, align_right, align_top}, {&w_fps, align_right, align_top},
{&w_rate, align_left, align_top},
{NULL} {NULL}
} }
}; };
@ -548,6 +554,7 @@ static void HU_widget_build_ammo (void);
static void HU_widget_build_armor (void); static void HU_widget_build_armor (void);
static void HU_widget_build_coord (void); static void HU_widget_build_coord (void);
static void HU_widget_build_fps (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_health (void);
static void HU_widget_build_keys (void); static void HU_widget_build_keys (void);
static void HU_widget_build_frag (void); static void HU_widget_build_frag (void);
@ -652,6 +659,10 @@ void HU_Start(void)
&boom_font, colrngs[hudcolor_xyco], &boom_font, colrngs[hudcolor_xyco],
NULL, HU_widget_build_fps); 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_set_centered_message();
HU_disable_all_widgets(); HU_disable_all_widgets();
@ -1232,12 +1243,26 @@ static void HU_widget_build_coord (void)
static void HU_widget_build_fps (void) static void HU_widget_build_fps (void)
{ {
char hud_fpsstr[HU_MAXLINELENGTH/4]; char hud_fpsstr[HU_MAXLINELENGTH/4];
extern int fps;
sprintf(hud_fpsstr,"\x1b%c%d \x1b%cFPS", '0'+CR_GRAY, fps, '0'+CR_ORIG); 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); 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 // Crosshair
boolean hud_crosshair_health; 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_fps, plr->cheats & CF_SHOWFPS);
HU_cond_build_widget(&w_rate, plr->cheats & CF_RENDERSTATS);
if (hud_displayed && if (hud_displayed &&
scaledviewheight == SCREENHEIGHT && scaledviewheight == SCREENHEIGHT &&
@ -1888,7 +1914,8 @@ static const multiline_names_t
{"monsec", "stats", &w_monsec}, {"monsec", "stats", &w_monsec},
{"sttime", "time", &w_sttime}, {"sttime", "time", &w_sttime},
{"coord", "coords", &w_coord}, {"coord", "coords", &w_coord},
{"fps", "rate", &w_fps}, {"fps", NULL, &w_fps},
{"rate", NULL, &w_rate},
{NULL}, {NULL},
}; };

View File

@ -75,6 +75,7 @@ extern boolean uncapped, default_uncapped; // [FG] uncapped rendering frame rate
extern boolean fullscreen; extern boolean fullscreen;
extern boolean exclusive_fullscreen; extern boolean exclusive_fullscreen;
extern int fpslimit; // when uncapped, limit framerate to this value extern int fpslimit; // when uncapped, limit framerate to this value
extern int fps;
extern boolean integer_scaling; // [FG] force integer scales extern boolean integer_scaling; // [FG] force integer scales
extern boolean vga_porch_flash; // emulate VGA "porch" behaviour extern boolean vga_porch_flash; // emulate VGA "porch" behaviour
extern int widescreen; // widescreen mode extern int widescreen; // widescreen mode

View File

@ -665,7 +665,6 @@ static void cheat_clev(char *buf)
// killough 2/7/98: simplified using dprintf and made output more user-friendly // killough 2/7/98: simplified using dprintf and made output more user-friendly
static void cheat_mypos() static void cheat_mypos()
{ {
plyr->cheats &= ~CF_RENDERSTATS;
plyr->cheats ^= CF_MAPCOORDS; plyr->cheats ^= CF_MAPCOORDS;
if ((plyr->cheats & CF_MAPCOORDS) == 0) if ((plyr->cheats & CF_MAPCOORDS) == 0)
plyr->message = ""; plyr->message = "";
@ -1162,10 +1161,7 @@ static void cheat_nuke()
static void cheat_rate() static void cheat_rate()
{ {
plyr->cheats &= ~CF_MAPCOORDS;
plyr->cheats ^= CF_RENDERSTATS; plyr->cheats ^= CF_RENDERSTATS;
if ((plyr->cheats & CF_RENDERSTATS) == 0)
plyr->message = "";
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -525,12 +525,6 @@ void P_PlayerThink (player_t* player)
if (player->powers[pw_ironfeet] > 0) // killough if (player->powers[pw_ironfeet] > 0) // killough
player->powers[pw_ironfeet]--; player->powers[pw_ironfeet]--;
if (player->cheats & CF_RENDERSTATS)
{
extern void R_ShowRenderingStats();
R_ShowRenderingStats();
}
if (player->cheats & CF_MAPCOORDS) if (player->cheats & CF_MAPCOORDS)
{ {
extern void cheat_mypos_print(); extern void cheat_mypos_print();

View File

@ -713,20 +713,14 @@ void R_SetupFrame (player_t *player)
// R_ShowStats // R_ShowStats
// //
int rendered_visplanes, rendered_segs, rendered_vissprites; int rendered_visplanes, rendered_segs, rendered_vissprites, rendered_voxels;
void R_ShowRenderingStats(void)
{
extern int fps;
displaymsg("Segs %d, Visplanes %d, Sprites %d, FPS %d",
rendered_segs, rendered_visplanes, rendered_vissprites, fps);
}
static void R_ClearStats(void) static void R_ClearStats(void)
{ {
rendered_visplanes = 0; rendered_visplanes = 0;
rendered_segs = 0; rendered_segs = 0;
rendered_vissprites = 0; rendered_vissprites = 0;
rendered_voxels = 0;
} }
int autodetect_hom = 0; // killough 2/7/98: HOM autodetection flag 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. // The head node is the last node output.
R_RenderBSPNode (numnodes-1); R_RenderBSPNode (numnodes-1);
VX_NearbySprites (); if (voxels_found)
VX_NearbySprites ();
// [FG] update automap while playing // [FG] update automap while playing
if (automap_on) if (automap_on)

View File

@ -45,7 +45,7 @@ extern fixed_t viewheightfrac; // [FG] sprite clipping optimizations
// Rendering stats // Rendering stats
// //
extern int rendered_visplanes, rendered_segs, rendered_vissprites; extern int rendered_visplanes, rendered_segs, rendered_vissprites, rendered_voxels;
// //
// Lighting LUT. // Lighting LUT.

View File

@ -297,6 +297,7 @@ void R_InitSprites(char **namelist)
void R_ClearSprites (void) void R_ClearSprites (void)
{ {
rendered_vissprites = num_vissprite;
num_vissprite = 0; // killough num_vissprite = 0; // killough
} }
@ -1173,8 +1174,6 @@ void R_DrawMasked(void)
} }
} }
rendered_vissprites = num_vissprite;
// draw all vissprites back to front // draw all vissprites back to front
for (i = num_vissprite ;--i>=0; ) for (i = num_vissprite ;--i>=0; )

View File

@ -53,6 +53,8 @@ static struct Voxel * all_voxels[NUMSPRITES][MAX_FRAMES];
static int vx_rotate_items = 1; static int vx_rotate_items = 1;
boolean voxels_found = false;
// bits in the `face` byte of a slab // bits in the `face` byte of a slab
enum VoxelFace enum VoxelFace
@ -272,6 +274,9 @@ static boolean VX_Load (int spr, int frame)
// Note: this may return NULL // Note: this may return NULL
struct Voxel * v = VX_Decode (buf, len); struct Voxel * v = VX_Decode (buf, len);
if (v != NULL)
voxels_found = true;
all_voxels[spr][frame] = v; all_voxels[spr][frame] = v;
Z_Free (buf); Z_Free (buf);
@ -353,6 +358,7 @@ static int VX_NewVisVoxel (void)
void VX_ClearVoxels (void) void VX_ClearVoxels (void)
{ {
rendered_voxels = num_visvoxels;
num_visvoxels = 0; num_visvoxels = 0;
} }

View File

@ -27,4 +27,6 @@ boolean VX_ProjectVoxel (mobj_t * thing);
void VX_DrawVoxel (vissprite_t * vis); void VX_DrawVoxel (vissprite_t * vis);
extern boolean voxels_found;
#endif /* __R_VOXEL__ */ #endif /* __R_VOXEL__ */