add source-sdk-2013

This commit is contained in:
nillerusr
2022-03-01 23:00:42 +03:00
parent 88b8830e8b
commit edc8d6c584
3288 changed files with 3731 additions and 1062455 deletions
+131 -53
View File
@@ -59,7 +59,7 @@ void DBG_AssertFunction( bool fExpr, const char *szExpr, const char *szFile, int
Q_snprintf(szOut,sizeof(szOut), "ASSERT FAILED:\n %s \n(%s@%d)\n%s", szExpr, szFile, szLine, szMessage);
else
Q_snprintf(szOut,sizeof(szOut), "ASSERT FAILED:\n %s \n(%s@%d)\n", szExpr, szFile, szLine);
Warning( "%s", szOut);
Warning( szOut);
}
#endif // DEBUG
@@ -161,11 +161,6 @@ IServerNetworkable *CEntityFactoryDictionary::Create( const char *pClassName )
IEntityFactory *pFactory = FindFactory( pClassName );
if ( !pFactory )
{
#ifdef STAGING_ONLY
static ConVarRef tf_bot_use_items( "tf_bot_use_items" );
if ( tf_bot_use_items.IsValid() && tf_bot_use_items.GetInt() )
return NULL;
#endif
Warning("Attempted to create unknown entity type %s!\n", pClassName );
return NULL;
}
@@ -205,7 +200,7 @@ void CEntityFactoryDictionary::ReportEntitySizes()
{
for ( int i = m_Factories.First(); i != m_Factories.InvalidIndex(); i = m_Factories.Next( i ) )
{
Msg( " %s: %llu", m_Factories.GetElementName( i ), (uint64)(m_Factories[i]->GetEntitySize()) );
Msg( " %s: %d", m_Factories.GetElementName( i ), m_Factories[i]->GetEntitySize() );
}
}
@@ -284,19 +279,19 @@ float UTIL_GetSimulationInterval()
//-----------------------------------------------------------------------------
int UTIL_EntitiesInBox( const Vector &mins, const Vector &maxs, CFlaggedEntitiesEnum *pEnum )
{
::partition->EnumerateElementsInBox( PARTITION_ENGINE_NON_STATIC_EDICTS, mins, maxs, false, pEnum );
partition->EnumerateElementsInBox( PARTITION_ENGINE_NON_STATIC_EDICTS, mins, maxs, false, pEnum );
return pEnum->GetCount();
}
int UTIL_EntitiesAlongRay( const Ray_t &ray, CFlaggedEntitiesEnum *pEnum )
{
::partition->EnumerateElementsAlongRay( PARTITION_ENGINE_NON_STATIC_EDICTS, ray, false, pEnum );
partition->EnumerateElementsAlongRay( PARTITION_ENGINE_NON_STATIC_EDICTS, ray, false, pEnum );
return pEnum->GetCount();
}
int UTIL_EntitiesInSphere( const Vector &center, float radius, CFlaggedEntitiesEnum *pEnum )
{
::partition->EnumerateElementsInSphere( PARTITION_ENGINE_NON_STATIC_EDICTS, center, radius, false, pEnum );
partition->EnumerateElementsInSphere( PARTITION_ENGINE_NON_STATIC_EDICTS, center, radius, false, pEnum );
return pEnum->GetCount();
}
@@ -573,6 +568,51 @@ CBasePlayer *UTIL_PlayerByIndex( int playerIndex )
return pPlayer;
}
CBasePlayer* UTIL_PlayerByName( const char *name )
{
if ( !name || !name[0] )
return NULL;
for (int i = 1; i<=gpGlobals->maxClients; i++ )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );
if ( !pPlayer )
continue;
if ( !pPlayer->IsConnected() )
continue;
if ( Q_stricmp( pPlayer->GetPlayerName(), name ) == 0 )
{
return pPlayer;
}
}
return NULL;
}
CBasePlayer* UTIL_PlayerByUserId( int userID )
{
for (int i = 1; i<=gpGlobals->maxClients; i++ )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );
if ( !pPlayer )
continue;
if ( !pPlayer->IsConnected() )
continue;
if ( engine->GetPlayerUserId(pPlayer->edict()) == userID )
{
return pPlayer;
}
}
return NULL;
}
//
// Return the local player.
// If this is a multiplayer game, return NULL.
@@ -1308,7 +1348,7 @@ void UTIL_SnapDirectionToAxis( Vector &direction, float epsilon )
}
}
const char *UTIL_VarArgs( const char *format, ... )
char *UTIL_VarArgs( const char *format, ... )
{
va_list argptr;
static char string[1024];
@@ -1779,13 +1819,14 @@ float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vecto
//=========================================================
// UTIL_StripToken - for redundant keynames
//=========================================================
void UTIL_StripToken( const char *pKey, char *pDest, int nDestLength )
void UTIL_StripToken( const char *pKey, char *pDest )
{
int i = 0;
while ( ( i < nDestLength - 1 ) && pKey[i] && pKey[i] != '#' )
while ( pKey[i] && pKey[i] != '#' )
{
pDest[i] = pKey[i];
++ i;
i++;
}
pDest[i] = 0;
}
@@ -1988,6 +2029,49 @@ void UTIL_ValidateSoundName( string_t &name, const char *defaultStr )
}
}
//-----------------------------------------------------------------------------
// Purpose: Slightly modified strtok. Does not modify the input string. Does
// not skip over more than one separator at a time. This allows parsing
// strings where tokens between separators may or may not be present:
//
// Door01,,,0 would be parsed as "Door01" "" "" "0"
// Door01,Open,,0 would be parsed as "Door01" "Open" "" "0"
//
// Input : token - Returns with a token, or zero length if the token was missing.
// str - String to parse.
// sep - Character to use as separator. UNDONE: allow multiple separator chars
// Output : Returns a pointer to the next token to be parsed.
//-----------------------------------------------------------------------------
const char *nexttoken(char *token, const char *str, char sep)
{
if ((str == NULL) || (*str == '\0'))
{
*token = '\0';
return(NULL);
}
//
// Copy everything up to the first separator into the return buffer.
// Do not include separators in the return buffer.
//
while ((*str != sep) && (*str != '\0'))
{
*token++ = *str++;
}
*token = '\0';
//
// Advance the pointer unless we hit the end of the input string.
//
if (*str == '\0')
{
return(str);
}
return(++str);
}
//-----------------------------------------------------------------------------
// Purpose: Helper for UTIL_FindClientInPVS
// Input : check - last checked client
@@ -2982,7 +3066,7 @@ static ConCommand kdtree_test( "kdtree_test", CC_KDTreeTest, "Tests spatial part
void CC_VoxelTreeView( void )
{
Msg( "VoxelTreeView\n" );
::partition->RenderAllObjectsInTree( 10.0f );
partition->RenderAllObjectsInTree( 10.0f );
}
static ConCommand voxeltree_view( "voxeltree_view", CC_VoxelTreeView, "View entities in the voxel-tree.", FCVAR_CHEAT );
@@ -2993,7 +3077,7 @@ void CC_VoxelTreePlayerView( void )
CBasePlayer *pPlayer = static_cast<CBasePlayer*>( UTIL_GetLocalPlayer() );
Vector vecStart = pPlayer->GetAbsOrigin();
::partition->RenderObjectsInPlayerLeafs( vecStart - VEC_HULL_MIN_SCALED( pPlayer ), vecStart + VEC_HULL_MAX_SCALED( pPlayer ), 3.0f );
partition->RenderObjectsInPlayerLeafs( vecStart - VEC_HULL_MIN_SCALED( pPlayer ), vecStart + VEC_HULL_MAX_SCALED( pPlayer ), 3.0f );
}
static ConCommand voxeltree_playerview( "voxeltree_playerview", CC_VoxelTreePlayerView, "View entities in the voxel-tree at the player position.", FCVAR_CHEAT );
@@ -3027,27 +3111,24 @@ void CC_VoxelTreeBox( const CCommand &args )
vecPoints[5].Init( vecMin.x, vecMax.y, vecMax.z );
vecPoints[6].Init( vecMax.x, vecMax.y, vecMax.z );
vecPoints[7].Init( vecMax.x, vecMin.y, vecMax.z );
if ( debugoverlay )
{
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[1], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[2], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[3], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[0], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[4], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[5], vecPoints[6], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[6], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[7], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[1], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[2], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[3], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[0], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[6], 255, 0, 0, true, flTime );
}
debugoverlay->AddLineOverlay( vecPoints[4], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[5], vecPoints[6], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[6], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[7], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[6], 255, 0, 0, true, flTime );
Msg( "VoxelTreeBox - (%f %f %f) to (%f %f %f)\n", vecMin.x, vecMin.y, vecMin.z, vecMax.x, vecMax.y, vecMax.z );
::partition->RenderObjectsInBox( vecMin, vecMax, flTime );
partition->RenderObjectsInBox( vecMin, vecMax, flTime );
}
static ConCommand voxeltree_box( "voxeltree_box", CC_VoxelTreeBox, "View entities in the voxel-tree inside box <Vector(min), Vector(max)>.", FCVAR_CHEAT );
@@ -3085,26 +3166,23 @@ void CC_VoxelTreeSphere( const CCommand &args )
vecPoints[6].Init( vecMax.x, vecMax.y, vecMax.z );
vecPoints[7].Init( vecMax.x, vecMin.y, vecMax.z );
if ( debugoverlay )
{
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[1], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[2], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[3], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[0], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[1], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[2], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[3], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[0], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[4], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[5], vecPoints[6], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[6], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[7], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[4], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[5], vecPoints[6], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[6], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[7], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[6], 255, 0, 0, true, flTime );
}
debugoverlay->AddLineOverlay( vecPoints[0], vecPoints[4], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[3], vecPoints[7], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[1], vecPoints[5], 255, 0, 0, true, flTime );
debugoverlay->AddLineOverlay( vecPoints[2], vecPoints[6], 255, 0, 0, true, flTime );
Msg( "VoxelTreeSphere - (%f %f %f), %f\n", vecCenter.x, vecCenter.y, vecCenter.z, flRadius );
::partition->RenderObjectsInSphere( vecCenter, flRadius, flTime );
partition->RenderObjectsInSphere( vecCenter, flRadius, flTime );
}
static ConCommand voxeltree_sphere( "voxeltree_sphere", CC_VoxelTreeSphere, "View entities in the voxel-tree inside sphere <Vector(center), float(radius)>.", FCVAR_CHEAT );
@@ -3118,7 +3196,7 @@ void CC_CollisionTest( const CCommand &args )
return;
Msg( "Testing collision system\n" );
::partition->ReportStats( "" );
partition->ReportStats( "" );
int i;
CBaseEntity *pSpot = gEntList.FindEntityByClassname( NULL, "info_player_start");
Vector start = pSpot->GetAbsOrigin();
@@ -3189,14 +3267,14 @@ void CC_CollisionTest( const CCommand &args )
{
if ( i == 0 )
{
::partition->RenderLeafsForRayTraceStart( 10.0f );
partition->RenderLeafsForRayTraceStart( 10.0f );
}
UTIL_TraceLine( start, targets[i], nMask, NULL, COLLISION_GROUP_NONE, &tr );
if ( i == 0 )
{
::partition->RenderLeafsForRayTraceEnd( );
partition->RenderLeafsForRayTraceEnd( );
}
}
}
@@ -3205,7 +3283,7 @@ void CC_CollisionTest( const CCommand &args )
}
test[testType] = duration;
Msg("%d collisions in %.2f ms (%u dots)\n", NUM_COLLISION_TESTS, duration*1000, dots );
::partition->ReportStats( "" );
partition->ReportStats( "" );
#if 1
int red = 255, green = 0, blue = 0;
for ( i = 0; i < 1 /*NUM_COLLISION_TESTS*/; i++ )