Skip to content

Commit

Permalink
Fixed mods parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpaterakis committed Aug 27, 2022
1 parent 5e306c2 commit 7e0b0ca
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sgdboop.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,17 @@ struct nonSteamApp* getSourceMods(const char* type)
continue;
}

while ((read = readLine(&line, &len, fp)) != -1) {
int foundGameKey = 0;

while ((read = readLine(&line, &len, fp)) != -1) {

// If line contains the "game" key, get the mod's name and create the struct entry
unsigned char* commentChar = strstr(line, "//");
unsigned char* nameStartChar = strstr(line, "game");
unsigned char* steamAppIdStartChar = strstr(line, "SteamAppId");

if (nameStartChar > 0 && commentChar == 0) {
// Make sure to first capture the "game" key, properly
if (nameStartChar > 0 && commentChar == 0 && !foundGameKey && (nameStartChar == line || isspace(*(nameStartChar - 1))) && isspace(*(nameStartChar + 4))) {

nameStartChar = strstr(line, "\"") + 1;
unsigned char* nameEndChar = strstr(nameStartChar, "\"");
Expand Down Expand Up @@ -633,13 +635,15 @@ struct nonSteamApp* getSourceMods(const char* type)
strcpy(sourceModsNames[modsCount], nameStartChar);
strcpy(sourceModsDirs[modsCount], dir->d_name);

foundGameKey = 1;

if (goldsource) {
modsCount++;
break;
}
}
}
else if (steamAppIdStartChar > 0) {
else if (steamAppIdStartChar > 0 && foundGameKey) {

// If line contains the "SteamAppId" key, get the mod's name and create the struct entry
unsigned char* steamAppIdStartChar = strstr(line, "SteamAppId");
Expand Down

0 comments on commit 7e0b0ca

Please sign in to comment.