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:
parent
16a270764c
commit
558a5bb446
@ -198,6 +198,7 @@ void
|
|||||||
mm_GetGameName(char *buffer, size_t size)
|
mm_GetGameName(char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
|
bool bHasDedicated = false;
|
||||||
|
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
static char game[128];
|
static char game[128];
|
||||||
@ -207,15 +208,18 @@ mm_GetGameName(char *buffer, size_t size)
|
|||||||
LPWSTR *wargv = CommandLineToArgvW(pCmdLine, &argc);
|
LPWSTR *wargv = CommandLineToArgvW(pCmdLine, &argc);
|
||||||
for (int i = 0; i < argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
if (wcscmp(wargv[i], L"-game") != 0)
|
if (wcscmp(wargv[i], L"-game") == 0)
|
||||||
continue;
|
{
|
||||||
|
if (++i >= argc)
|
||||||
|
break;
|
||||||
|
|
||||||
if (++i >= argc)
|
wcstombs(buffer, wargv[i], size);
|
||||||
break;
|
buffer[size-1] = '\0';
|
||||||
|
}
|
||||||
wcstombs(buffer, wargv[i], size);
|
else if (wcscmp(wargv[i], L"-dedicated") == 0)
|
||||||
buffer[size-1] = '\0';
|
{
|
||||||
break;
|
bHasDedicated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFree(wargv);
|
LocalFree(wargv);
|
||||||
@ -225,15 +229,18 @@ mm_GetGameName(char *buffer, size_t size)
|
|||||||
char **argv = *_NSGetArgv();
|
char **argv = *_NSGetArgv();
|
||||||
for (int i = 0; i < argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
if (strcmp(argv[i], "-game") != 0)
|
if (strcmp(argv[i], "-game") == 0)
|
||||||
continue;
|
{
|
||||||
|
if (++i >= argc)
|
||||||
|
break;
|
||||||
|
|
||||||
if (++i >= argc)
|
strncpy(buffer, argv[i], size);
|
||||||
break;
|
buffer[size-1] = '\0';
|
||||||
|
}
|
||||||
strncpy(buffer, argv[i], size);
|
else if (strcmp(argv[i], "-dedicated") == 0)
|
||||||
buffer[size-1] = '\0';
|
{
|
||||||
break;
|
bHasDedicated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
@ -250,13 +257,17 @@ mm_GetGameName(char *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
strncpy(buffer, arg, size);
|
strncpy(buffer, arg, size);
|
||||||
buffer[size-1] = '\0';
|
buffer[size-1] = '\0';
|
||||||
break;
|
bNextIsGame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(arg, "-game") == 0)
|
if (strcmp(arg, "-game") == 0)
|
||||||
{
|
{
|
||||||
bNextIsGame = true;
|
bNextIsGame = true;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(arg, "-dedicated") == 0)
|
||||||
|
{
|
||||||
|
bHasDedicated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(arg);
|
free(arg);
|
||||||
@ -268,9 +279,19 @@ mm_GetGameName(char *buffer, size_t size)
|
|||||||
|
|
||||||
if (buffer[0] == 0)
|
if (buffer[0] == 0)
|
||||||
{
|
{
|
||||||
// FIXME: this was "." and is now "dota" for Source2.
|
// HackHackHack - Different engines have different defaults if -game isn't specified
|
||||||
// That breaks Dark Messiah compatibility.
|
// we only use this for game detection, and not even in all cases. Old behavior was to
|
||||||
strncpy(buffer, "dota", size);
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user