Support displaying < 1 FPS in HUD

This commit is contained in:
UnknownShadow200 2024-02-21 19:41:13 +11:00
parent c4e8729034
commit dfcd025cab
2 changed files with 10 additions and 3 deletions

View File

@ -669,7 +669,7 @@ static void Game_Free(void* obj) {
Window_ProcessEvents(delta);\ Window_ProcessEvents(delta);\
if (!gameRunning) return;\ if (!gameRunning) return;\
\ \
if (delta > 1.0) delta = 1.0; /* avoid large delta with suspended process */ \ if (delta > 5.0) delta = 5.0; /* avoid large delta with suspended process */ \
if (delta > 0.0) { Game_FrameStart = render; Game_RenderFrame(delta); } if (delta > 0.0) { Game_FrameStart = render; Game_RenderFrame(delta); }
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB

View File

@ -88,13 +88,20 @@ static struct HUDScreen {
static void HUDScreen_RemakeLine1(struct HUDScreen* s) { static void HUDScreen_RemakeLine1(struct HUDScreen* s) {
cc_string status; char statusBuffer[STRING_SIZE * 2]; cc_string status; char statusBuffer[STRING_SIZE * 2];
int indices, ping, fps; int indices, ping, fps;
float real_fps;
String_InitArray(status, statusBuffer); String_InitArray(status, statusBuffer);
/* Don't remake texture when FPS isn't being shown */ /* Don't remake texture when FPS isn't being shown */
if (!Gui.ShowFPS && s->line1.tex.ID) return; if (!Gui.ShowFPS && s->line1.tex.ID) return;
fps = s->accumulator == 0 ? 1 : (int)(s->frames / s->accumulator); fps = s->accumulator == 0 ? 1 : (int)(s->frames / s->accumulator);
String_Format1(&status, "%i fps, ", &fps);
if (fps == 0) {
/* Running at less than 1 FPS.. */
real_fps = s->frames / s->accumulator;
String_Format1(&status, "%f1 fps, ", &real_fps);
} else {
String_Format1(&status, "%i fps, ", &fps);
}
if (Game_ClassicMode) { if (Game_ClassicMode) {
String_Format1(&status, "%i chunk updates", &Game.ChunkUpdates); String_Format1(&status, "%i chunk updates", &Game.ChunkUpdates);