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