Browse Source

Tempents distance clipping (experimental)

gravgun
mittorn 6 years ago
parent
commit
4f2f316879
  1. 4
      dlls/gravgunmod.cpp
  2. 2
      dlls/gravgunmod.h
  3. 364
      dlls/util.cpp

4
dlls/gravgunmod.cpp

@ -28,6 +28,8 @@ cvar_t mp_maxbmodeldist = { "mp_maxbmodeldist", "4096", FCVAR_SERVER};
cvar_t mp_maxtrashdist = { "mp_maxtrashdist", "4096", FCVAR_SERVER}; cvar_t mp_maxtrashdist = { "mp_maxtrashdist", "4096", FCVAR_SERVER};
cvar_t mp_maxwaterdist = { "mp_maxwaterdist", "4096", FCVAR_SERVER}; cvar_t mp_maxwaterdist = { "mp_maxwaterdist", "4096", FCVAR_SERVER};
cvar_t mp_maxotherdist = { "mp_maxotherdist", "4096", FCVAR_SERVER}; cvar_t mp_maxotherdist = { "mp_maxotherdist", "4096", FCVAR_SERVER};
cvar_t mp_servercliptents = { "mp_servercliptents", "0", FCVAR_SERVER};
cvar_t mp_maxtentdist = { "mp_maxtentdist", "4096", FCVAR_SERVER};
void Ent_RunGC_f( void ); void Ent_RunGC_f( void );
@ -101,6 +103,8 @@ void GGM_RegisterCVars( void )
CVAR_REGISTER( &mp_maxtrashdist ); CVAR_REGISTER( &mp_maxtrashdist );
CVAR_REGISTER( &mp_maxwaterdist ); CVAR_REGISTER( &mp_maxwaterdist );
CVAR_REGISTER( &mp_maxotherdist ); CVAR_REGISTER( &mp_maxotherdist );
CVAR_REGISTER( &mp_servercliptents );
CVAR_REGISTER( &mp_maxtentdist );
g_engfuncs.pfnAddServerCommand( "ent_rungc", Ent_RunGC_f ); g_engfuncs.pfnAddServerCommand( "ent_rungc", Ent_RunGC_f );
} }

2
dlls/gravgunmod.h

@ -25,6 +25,8 @@ extern cvar_t mp_maxbmodeldist;
extern cvar_t mp_maxtrashdist; extern cvar_t mp_maxtrashdist;
extern cvar_t mp_maxwaterdist; extern cvar_t mp_maxwaterdist;
extern cvar_t mp_maxotherdist; extern cvar_t mp_maxotherdist;
extern cvar_t mp_servercliptents;
extern cvar_t mp_maxtentdist;
void GGM_RegisterCVars( void ); void GGM_RegisterCVars( void );
void Ent_RunGC( bool common, bool enttools, const char *userid, const char *pattern = NULL ); void Ent_RunGC( bool common, bool enttools, const char *userid, const char *pattern = NULL );

364
dlls/util.cpp

