From 204672800c3f56f5c7c433b184c0336d1c9a0ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 7 Sep 2024 15:58:03 +0200 Subject: [PATCH] Warning fix --- UI/DebugOverlay.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/UI/DebugOverlay.cpp b/UI/DebugOverlay.cpp index c432a42201..fec216f949 100644 --- a/UI/DebugOverlay.cpp +++ b/UI/DebugOverlay.cpp @@ -435,21 +435,23 @@ void DrawFPS(UIContext *ctx, const Bounds &bounds) { float vps, fps, actual_fps; __DisplayGetFPS(&vps, &fps, &actual_fps); - char fpsbuf[256]{}; - if (g_Config.iShowStatusFlags == ((int)ShowStatusFlags::FPS_COUNTER | (int)ShowStatusFlags::SPEED_COUNTER)) { + char fpsbuf[256]; + fpsbuf[0] = '\0'; + if ((g_Config.iShowStatusFlags & ((int)ShowStatusFlags::FPS_COUNTER | (int)ShowStatusFlags::SPEED_COUNTER)) == ((int)ShowStatusFlags::FPS_COUNTER | (int)ShowStatusFlags::SPEED_COUNTER)) { snprintf(fpsbuf, sizeof(fpsbuf), "%0.0f/%0.0f (%0.1f%%)", actual_fps, fps, vps / ((g_Config.iDisplayRefreshRate / 60.0f * 59.94f) / 100.0f)); } else { if (g_Config.iShowStatusFlags & (int)ShowStatusFlags::FPS_COUNTER) { snprintf(fpsbuf, sizeof(fpsbuf), "FPS: %0.1f", actual_fps); - } - if (g_Config.iShowStatusFlags & (int)ShowStatusFlags::SPEED_COUNTER) { - snprintf(fpsbuf, sizeof(fpsbuf), "%s Speed: %0.1f%%", fpsbuf, vps / (59.94f / 100.0f)); + } else if (g_Config.iShowStatusFlags & (int)ShowStatusFlags::SPEED_COUNTER) { + snprintf(fpsbuf, sizeof(fpsbuf), "Speed: %0.1f%%", vps / (59.94f / 100.0f)); } } #ifdef CAN_DISPLAY_CURRENT_BATTERY_CAPACITY if (g_Config.iShowStatusFlags & (int)ShowStatusFlags::BATTERY_PERCENT) { - snprintf(fpsbuf, sizeof(fpsbuf), "%s Battery: %d%%", fpsbuf, getCurrentBatteryCapacity()); + char temp[256]; + snprintf(temp, sizeof(temp), "%s Battery: %d%%", fpsbuf, getCurrentBatteryCapacity()); + snprintf(fpsbuf, sizeof(fpsbuf), "%s", temp); } #endif