From 63efbfc1d616e662afc7eab244e7af8324ff968f Mon Sep 17 00:00:00 2001 From: s1lentq Date: Tue, 22 Jun 2021 14:17:31 +0700 Subject: [PATCH] 'game_player_equip' checking buggy maps --- regamedll/dlls/maprules.cpp | 27 +++++++++++++++++++++++++++ regamedll/dlls/maprules.h | 3 ++- regamedll/dlls/player.cpp | 8 +++++++- regamedll/dlls/util.cpp | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/maprules.cpp b/regamedll/dlls/maprules.cpp index 2d73d2b4..20f3c1c7 100644 --- a/regamedll/dlls/maprules.cpp +++ b/regamedll/dlls/maprules.cpp @@ -563,6 +563,33 @@ void CGamePlayerEquip::KeyValue(KeyValueData *pkvd) } } +bool CGamePlayerEquip::HasBuggyMap() const +{ + if (!UseOnly()) + return false; + + CBaseEntity *pEntity = NULL; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "multi_manager"))) + { + if (FNullEnt(pEntity)) + break; + + // Consider case with game_playerspawn only + if (!FStrEq(pEntity->pev->targetname, "game_playerspawn")) + continue; + + // Lookup 'game_player_equip' into multi_manager + if (pEntity->HasTarget(pev->targetname)) + { + ALERT(at_warning, "%s is BUGGY! 'game_player_equip' may be called twice, this has only direct actiavte behavior.\nTriggered by (#%d) %s.\n", + STRING(gpGlobals->mapname), ENTINDEX(pEntity->pev), STRING(pEntity->pev->classname)); + return true; + } + } + + return false; +} + void CGamePlayerEquip::Touch(CBaseEntity *pOther) { if (CanEquipOverTouch(pOther)) diff --git a/regamedll/dlls/maprules.h b/regamedll/dlls/maprules.h index 1690795e..ac4da948 100644 --- a/regamedll/dlls/maprules.h +++ b/regamedll/dlls/maprules.h @@ -258,7 +258,8 @@ public: public: bool UseOnly() const { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) == SF_PLAYEREQUIP_USEONLY; } bool RemoveWeapons() const { return (pev->spawnflags & SF_PLAYEREQUIP_REMOVEWEAPONS) == SF_PLAYEREQUIP_REMOVEWEAPONS; } - + bool HasBuggyMap() const; + bool CanEquipOverTouch(CBaseEntity *pOther) { if (!CanFireForActivator(pOther)) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index b59badc5..f97ffbdd 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -9978,9 +9978,15 @@ void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipG #endif { pWeaponEntity->Touch(this); - addDefault = false; } +#ifdef REGAMEDLL_FIXES + // TODO: Remove me someday! + // Check buggy map and spew message about it! + // 'game_player_equip' may be call twice on player spawn and 'game_playerspawn' event + else if (pWeaponEntity->HasBuggyMap()) + addDefault = false; // Don't give default items now, because we have a deferred equipment +#endif } } diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 8385be35..aea816fc 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -1727,7 +1727,7 @@ bool UTIL_AreHostagesImprov() #ifdef REGAMEDLL_ADD if (g_engfuncs.pfnEngCheckParm == nullptr) return false; - + // someday in CS 1.6 int improv = ENG_CHECK_PARM("-host-improv", nullptr); if (improv)