From e01565fc0f7ce60bcce60e2e44b675ba77f1d6d2 Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Sun, 7 Jan 2018 22:20:55 +0000 Subject: [PATCH] Add support for parsing comments in steam.inf --- extension/extension.cpp | 29 +++++++++++++++++++++++++---- extension/version.h | 4 ++-- product.version | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/extension/extension.cpp b/extension/extension.cpp index 0104aff..5e593aa 100644 --- a/extension/extension.cpp +++ b/extension/extension.cpp @@ -57,7 +57,7 @@ char crashGamePath[512]; char crashCommandLine[1024]; char crashSourceModPath[512]; char crashGameDirectory[256]; -char steamInf[512]; +char steamInf[1024]; char dumpStoragePath[512]; char logPath[512]; @@ -570,11 +570,13 @@ bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late) FILE *steamInfFile = fopen(steamInfPath, "rb"); if (steamInfFile) { - char steamInfTemp[256] = {0}; + char steamInfTemp[1024] = {0}; fread(steamInfTemp, sizeof(char), sizeof(steamInfTemp) - 1, steamInfFile); fclose(steamInfFile); + unsigned commentChars = 0; + unsigned valueChars = 0; unsigned source = 0; strcpy(steamInf, "\nSteam_"); unsigned target = 7; // strlen("\nSteam_"); @@ -583,20 +585,39 @@ bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late) source++; break; } + if (steamInfTemp[source] == '/') { + source++; + commentChars++; + continue; + } + if (commentChars == 1) { + commentChars = 0; + steamInf[target++] = '/'; + valueChars++; + } if (steamInfTemp[source] == '\r') { source++; continue; } if (steamInfTemp[source] == '\n') { + commentChars = 0; source++; if (steamInfTemp[source] == '\0') { break; } - strcpy(&steamInf[target], "\nSteam_"); - target += 7; + if (valueChars > 0) { + valueChars = 0; + strcpy(&steamInf[target], "\nSteam_"); + target += 7; + } + continue; + } + if (commentChars >= 2) { + source++; continue; } steamInf[target++] = steamInfTemp[source++]; + valueChars++; } } diff --git a/extension/version.h b/extension/version.h index 2fd77ab..f9a2651 100644 --- a/extension/version.h +++ b/extension/version.h @@ -18,9 +18,9 @@ #define SM_BUILD_TAG "-manual" #define SM_BUILD_UNIQUEID "[MANUAL BUILD]" -#define SM_VERSION "2.3.2" +#define SM_VERSION "2.3.3" #define SM_FULL_VERSION SM_VERSION SM_BUILD_TAG -#define SM_FILE_VERSION 2,3,2,0 +#define SM_FILE_VERSION 2,3,3,0 #endif diff --git a/product.version b/product.version index f90b1af..0bee604 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -2.3.2 +2.3.3