From e8171c4d844c041ac9b8b6cc97c299d63fca97f2 Mon Sep 17 00:00:00 2001 From: mittorn Date: Mon, 8 Oct 2018 16:15:41 +0000 Subject: [PATCH] Use flags for gc, disable emergency clean --- dlls/enttools.cpp | 4 ++-- dlls/gravgunmod.cpp | 25 +++++++++++++++---------- dlls/gravgunmod.h | 4 +++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dlls/enttools.cpp b/dlls/enttools.cpp index d5da41a5..47a3f061 100644 --- a/dlls/enttools.cpp +++ b/dlls/enttools.cpp @@ -116,7 +116,7 @@ bool Ent_CheckCreate( edict_t *player, const char *classname ) { // remove all created entities if( node->clear ) - Ent_RunGC( false, true, GGM_GetPlayerID( player ) ); + Ent_RunGC( GC_ENTTOOLS, GGM_GetPlayerID( player ) ); if( node->behaviour == 2 ) { @@ -757,7 +757,7 @@ void Ent_Fire_f( edict_t *player ) Ent_ClientPrintf( player, "entity %i\n", i ); if( single && count > 0 ) - break; + break; count++; diff --git a/dlls/gravgunmod.cpp b/dlls/gravgunmod.cpp index b80d2a99..253d5dca 100644 --- a/dlls/gravgunmod.cpp +++ b/dlls/gravgunmod.cpp @@ -144,7 +144,7 @@ void GGM_RegisterCVars( void ) g_engfuncs.pfnAddServerCommand( "mp_lightstyle", GGM_LightStyle_f ); } -void Ent_RunGC( bool common, bool enttools, const char *userid, const char *pattern ) +void Ent_RunGC( int flags, const char *userid, const char *pattern ) { int i, count = 0, removed = 0; edict_t *ent = g_engfuncs.pfnPEntityOfEntIndex( gpGlobals->maxClients + 5 ); @@ -166,7 +166,7 @@ void Ent_RunGC( bool common, bool enttools, const char *userid, const char *patt if( ent->v.flags & FL_KILLME ) continue; - if( common ) + if( flags & GC_COMMON ) { if( !strcmp( classname, "gib" ) || !strcmp( classname, "gateofbabylon_bolt" ) ) { @@ -182,7 +182,7 @@ void Ent_RunGC( bool common, bool enttools, const char *userid, const char *patt continue; } } - if( !enttools && !pattern ) + if( !(flags & GC_ENTTOOLS) && !pattern ) { if( strncmp( classname, "monster_", 8 ) || strncmp( classname, "weapon_", 7 ) || strncmp( classname, "ammo_", 5 ) || strncmp( classname, "item_", 5 ) ) continue; @@ -204,7 +204,7 @@ void Ent_RunGC( bool common, bool enttools, const char *userid, const char *patt continue; } - if( enttools && entity->enttools_data.enttools ) + if( (flags & GC_ENTTOOLS) && entity->enttools_data.enttools ) { if( !userid || !strcmp( userid, entity->enttools_data.ownerid ) ) { @@ -214,7 +214,7 @@ void Ent_RunGC( bool common, bool enttools, const char *userid, const char *patt } } - if( common && !entity->IsInWorld() ) + if( (flags & GC_COMMON) && !entity->IsInWorld() ) { ent->v.flags |= FL_KILLME; removed++; @@ -246,7 +246,12 @@ void Ent_RunGC_f() const char *pattern = CMD_ARGV( 2 ); if( enttools != 2 || !pattern[0] ) pattern = NULL; - Ent_RunGC( enttools == 0, enttools == 1, NULL, pattern ); + int flags = 0; + if( !enttools ) + flags |= GC_COMMON; + if( enttools == 1 ) + flags |= GC_ENTTOOLS; + Ent_RunGC( flags, NULL, pattern ); } int Ent_CheckEntitySpawn( edict_t *pent ) @@ -262,7 +267,7 @@ int Ent_CheckEntitySpawn( edict_t *pent ) if( gpGlobals->maxEntities - index < 10 ) { ALERT( at_error, "REFUSING CREATING ENTITY %s\n", STRING( pent->v.classname ) ); - Ent_RunGC( true, true, NULL ); + //Ent_RunGC( 0, NULL ); return 1; } @@ -275,7 +280,7 @@ int Ent_CheckEntitySpawn( edict_t *pent ) return 1; - Ent_RunGC( true, false, NULL ); + Ent_RunGC( GC_COMMON, NULL ); return 0; } @@ -283,13 +288,13 @@ int Ent_CheckEntitySpawn( edict_t *pent ) if( index > gpGlobals->maxEntities / 2 && counter - lastgc > 256 ) { lastgc = counter; - Ent_RunGC( true, false, NULL ); + Ent_RunGC( GC_COMMON, NULL ); return 0; } else if( counter - lastgc > gpGlobals->maxEntities ) { lastgc = counter; - Ent_RunGC( true, false, NULL ); + Ent_RunGC( GC_COMMON, NULL ); return 0; } } diff --git a/dlls/gravgunmod.h b/dlls/gravgunmod.h index e6881e23..843dc41b 100644 --- a/dlls/gravgunmod.h +++ b/dlls/gravgunmod.h @@ -47,7 +47,9 @@ extern cvar_t mp_maxtentdist; extern cvar_t mp_maxdecals; void GGM_RegisterCVars( void ); -void Ent_RunGC( bool common, bool enttools, const char *userid, const char *pattern = NULL ); +#define GC_COMMON (1<<0) +#define GC_ENTTOOLS (1<<1) +void Ent_RunGC( int flags, const char *userid, const char *pattern = NULL ); bool Q_stricmpext( const char *pattern, const char *text ); class CBasePlayer; void GGM_ClientPutinServer(edict_t *pEntity , CBasePlayer *pPlayer);