diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 3278460e..2576dc06 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -129,10 +129,16 @@ int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) } #endif +int UTIL_CoopCheckSpawn( edict_t *pent ); + int DispatchSpawn( edict_t *pent ) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent ); + int ret = UTIL_CoopCheckSpawn( pent ); + if( ret ) + return ret; + if( pEntity ) { // Initialize these or entities who don't link to the world won't have anything in here diff --git a/dlls/coop.cpp b/dlls/coop.cpp index e0680b2e..3df00183 100644 --- a/dlls/coop.cpp +++ b/dlls/coop.cpp @@ -814,3 +814,99 @@ bool UTIL_CoopConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int co } return true; } +#ifdef _WIN32 +// Shitty windows does not even have this!!!!!!! + +#include +/* @NOPEDANTRY: ignore use of reserved identifier */ +char *strrstr(const char *x, const char *y) { +char *prev = NULL; +char *next; +if (*y == '\0') +return strchr(x, '\0'); +while ((next = strstr(x, y)) != NULL) { +prev = next; +x = next + 1; +} +return prev; +} +#endif + +int UTIL_CheckForEntTools( edict_t *pent ) +{ + if( pent->v.targetname ) + { + char *s = (char*)STRING( pent->v.targetname ); + char str[256]; + strcpy( str, s ); + s = strrstr( str, "_e" ); + if( s ) + { + *s = 0; + s = s + 2; + if( atoi(s) == ENTINDEX( pent ) ) + { + s = strrstr( str, "_"); + if( s ) + { + int userid = atoi( s + 1 ); + for( int i = 1; i < gpGlobals->maxClients; i++ ) + if( userid == g_engfuncs.pfnGetPlayerUserId( INDEXENT( i ) ) ) + return i; + } + } + } + } + return 0; +} + +int UTIL_CoopCheckSpawn( edict_t *pent ) +{ + if( mp_checkentities.value ) + { + const char *szClassName = NULL; + + if( !pent->v.classname ) + return 0; + + szClassName = STRING( pent->v.classname ); + + if( !szClassName || !szClassName[0] ) + return 0; + + if( strstr( szClassName, "monster_") ) + { + CBasePlayer *pPlayer = (CBasePlayer*)UTIL_PlayerByIndex( UTIL_CheckForEntTools( pent ) ); + + if( pPlayer ) + { + if( UTIL_CoopIsBadPlayer( pPlayer ) ) + { + pent->v.flags = FL_KILLME; + return -1; + } + + if( gpGlobals->time - pPlayer->m_fEnttoolsMonsterTime < 5 ) + { + UTIL_CoopKickPlayer( pPlayer ); + pent->v.flags = FL_KILLME; + return -1; + } + + if( gpGlobals->time - pPlayer->m_fEnttoolsMonsterTime > 120 ) + pPlayer->m_iEnttoolsMonsters = 0; + + if( pPlayer->m_iEnttoolsMonsters > 5 ) + { + UTIL_CoopKickPlayer( pPlayer ); + pent->v.flags = FL_KILLME; + return -1; + } + pPlayer->m_iEnttoolsMonsters++; + pPlayer->m_fEnttoolsMonsterTime = gpGlobals->time; + } + + } + } + return 0; +} diff --git a/dlls/coop_util.h b/dlls/coop_util.h index df290b29..93277aa7 100644 --- a/dlls/coop_util.h +++ b/dlls/coop_util.h @@ -28,6 +28,8 @@ extern cvar_t mp_coop_reconnect_hack; extern cvar_t mp_coop_noangry; extern cvar_t mp_spectator; extern cvar_t mp_fixhornetbug; +extern cvar_t mp_checkentities; + extern cvar_t sentences_txt; extern cvar_t materials_txt; diff --git a/dlls/game.cpp b/dlls/game.cpp index c948e495..11fe257e 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -64,6 +64,7 @@ cvar_t mp_unduck = { "mp_unduck", "0", FCVAR_SERVER }; cvar_t mp_semclip = { "mp_semclip", "0", FCVAR_SERVER }; cvar_t mp_spectator = { "mp_spectator", "0", FCVAR_SERVER }; cvar_t mp_fixhornetbug = { "mp_fixhornetbug", "0", FCVAR_SERVER }; +cvar_t mp_checkentities = { "mp_checkentities", "0", FCVAR_SERVER }; cvar_t materials_txt = { "materials_txt", "sound/materials.txt", FCVAR_SERVER }; cvar_t sentences_txt = { "sentences_txt", "sound/sentences.txt", FCVAR_SERVER }; @@ -522,6 +523,8 @@ void GameDLLInit( void ) CVAR_REGISTER( &mp_skipdefaults ); CVAR_REGISTER( &mp_coop_strongcheckpoints ); CVAR_REGISTER( &mp_fixhornetbug ); + CVAR_REGISTER( &mp_checkentities ); + CVAR_REGISTER( &sentences_txt ); diff --git a/dlls/player.h b/dlls/player.h index a74757f6..758108d6 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -338,6 +338,8 @@ public: int m_iMenuState; int m_iLocalConfirm; int m_iConfirmKey; + int m_iEnttoolsMonsters; + float m_fEnttoolsMonsterTime; virtual void Touch( CBaseEntity *pOther ); };