Use flags for gc, disable emergency clean

This commit is contained in:
mittorn 2018-10-08 16:15:41 +00:00
parent cb47acfe45
commit e8171c4d84
3 changed files with 20 additions and 13 deletions

View File

@ -116,7 +116,7 @@ bool Ent_CheckCreate( edict_t *player, const char *classname )
{ {
// remove all created entities // remove all created entities
if( node->clear ) if( node->clear )
Ent_RunGC( false, true, GGM_GetPlayerID( player ) ); Ent_RunGC( GC_ENTTOOLS, GGM_GetPlayerID( player ) );
if( node->behaviour == 2 ) if( node->behaviour == 2 )
{ {
@ -757,7 +757,7 @@ void Ent_Fire_f( edict_t *player )
Ent_ClientPrintf( player, "entity %i\n", i ); Ent_ClientPrintf( player, "entity %i\n", i );
if( single && count > 0 ) if( single && count > 0 )
break; break;
count++; count++;

View File

@ -144,7 +144,7 @@ void GGM_RegisterCVars( void )
g_engfuncs.pfnAddServerCommand( "mp_lightstyle", GGM_LightStyle_f ); 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; int i, count = 0, removed = 0;
edict_t *ent = g_engfuncs.pfnPEntityOfEntIndex( gpGlobals->maxClients + 5 ); 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 ) if( ent->v.flags & FL_KILLME )
continue; continue;
if( common ) if( flags & GC_COMMON )
{ {
if( !strcmp( classname, "gib" ) || !strcmp( classname, "gateofbabylon_bolt" ) ) 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; 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 ) ) if( strncmp( classname, "monster_", 8 ) || strncmp( classname, "weapon_", 7 ) || strncmp( classname, "ammo_", 5 ) || strncmp( classname, "item_", 5 ) )
continue; continue;
@ -204,7 +204,7 @@ void Ent_RunGC( bool common, bool enttools, const char *userid, const char *patt
continue; continue;
} }
if( enttools && entity->enttools_data.enttools ) if( (flags & GC_ENTTOOLS) && entity->enttools_data.enttools )
{ {
if( !userid || !strcmp( userid, entity->enttools_data.ownerid ) ) 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; ent->v.flags |= FL_KILLME;
removed++; removed++;
@ -246,7 +246,12 @@ void Ent_RunGC_f()
const char *pattern = CMD_ARGV( 2 ); const char *pattern = CMD_ARGV( 2 );
if( enttools != 2 || !pattern[0] ) if( enttools != 2 || !pattern[0] )
pattern = NULL; 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 ) int Ent_CheckEntitySpawn( edict_t *pent )
@ -262,7 +267,7 @@ int Ent_CheckEntitySpawn( edict_t *pent )
if( gpGlobals->maxEntities - index < 10 ) if( gpGlobals->maxEntities - index < 10 )
{ {
ALERT( at_error, "REFUSING CREATING ENTITY %s\n", STRING( pent->v.classname ) ); ALERT( at_error, "REFUSING CREATING ENTITY %s\n", STRING( pent->v.classname ) );
Ent_RunGC( true, true, NULL ); //Ent_RunGC( 0, NULL );
return 1; return 1;
} }
@ -275,7 +280,7 @@ int Ent_CheckEntitySpawn( edict_t *pent )
return 1; return 1;
Ent_RunGC( true, false, NULL ); Ent_RunGC( GC_COMMON, NULL );
return 0; return 0;
} }
@ -283,13 +288,13 @@ int Ent_CheckEntitySpawn( edict_t *pent )
if( index > gpGlobals->maxEntities / 2 && counter - lastgc > 256 ) if( index > gpGlobals->maxEntities / 2 && counter - lastgc > 256 )
{ {
lastgc = counter; lastgc = counter;
Ent_RunGC( true, false, NULL ); Ent_RunGC( GC_COMMON, NULL );
return 0; return 0;
} }
else if( counter - lastgc > gpGlobals->maxEntities ) else if( counter - lastgc > gpGlobals->maxEntities )
{ {
lastgc = counter; lastgc = counter;
Ent_RunGC( true, false, NULL ); Ent_RunGC( GC_COMMON, NULL );
return 0; return 0;
} }
} }

View File

@ -47,7 +47,9 @@ extern cvar_t mp_maxtentdist;
extern cvar_t mp_maxdecals; extern cvar_t mp_maxdecals;
void GGM_RegisterCVars( void ); 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 ); bool Q_stricmpext( const char *pattern, const char *text );
class CBasePlayer; class CBasePlayer;
void GGM_ClientPutinServer(edict_t *pEntity , CBasePlayer *pPlayer); void GGM_ClientPutinServer(edict_t *pEntity , CBasePlayer *pPlayer);