From 9074661ab5e2620aacb55f313bcdbb335b45bdbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=E1=BA=A1m=20Minh=20D=C6=B0=C6=A1ng?= <47449032+thisis2838@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:20:21 +0700 Subject: [PATCH 1/2] Fix build number algo to use both methods Some early steampipe builds use the typical version number print like pre-steampipe which does not work with the version command backtracing method (at least at the time of writing). --- spt/utils/game_detection.cpp | 91 ++++++++++++++---------------------- 1 file changed, 34 insertions(+), 57 deletions(-) diff --git a/spt/utils/game_detection.cpp b/spt/utils/game_detection.cpp index 0f22e105..98ad66b5 100644 --- a/spt/utils/game_detection.cpp +++ b/spt/utils/game_detection.cpp @@ -237,7 +237,6 @@ namespace utils build_num -= 35739; return build_num; } -#ifndef SSDK2013 void StartBuildNumberSearch() { BuildResult = std::async( @@ -270,70 +269,48 @@ namespace utils const char* date_str = wholeString + 20; build_num = DateToBuildNumber(date_str); } - else + + if (match < 0 || build_num < 0) { - Warning( - "Was unable to find date string! Build information not available\n"); +#ifdef SSDK2013 + Warning("Was unable to find date string! Trying fallback via version command...\n"); + + ConCommand_guts* versionCommand = + reinterpret_cast(g_pCVar->FindCommand("version")); + int build_num = -1; + + if (versionCommand) + { + uint8_t* buildNumPtrPtr = + reinterpret_cast(versionCommand->m_fnCommandCallback) + + 3; + + if (buildNumPtrPtr >= moduleStart && buildNumPtrPtr <= moduleEnd) + { + uint8_t* buildNumPtr = + *reinterpret_cast(buildNumPtrPtr); + + if (buildNumPtr >= moduleStart && buildNumPtr <= moduleEnd) + { + build_num = *reinterpret_cast(buildNumPtr); + } + } + } + if (build_num >= 0) + { + return build_num; + } +#else + Warning("Was unable to find date string for build number!\n"); +#endif + Warning("Build information not available\n"); } } return build_num; }); } -#else - int GetBuildNumberViaVersionCommand(uint8_t* moduleStart, uint8_t* moduleEnd) - { - ConCommand_guts* versionCommand = reinterpret_cast(g_pCVar->FindCommand("version")); - int build_num = -1; - if (versionCommand) - { - uint8_t* buildNumPtrPtr = reinterpret_cast(versionCommand->m_fnCommandCallback) + 3; - - if (buildNumPtrPtr >= moduleStart && buildNumPtrPtr <= moduleEnd) - { - uint8_t* buildNumPtr = *reinterpret_cast(buildNumPtrPtr); - - if (buildNumPtr >= moduleStart && buildNumPtr <= moduleEnd) - { - build_num = *reinterpret_cast(buildNumPtr); - } - } - } - - if (build_num == -1) - { - Warning("Build information not available!\n"); - } - - return build_num; - } - - void StartBuildNumberSearch() - { - BuildResult = std::async(std::launch::async, - []() - { - void* handle; - uint8_t* moduleStart; - uint8_t* moduleEnd; - size_t moduleSize; - int build_num = -1; - - if (MemUtils::GetModuleInfo(L"engine.dll", - &handle, - reinterpret_cast(&moduleStart), - &moduleSize)) - { - moduleEnd = moduleStart + moduleSize; - build_num = - GetBuildNumberViaVersionCommand(moduleStart, moduleEnd); - } - - return build_num; - }); - } -#endif bool DataInModule(void* ptr, size_t nBytes, void* modBase, size_t modSize) { From 4e8ca2e850a40bcac50731000f17ef4242227740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=E1=BA=A1m=20Minh=20D=C6=B0=C6=A1ng?= <47449032+thisis2838@users.noreply.github.com> Date: Thu, 22 Jan 2026 22:27:56 +0700 Subject: [PATCH 2/2] Add SPT: prefix to spew and change one warning to be dev --- spt/utils/game_detection.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spt/utils/game_detection.cpp b/spt/utils/game_detection.cpp index 98ad66b5..3c3e01d8 100644 --- a/spt/utils/game_detection.cpp +++ b/spt/utils/game_detection.cpp @@ -265,7 +265,7 @@ namespace utils { const char* wholeString = reinterpret_cast(moduleStart) + match; - DevMsg("Found date string: %s\n", wholeString); + DevMsg("SPT: Found date string: %s\n", wholeString); const char* date_str = wholeString + 20; build_num = DateToBuildNumber(date_str); } @@ -273,7 +273,7 @@ namespace utils if (match < 0 || build_num < 0) { #ifdef SSDK2013 - Warning("Was unable to find date string! Trying fallback via version command...\n"); + DevWarning("SPT: Was unable to find date string! Trying fallback via version command...\n"); ConCommand_guts* versionCommand = reinterpret_cast(g_pCVar->FindCommand("version")); @@ -301,9 +301,9 @@ namespace utils return build_num; } #else - Warning("Was unable to find date string for build number!\n"); + Warning("SPT: Was unable to find date string for build number!\n"); #endif - Warning("Build information not available\n"); + Warning("SPT: Build information not available\n"); } }