summaryrefslogtreecommitdiffhomepage
path: root/src/gameinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gameinfo.c')
-rw-r--r--src/gameinfo.c24
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));