@ -1102,18 +1102,54 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color,
if( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED ) if( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED )
color = 0; color = 0;
if( mp_serverdistclip.value && mp_servercliptents.value )
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); {
WRITE_BYTE( TE_BLOODSTREAM ); // loop through all players
WRITE_COORD( origin.x ); for( int i = 1; i <= gpGlobals->maxClients; i++ )
WRITE_COORD( origin.y ); {
WRITE_COORD( origin.z ); CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
WRITE_COORD( direction.x ); if( pPlayer )
WRITE_COORD( direction.y ); {
WRITE_COORD( direction.z ); Vector delta = origin - pPlayer->edict()->v.origin;
WRITE_BYTE( color ); float dist = 0;
WRITE_BYTE( Q_min( amount, 255 ) );
MESSAGE_END(); if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict() );
WRITE_BYTE( TE_BLOODSTREAM );
WRITE_COORD( origin.x );
WRITE_COORD( origin.y );
WRITE_COORD( origin.z );
WRITE_COORD( direction.x );
WRITE_COORD( direction.y );
WRITE_COORD( direction.z );
WRITE_BYTE( color );
WRITE_BYTE( Q_min( amount, 255 ) );
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin );
WRITE_BYTE( TE_BLOODSTREAM );
WRITE_COORD( origin.x );
WRITE_COORD( origin.y );
WRITE_COORD( origin.z );
WRITE_COORD( direction.x );
WRITE_COORD( direction.y );
WRITE_COORD( direction.z );
WRITE_BYTE( color );
WRITE_BYTE( Q_min( amount, 255 ) );
MESSAGE_END();
}
} }
void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount )
@ -1136,16 +1172,52 @@ void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color,
if( amount > 255 ) if( amount > 255 )
amount = 255; amount = 255;
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); if( mp_serverdistclip.value && mp_servercliptents.value )
WRITE_BYTE( TE_BLOODSPRITE ); {
WRITE_COORD( origin.x); // pos // loop through all players
WRITE_COORD( origin.y); for( int i = 1; i <= gpGlobals->maxClients; i++ )
WRITE_COORD( origin.z); {
WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models if( pPlayer )
WRITE_BYTE( color ); // color index into host_basepal {
WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size Vector delta = origin - pPlayer->edict()->v.origin;
MESSAGE_END(); float dist = 0;
if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict() );
WRITE_BYTE( TE_BLOODSPRITE );
WRITE_COORD( origin.x); // pos
WRITE_COORD( origin.y);
WRITE_COORD( origin.z);
WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model
WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models
WRITE_BYTE( color ); // color index into host_basepal
WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin );
WRITE_BYTE( TE_BLOODSPRITE );
WRITE_COORD( origin.x); // pos
WRITE_COORD( origin.y);
WRITE_COORD( origin.z);
WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model
WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models
WRITE_BYTE( color ); // color index into host_basepal
WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size
MESSAGE_END();
}
} }
Vector UTIL_RandomBloodVector( void ) Vector UTIL_RandomBloodVector( void )
@ -1217,15 +1289,50 @@ void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber )
} }
} }
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); if( mp_serverdistclip.value && mp_servercliptents.value )
WRITE_BYTE( message ); {
WRITE_COORD( pTrace->vecEndPos.x ); // loop through all players
WRITE_COORD( pTrace->vecEndPos.y ); for( int i = 1; i <= gpGlobals->maxClients; i++ )
WRITE_COORD( pTrace->vecEndPos.z ); {
WRITE_BYTE( index ); CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
if( entityIndex ) if( pPlayer )
WRITE_SHORT( entityIndex ); {
MESSAGE_END(); Vector delta = pTrace->vecEndPos - pPlayer->edict()->v.origin;
float dist = 0;
if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict() );
WRITE_BYTE( message );
WRITE_COORD( pTrace->vecEndPos.x );
WRITE_COORD( pTrace->vecEndPos.y );
WRITE_COORD( pTrace->vecEndPos.z );
WRITE_BYTE( index );
if( entityIndex )
WRITE_SHORT( entityIndex );
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( message );
WRITE_COORD( pTrace->vecEndPos.x );
WRITE_COORD( pTrace->vecEndPos.y );
WRITE_COORD( pTrace->vecEndPos.z );
WRITE_BYTE( index );
if( entityIndex )
WRITE_SHORT( entityIndex );
MESSAGE_END();
}
} }
/* /*
@ -1256,15 +1363,50 @@ void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber,
if( pTrace->flFraction == 1.0 ) if( pTrace->flFraction == 1.0 )
return; return;
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); if( mp_serverdistclip.value && mp_servercliptents.value )
WRITE_BYTE( TE_PLAYERDECAL ); {
WRITE_BYTE( playernum ); // loop through all players
WRITE_COORD( pTrace->vecEndPos.x ); for( int i = 1; i <= gpGlobals->maxClients; i++ )
WRITE_COORD( pTrace->vecEndPos.y ); {
WRITE_COORD( pTrace->vecEndPos.z ); CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) ); if( pPlayer )
WRITE_BYTE( index ); {
MESSAGE_END(); Vector delta = pTrace->vecEndPos - pPlayer->edict()->v.origin;
float dist = 0;
if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict() );
WRITE_BYTE( TE_PLAYERDECAL );
WRITE_BYTE( playernum );
WRITE_COORD( pTrace->vecEndPos.x );
WRITE_COORD( pTrace->vecEndPos.y );
WRITE_COORD( pTrace->vecEndPos.z );
WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) );
WRITE_BYTE( index );
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_PLAYERDECAL );
WRITE_BYTE( playernum );
WRITE_COORD( pTrace->vecEndPos.x );
WRITE_COORD( pTrace->vecEndPos.y );
WRITE_COORD( pTrace->vecEndPos.z );
WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) );
WRITE_BYTE( index );
MESSAGE_END();
}
} }
void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber )
@ -1279,35 +1421,135 @@ void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber )
if( pTrace->flFraction == 1.0 ) if( pTrace->flFraction == 1.0 )
return; return;
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pTrace->vecEndPos ); if( mp_serverdistclip.value && mp_servercliptents.value )
WRITE_BYTE( TE_GUNSHOTDECAL ); {
WRITE_COORD( pTrace->vecEndPos.x ); // loop through all players
WRITE_COORD( pTrace->vecEndPos.y ); for( int i = 1; i <= gpGlobals->maxClients; i++ )
WRITE_COORD( pTrace->vecEndPos.z ); {
WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) ); CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
WRITE_BYTE( index ); if( pPlayer )
MESSAGE_END(); {
Vector delta = pTrace->vecEndPos - pPlayer->edict()->v.origin;
float dist = 0;
if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict());
WRITE_BYTE( TE_GUNSHOTDECAL );
WRITE_COORD( pTrace->vecEndPos.x );
WRITE_COORD( pTrace->vecEndPos.y );
WRITE_COORD( pTrace->vecEndPos.z );
WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) );
WRITE_BYTE( index );
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pTrace->vecEndPos );
WRITE_BYTE( TE_GUNSHOTDECAL );
WRITE_COORD( pTrace->vecEndPos.x );
WRITE_COORD( pTrace->vecEndPos.y );
WRITE_COORD( pTrace->vecEndPos.z );
WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) );
WRITE_BYTE( index );
MESSAGE_END();
}
} }
void UTIL_Sparks( const Vector &position ) void UTIL_Sparks( const Vector &position )
{ {
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position );
WRITE_BYTE( TE_SPARKS ); if( mp_serverdistclip.value && mp_servercliptents.value )
WRITE_COORD( position.x ); {
WRITE_COORD( position.y ); // loop through all players
WRITE_COORD( position.z ); for( int i = 1; i <= gpGlobals->maxClients; i++ )
MESSAGE_END(); {
CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
if( pPlayer )
{
Vector delta = position - pPlayer->edict()->v.origin;
float dist = 0;
if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict() );
WRITE_BYTE( TE_SPARKS );
WRITE_COORD( position.x );
WRITE_COORD( position.y );
WRITE_COORD( position.z );
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position );
WRITE_BYTE( TE_SPARKS );
WRITE_COORD( position.x );
WRITE_COORD( position.y );
WRITE_COORD( position.z );
MESSAGE_END();
}
} }
void UTIL_Ricochet( const Vector &position, float scale ) void UTIL_Ricochet( const Vector &position, float scale )
{ {
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position ); if( mp_serverdistclip.value && mp_servercliptents.value )
WRITE_BYTE( TE_ARMOR_RICOCHET ); {
WRITE_COORD( position.x ); // loop through all players
WRITE_COORD( position.y ); for( int i = 1; i <= gpGlobals->maxClients; i++ )
WRITE_COORD( position.z ); {
WRITE_BYTE( (int)( scale * 10 ) ); CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );
MESSAGE_END(); if( pPlayer )
{
Vector delta = position - pPlayer->edict()->v.origin;
float dist = 0;
if( abs(delta.x) > dist )
dist = abs(delta.x);
if( abs(delta.y) > dist )
dist = abs(delta.y);
if( abs(delta.z) > dist )
dist = abs(delta.z);
if( dist > mp_maxtentdist.value)
continue;
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pPlayer->edict() );
WRITE_BYTE( TE_ARMOR_RICOCHET );
WRITE_COORD( position.x );
WRITE_COORD( position.y );
WRITE_COORD( position.z );
WRITE_BYTE( (int)( scale * 10 ) );
MESSAGE_END();
}
}
}
else
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position );
WRITE_BYTE( TE_ARMOR_RICOCHET );
WRITE_COORD( position.x );
WRITE_COORD( position.y );
WRITE_COORD( position.z );
WRITE_BYTE( (int)( scale * 10 ) );
MESSAGE_END();
}
} }
BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ) BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 )

Loading…
Cancel
Save