Skip to content

Commit

Permalink
Merge pull request #122 from alliedmodders/psy/s2-linux-load-fix
Browse files Browse the repository at this point in the history
Fix load on Source 2 Linux servers when -game launch arg is missing
  • Loading branch information
psychonic authored Sep 29, 2023
2 parents 62dd3dd + 0cfae59 commit 57043e3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion loader/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ mm_LogFatal(const char *message, ...)
va_list ap;
char header[256];

printf("MMS: Fatal error: ");
va_start(ap, message);
vprintf(message, ap);
va_end(ap);
printf("\n");

fp = fopen(mm_fatal_logfile, "at");
if (!fp && (fp = fopen("metamod-fatal.log", "at")) == NULL)
return;
Expand Down Expand Up @@ -292,16 +298,28 @@ mm_GetGameName(char *buffer, size_t size)
#ifdef _WIN32
GetGameInfoStringFn func = (GetGameInfoStringFn)mm_GetLibAddress(pTier0, "?GetGameInfoString@@YAPEBDPEBD0PEAD_K@Z");
#else
GetGameInfoStringFn func = (GetGameInfoStringFn)mm_GetLibAddress(pTier0, "__Z17GetGameInfoStringPKcS0_Pcm");
GetGameInfoStringFn func = (GetGameInfoStringFn)mm_GetLibAddress(pTier0, "_Z17GetGameInfoStringPKcS0_Pcm");
#endif
if (func != nullptr)
{
static char szTmp[260];
strncpy(buffer, func("FileSystem/SearchPaths/Mod", "", szTmp, sizeof(szTmp)), size);
}
else
{
mm_LogFatal("Failed to resolve GetGameInfoString in fallback gamedir lookup.");
}

mm_UnloadLibrary(pTier0);
}
else
{
mm_LogFatal("Failed to load tier0 from \"%s\" in fallback gamedir lookup: %s", tier0_path, err);
}
}
else
{
mm_LogFatal("Failed to resolve tier0 path in fallback gamedir lookup.");
}
}

Expand Down

0 comments on commit 57043e3

Please sign in to comment.