From 9009f75bf5fd33e13abae5762d31968b39f233c3 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 15 May 2022 23:05:41 +0100 Subject: Fix GetEngineBuildNumber and entity property stuff I still haven't bothered to flesh out all the possible indices for GetEngineBuildNumber but we're back to being able to use it to detect The Last Stand (as a result of some old version testing Aciidz did - thanks again!). This means we can do away with the terrible map file- based hotfix. Also, turns out sst_l4d_testwarp doesn't work if the plugin gets loaded early via VDF because certain SendTable offsets start out negated, so we work around that too now. --- src/engineapi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/engineapi.c') diff --git a/src/engineapi.c b/src/engineapi.c index 369bebd..ec3d857 100644 --- a/src/engineapi.c +++ b/src/engineapi.c @@ -15,6 +15,7 @@ */ #include // used in generated code +#include // " #include // " #include "con_.h" @@ -43,6 +44,8 @@ void *globalvars; DECL_VFUNC_DYN(void *, GetAllServerClasses) DECL_VFUNC_DYN(int, GetEngineBuildNumber) +DECL_VFUNC(int, GetEngineBuildNumber_newl4d2, 99) // duping gamedata entry, yuck + #include bool engineapi_init(int pluginver) { @@ -84,9 +87,13 @@ bool engineapi_init(int pluginver) { _gametype_tag |= _gametype_tag_Portal1; } - // TERRIBLE HACK: TODO(compat): come up with a better method later - if (GAMETYPE_MATCHES(L4D2) && os_access(OS_LIT( - "update/maps/c14m1_junkyard.bsp"), R_OK) != -1) { + // Ugly HACK: we want to call GetEngineBuildNumber to find out if we're on a + // Last Stand version (because they changed entity vtables for some reason), + // but that function also got moved in 2.0.4.1 which means we can't call it + // till gamedata is set up, so we have to have a bit of redundant logic here + // to bootstrap things. + if (GAMETYPE_MATCHES(L4D2) && GAMETYPE_MATCHES(Client013) && + VCALL(engclient, GetEngineBuildNumber_newl4d2) >= 2200) { _gametype_tag |= _gametype_tag_TheLastStand; } @@ -100,7 +107,6 @@ bool engineapi_init(int pluginver) { has_off_SP_varname && has_off_SP_offset) { initentprops(VCALL(srvdll, GetAllServerClasses)); } - return true; } -- cgit v1.2.3