From b86ecf7441ae356d45c5124ecafc46c751b727d1 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 18 Apr 2023 22:59:21 +0200 Subject: [PATCH] Keep preceding 0 in firmware strings --- rpcs3/util/sysinfo.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index fdfa5991ec..24c8e19273 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -415,13 +415,25 @@ std::string utils::get_firmware_version() version = version.substr(start, end - start); // Trim version (e.g. '04.8900' becomes '4.89') - const usz trim_start = version.find_first_not_of('0'); + usz trim_start = version.find_first_not_of('0'); if (trim_start == umax) { return {}; } + // Keep at least one preceding 0 (e.g. '00.3100' becomes '0.31' instead of '.31') + if (version[trim_start] == '.') + { + if (trim_start == 0) + { + // Version starts with '.' for some reason + return {}; + } + + trim_start--; + } + const usz dot_pos = version.find_first_of('.', trim_start); if (dot_pos == umax)