mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-02-09 05:24:17 +00:00
Add model validation
This commit is contained in:
parent
6382679d86
commit
4f2d1b76df
@ -453,6 +453,34 @@ void Ent_HelpFire( edict_t *player )
|
||||
Ent_ClientPrintf( player, " clearspawnflag\n" );
|
||||
}
|
||||
|
||||
// xash3d only
|
||||
// maybe incompatible with BSP2 engine
|
||||
#include <com_model.h>
|
||||
#include <physint.h>
|
||||
bool Ent_CheckModel( const char *model )
|
||||
{
|
||||
if( !mp_enttools_checkmodels.value )
|
||||
return true;
|
||||
|
||||
// null model is safe
|
||||
if( !model || !model[0] )
|
||||
return true;
|
||||
|
||||
// check for brush submodel safety
|
||||
if( model[0] == '*' )
|
||||
{
|
||||
if( !model[1] || !Q_isdigit(model + 1) ) // will crash client engine before 0.19.3
|
||||
return false;
|
||||
model_t *world = (model_t*)g_physfuncs.pfnGetModel(1);
|
||||
int submodel = atoi(model + 1);
|
||||
if( submodel < 1 || world && submodel >= world->numsubmodels )
|
||||
return false;
|
||||
} // do not allow to set different model types. bsp models will destroy all submodels on map
|
||||
else if( !strstr( model, ".mdl" ) || !strstr( model, ".spr" ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Ent_Fire_f
|
||||
@ -579,7 +607,13 @@ void Ent_Fire_f( edict_t *player )
|
||||
}
|
||||
if( !stricmp( cmd, "setmodel" ) )
|
||||
{
|
||||
SET_MODEL( ent, CMD_ARGV( 3 ) );
|
||||
const char *model = CMD_ARGV( 3 );
|
||||
if( !Ent_CheckModel( model ) )
|
||||
{
|
||||
Ent_ClientPrintf(player, "Bad model %s\n", model );
|
||||
return;
|
||||
}
|
||||
SET_MODEL( ent, model );
|
||||
}
|
||||
if( !stricmp( cmd, "set" ) )
|
||||
{
|
||||
@ -733,6 +767,7 @@ void Ent_Fire_f( edict_t *player )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Ent_Create_f
|
||||
@ -858,6 +893,14 @@ void Ent_Create_f( edict_t *player )
|
||||
Ent_ClientPrintf( player, "value \"%s\" set to \"%s\"!\n", pkvd.szKeyName, pkvd.szValue );
|
||||
}
|
||||
|
||||
if( ent && ent->v.model && !Ent_CheckModel( STRING( ent->v.model ) ) )
|
||||
{
|
||||
Ent_ClientPrintf( player, "Bad model %s, removing entity\n", STRING( ent->v.model ) );
|
||||
ent->v.effects |= EF_NODRAW;
|
||||
ent->v.flags |= FL_KILLME;
|
||||
return;
|
||||
}
|
||||
|
||||
// onwership
|
||||
CBaseEntity *entity = CBaseEntity::Instance( ent );
|
||||
if( entity )
|
||||
|
@ -32,6 +32,7 @@ cvar_t mp_maxmonsterdist = { "mp_maxmonsterdist", "4096", FCVAR_SERVER};
|
||||
cvar_t mp_servercliptents = { "mp_servercliptents", "0", FCVAR_SERVER};
|
||||
cvar_t mp_maxtentdist = { "mp_maxtentdist", "4096", FCVAR_SERVER};
|
||||
cvar_t mp_maxdecals = { "mp_maxdecals", "-1", FCVAR_SERVER };
|
||||
cvar_t mp_enttools_checkmodels = { "mp_enttools_checkmodels", "0", FCVAR_SERVER };
|
||||
|
||||
void Ent_RunGC_f( void );
|
||||
|
||||
@ -109,6 +110,7 @@ void GGM_RegisterCVars( void )
|
||||
CVAR_REGISTER( &mp_servercliptents );
|
||||
CVAR_REGISTER( &mp_maxtentdist );
|
||||
CVAR_REGISTER( &mp_maxdecals );
|
||||
CVAR_REGISTER( &mp_enttools_checkmodels );
|
||||
|
||||
g_engfuncs.pfnAddServerCommand( "ent_rungc", Ent_RunGC_f );
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ extern cvar_t mp_maxtrashdist;
|
||||
extern cvar_t mp_maxwaterdist;
|
||||
extern cvar_t mp_maxmonsterdist;
|
||||
extern cvar_t mp_maxotherdist;
|
||||
extern cvar_t mp_enttools_checkmodels;
|
||||
|
||||
// tempentity clipping
|
||||
// if enabled, ignores PVS, so use only on open world
|
||||
|
Loading…
x
Reference in New Issue
Block a user