1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-11-29 11:24:19 +01:00

Restore Dark Messiah compat.

This commit is contained in:
Nicholas Hastings 2017-04-15 10:23:36 -04:00
parent 16a270764c
commit 558a5bb446

View File

@ -198,6 +198,7 @@ void
mm_GetGameName(char *buffer, size_t size)
{
buffer[0] = '\0';
bool bHasDedicated = false;
#if defined _WIN32
static char game[128];
@ -207,15 +208,18 @@ mm_GetGameName(char *buffer, size_t size)
LPWSTR *wargv = CommandLineToArgvW(pCmdLine, &argc);
for (int i = 0; i < argc; ++i)
{
if (wcscmp(wargv[i], L"-game") != 0)
continue;
if (wcscmp(wargv[i], L"-game") == 0)
{
if (++i >= argc)
break;
if (++i >= argc)
break;
wcstombs(buffer, wargv[i], size);
buffer[size-1] = '\0';
break;
wcstombs(buffer, wargv[i], size);
buffer[size-1] = '\0';
}
else if (wcscmp(wargv[i], L"-dedicated") == 0)
{
bHasDedicated = true;
}
}
LocalFree(wargv);
@ -225,15 +229,18 @@ mm_GetGameName(char *buffer, size_t size)
char **argv = *_NSGetArgv();
for (int i = 0; i < argc; ++i)
{
if (strcmp(argv[i], "-game") != 0)
continue;
if (strcmp(argv[i], "-game") == 0)
{
if (++i >= argc)
break;
if (++i >= argc)
break;
strncpy(buffer, argv[i], size);
buffer[size-1] = '\0';
break;
strncpy(buffer, argv[i], size);
buffer[size-1] = '\0';
}
else if (strcmp(argv[i], "-dedicated") == 0)
{
bHasDedicated = true;
}
}
#elif defined __linux__
@ -250,13 +257,17 @@ mm_GetGameName(char *buffer, size_t size)
{
strncpy(buffer, arg, size);
buffer[size-1] = '\0';
break;
bNextIsGame = false;
}
if (strcmp(arg, "-game") == 0)
{
bNextIsGame = true;
}
else if (strcmp(arg, "-dedicated") == 0)
{
bHasDedicated = true;
}
}
free(arg);
@ -268,9 +279,19 @@ mm_GetGameName(char *buffer, size_t size)
if (buffer[0] == 0)
{
// FIXME: this was "." and is now "dota" for Source2.
// That breaks Dark Messiah compatibility.
strncpy(buffer, "dota", size);
// HackHackHack - Different engines have different defaults if -game isn't specified
// we only use this for game detection, and not even in all cases. Old behavior was to
// give back ".", which was only really accurate for Dark Messiah. We'll add a special
// case for Source2 / Dota as well, since it only supports gameinfo loading, which relies
// on accuracy here more than VSP loading.
if (bHasDedicated)
{
strncpy(buffer, "dota", size);
}
else
{
strncpy(buffer, ".", size);
}
}
}