diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2022-04-26 03:01:34 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2022-04-26 03:01:34 +0100 |
commit | f4fb50b6c618786e52f4d7caa8b46ca599dccfa1 (patch) | |
tree | 558b56ac1b3cde72c4c3a46f7f2d69680a5e4bae /src | |
parent | 117f3ad6ae3fb6df54bc553bd1efbab080d39606 (diff) |
Fix loading in early L4D2 builds
This was dumb.
Diffstat (limited to 'src')
-rw-r--r-- | src/gameinfo.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/gameinfo.c b/src/gameinfo.c index 6d4ddd5..9540054 100644 --- a/src/gameinfo.c +++ b/src/gameinfo.c @@ -244,21 +244,22 @@ bool gameinfo_init(void *(*ifacef)(const char *, int *)) { typedef char *(*VCALLCONV GetGameDirectory_func)(void *this); GetGameDirectory_func **engclient; int off; - if (engclient = ifacef("VEngineClient015", 0)) { // portal 2 + if (engclient = ifacef("VEngineClient015", 0)) { // portal 2 (post-release?) off = 35; } - else if (engclient = ifacef("VEngineClient014", 0)) { // bms, l4d2 2000 - off = 36; + else if (engclient = ifacef("VEngineClient014", 0)) { // l4d2000-~2027, bms? + if (!GAMETYPE_MATCHES(L4D2x)) goto unsup; + off = 73; // YES, THIS IS SEVENTY THREE ALL OF A SUDDEN. I KNOW. CRAZY. } else if (engclient = ifacef("VEngineClient013", 0)) { // ...most things? - if (GAMETYPE_MATCHES(L4Dx)) off = 36; // l4d2 changed it BACK?!? + if (GAMETYPE_MATCHES(L4Dx)) off = 36; // THEY CHANGED IT BACK LATER!? else off = 35; } else if (engclient = ifacef("VEngineClient012", 0)) { // dmomm, ep1, ... off = 37; } else { - con_warn("gameinfo: unsupported VEngineClient interface\n"); +unsup: con_warn("gameinfo: unsupported VEngineClient interface\n"); return false; } GetGameDirectory_func GetGameDirectory = (*engclient)[off]; @@ -286,19 +287,16 @@ bool gameinfo_init(void *(*ifacef)(const char *, int *)) { con_warn("gameinfo: invalid game directory path!\n"); return false; } - // immediately bounds check /gameinfo as we cat that into an equal sized - // buffer down below :^) - if (gamedirlen + sizeof("/gameinfo.txt") > sizeof(gamedir) / - sizeof(*gamedir)) { - con_warn("gameinfo: game directory path is too long!\n"); - return false; - } #else // no need to munge charset, use the string pointer directly gameinfo_gamedir = GetGameDirectory(engclient); int gamedirlen = strlen(gameinfo_gamedir); #endif - + if (gamedirlen + sizeof("/gameinfo.txt") > sizeof(gamedir) / + sizeof(*gamedir)) { + con_warn("gameinfo: game directory path is too long!\n"); + return false; + } os_char gameinfopath[PATH_MAX]; memcpy(gameinfopath, gameinfo_gamedir, gamedirlen * sizeof(*gameinfo_gamedir)); |