From f763e66a1ffcb4cd8a06e30ad9de15a4c5139f4b Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 15 Oct 2023 22:18:19 +0200 Subject: Fix proton detection output (#534) Fixes Proton detection logic printing incorrect basename --- NorthstarDLL/logging/logging.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/NorthstarDLL/logging/logging.cpp b/NorthstarDLL/logging/logging.cpp index a68fe704..3416bb8c 100644 --- a/NorthstarDLL/logging/logging.cpp +++ b/NorthstarDLL/logging/logging.cpp @@ -261,12 +261,22 @@ void StartupLog() spdlog::info("Operating System: {} (Wine)", sysname); spdlog::info("Wine build: {}", wine_get_build_id()); + // STEAM_COMPAT_TOOL_PATHS is a colon separated lists of all compat tool paths used + // The first one tends to be the Proton path itself + // We extract the basename out of it to get the name used char* compatToolPtr = std::getenv("STEAM_COMPAT_TOOL_PATHS"); if (compatToolPtr) { - std::string compatToolPath(compatToolPtr); + std::string_view compatToolPath(compatToolPtr); - spdlog::info("Proton build: {}", compatToolPath.substr(compatToolPath.rfind("/") + 1)); + auto protonBasenameEnd = compatToolPath.find(":"); + if (protonBasenameEnd == std::string_view::npos) + protonBasenameEnd = 0; + auto protonBasenameStart = compatToolPath.rfind("/", protonBasenameEnd) + 1; + if (protonBasenameStart == std::string_view::npos) + protonBasenameStart = 0; + + spdlog::info("Proton build: {}", compatToolPath.substr(protonBasenameStart, protonBasenameEnd - protonBasenameStart)); } } else -- cgit v1.2.3