From 245f63c4a58b36dc46731758063c03aba2d3ec06 Mon Sep 17 00:00:00 2001 From: Willian Henrique Date: Tue, 15 Nov 2022 21:19:47 -0300 Subject: Improve L4D2 and Portal gametype detection Adds tags for L4D2 2147 and Portal 3420. Committer's note: really the gamedata system might benefit from improvement in the future to support things like numerical ranges, but this will do for now. --- src/engineapi.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/engineapi.c') diff --git a/src/engineapi.c b/src/engineapi.c index 0511c7d..d4ee742 100644 --- a/src/engineapi.c +++ b/src/engineapi.c @@ -1,5 +1,6 @@ /* * Copyright © 2022 Michael Smith + * Copyright © 2023 Willian Henrique * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -44,8 +45,6 @@ void *inputsystem, *vgui; DECL_VFUNC_DYN(void *, GetAllServerClasses) -DECL_VFUNC(int, GetEngineBuildNumber_newl4d2, 99) // duping gamedata entry, yuck - #include bool engineapi_init(int pluginver) { @@ -88,16 +87,18 @@ bool engineapi_init(int pluginver) { // detect p1 for the benefit of specific features if (!GAMETYPE_MATCHES(Portal2) && con_findcmd("upgrade_portalgun")) { _gametype_tag |= _gametype_tag_Portal1; + if (!con_findvar("tf_arena_max_streak")) { + _gametype_tag |= _gametype_tag_Portal1_3420; + } } - // 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) && - GetEngineBuildNumber_newl4d2(engclient) >= 2200) { - _gametype_tag |= _gametype_tag_TheLastStand; + if (GAMETYPE_MATCHES(L4D2)) { + if (con_findvar("director_cs_weapon_spawn_chance")) { + _gametype_tag |= _gametype_tag_TheLastStand; + } + else if (con_findvar("sv_zombie_touch_trigger_delay")) { + _gametype_tag |= _gametype_tag_L4D2_2147; + } } // need to do this now; ServerClass network table iteration requires -- cgit v1.2.3