Skip to content

Commit

Permalink
pending: assorted experimented changes yet to be added to patch set
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Mar 12, 2023
1 parent 068db7f commit c7cb0c2
Show file tree
Hide file tree
Showing 36 changed files with 921 additions and 152 deletions.
8 changes: 1 addition & 7 deletions src/datacache/mdlcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ namespace {
#define MdlCacheMsg if ( !LogMdlCache() ) ; else Msg
#define MdlCacheWarning if ( !LogMdlCache() ) ; else Warning

#if defined( _X360 )
#define AsyncMdlCache() 0 // Explicitly OFF for 360 (incompatible)
#else
#define AsyncMdlCache() 0
#endif

#define ERROR_MODEL "models/error.mdl"
#define IDSTUDIOHEADER (('T'<<24)+('S'<<16)+('D'<<8)+'I')

Expand Down Expand Up @@ -184,7 +178,7 @@ class CTempAllocHelper
// ConVars
//-----------------------------------------------------------------------------
static ConVar r_rootlod( "r_rootlod", "0", FCVAR_ARCHIVE );
static ConVar mod_forcedata( "mod_forcedata", ( AsyncMdlCache() ) ? "0" : "1", 0, "Forces all model file data into cache on model load." );
static ConVar mod_forcedata( "mod_forcedata", "1", 0, "Forces all model file data into cache on model load." );
static ConVar mod_test_not_available( "mod_test_not_available", "0", FCVAR_CHEAT );
static ConVar mod_test_mesh_not_available( "mod_test_mesh_not_available", "0", FCVAR_CHEAT );
static ConVar mod_test_verts_not_available( "mod_test_verts_not_available", "0", FCVAR_CHEAT );
Expand Down
4 changes: 2 additions & 2 deletions src/engine/audio/private/snd_dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extern IVideoServices *g_pVideo;
#define DIST_MULT_TO_SNDLVL( dist_mult ) (soundlevel_t)(int)( dist_mult ? ( 20 * log10( pow( 10.0f, snd_refdb.GetFloat() / 20 ) / (dist_mult * snd_refdist.GetFloat()) ) ) : 0 )

#if !defined( _X360 )
#define THREADED_MIX_TIME 0.015
#define THREADED_MIX_TIME 0.005
#else
#define THREADED_MIX_TIME XMA_POLL_RATE * 0.001
#endif
Expand Down Expand Up @@ -470,7 +470,7 @@ static ConVar volume( "volume", "1.0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "Soun
// user configurable music volume
ConVar snd_musicvolume( "snd_musicvolume", "1.0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "Music volume", true, 0.0f, true, 1.0f );

ConVar snd_mixahead( "snd_mixahead", "0.1", FCVAR_DEVELOPMENTONLY ); //
ConVar snd_mixahead( "snd_threaded_mixahead", "0.1", 0 );
#ifdef THREADED_SOUND_UPDATE
ConVar snd_mix_async( "snd_mix_async", "1" );
#else
Expand Down
2 changes: 1 addition & 1 deletion src/engine/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ void Cmd_Exec_f( const CCommand &args )
}
}
// force any queued convar changes to flush before reading/writing them
UpdateMaterialSystemConfig();
//UpdateMaterialSystemConfig();
}


Expand Down
37 changes: 16 additions & 21 deletions src/engine/dt_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,52 +222,47 @@ void DecodeInfo::CopyVars( const DecodeInfo *pOther )

void Int_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
int nValue = pVar->m_Int;

if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
pOut->WriteVarInt32( nValue );
pOut->WriteVarInt32( pVar->m_Int );
}
else
{
pOut->WriteSignedVarInt32( nValue );
pOut->WriteSignedVarInt32( pVar->m_Int );
}
}
else
{
// If signed, preserve lower bits and then re-extend sign if nValue < 0;
// if unsigned, preserve all 32 bits no matter what. Bonus: branchless.
int nPreserveBits = ( 0x7FFFFFFF >> ( 32 - pProp->m_nBits ) );
nPreserveBits |= ( pProp->GetFlags() & SPROP_UNSIGNED ) ? 0xFFFFFFFF : 0;
int nSignExtension = ( nValue >> 31 ) & ~nPreserveBits;

nValue &= nPreserveBits;
nValue |= nSignExtension;

#ifdef DBGFLAG_ASSERT
// Assert that either the property is unsigned and in valid range,
// or signed with a consistent sign extension in the high bits
if ( pProp->m_nBits < 32 )
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
AssertMsg3( nValue == pVar->m_Int, "Unsigned prop %s needs more bits? Expected %i == %i", pProp->GetName(), nValue, pVar->m_Int );
int32 nMaskedValue = pVar->m_Int;
nMaskedValue &= (1u << pProp->m_nBits) - 1;
Assert(nMaskedValue == pVar->m_Int);
}
else
{
AssertMsg3( nValue == pVar->m_Int, "Signed prop %s needs more bits? Expected %i == %i", pProp->GetName(), nValue, pVar->m_Int );
int32 nSignExtendedValue = pVar->m_Int;
nSignExtendedValue <<= 32 - pProp->m_nBits;
nSignExtendedValue >>= 32 - pProp->m_nBits;
Assert(nSignExtendedValue == pVar->m_Int);
}
}
#endif
if (pProp->IsSigned())
{
pOut->WriteSBitLong(pVar->m_Int, pProp->m_nBits);
}
else
{
// This should never trigger, but I'm leaving it in for old-time's sake.
Assert( nValue == pVar->m_Int );
pOut->WriteUBitLong((unsigned int)pVar->m_Int, pProp->m_nBits);
}
#endif

pOut->WriteUBitLong( nValue, pProp->m_nBits, false );
}
}

Expand Down Expand Up @@ -322,7 +317,7 @@ int Int_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
return p1->ReadSignedVarInt32() != p2->ReadSignedVarInt32();
}

return p1->CompareBits(p2, pProp->m_nBits);
return p1->ReadUBitLong(pProp->m_nBits) != p2->ReadUBitLong(pProp->m_nBits);
}

const char* Int_GetTypeNameString()
Expand Down
7 changes: 5 additions & 2 deletions src/engine/l_studio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3179,15 +3179,18 @@ int CModelRender::DrawStaticPropArrayFast( StaticPropRenderInfo_t *pProps, int c
#endif // SWDS
}

#ifndef SWDS
static ConVar r_shadowlod("r_shadowlod", "-1");
static ConVar r_shadowlodbias("r_shadowlodbias", "2");
#endif

//-----------------------------------------------------------------------------
// Shadow rendering
//-----------------------------------------------------------------------------
matrix3x4_t* CModelRender::DrawModelShadowSetup( IClientRenderable *pRenderable, int body, int skin, DrawModelInfo_t *pInfo, matrix3x4_t *pCustomBoneToWorld )
{
#ifndef SWDS
DrawModelInfo_t &info = *pInfo;
static ConVar r_shadowlod("r_shadowlod", "-1");
static ConVar r_shadowlodbias("r_shadowlodbias", "2");

model_t const* pModel = pRenderable->GetModel();
if ( !pModel )
Expand Down
2 changes: 1 addition & 1 deletion src/engine/modelloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5022,7 +5022,7 @@ void CModelLoader::Studio_LoadModel( model_t *pModel, bool bTouchAllData )
if ( bLoadPhysics && !bPreLoaded )
{
// load the collision data now
bool bSynchronous = bTouchAllData;
bool bSynchronous = bTouchAllData && !AsyncMdlCache();
double t1 = Plat_FloatTime();
g_pMDLCache->GetVCollideEx( pModel->studio, bSynchronous );

Expand Down
2 changes: 1 addition & 1 deletion src/engine/sv_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern CNetworkStringTableContainer *networkStringTableContainerServer;

static ConVar sv_timeout( "sv_timeout", "65", 0, "After this many seconds without a message from a client, the client is dropped" );
static ConVar sv_maxrate( "sv_maxrate", "0", FCVAR_REPLICATED, "Max bandwidth rate allowed on server, 0 == unlimited" );
static ConVar sv_minrate( "sv_minrate", "3500", FCVAR_REPLICATED, "Min bandwidth rate allowed on server, 0 == unlimited" );
static ConVar sv_minrate( "sv_minrate", V_STRINGIFY( DEFAULT_RATE ), FCVAR_REPLICATED, "Min bandwidth rate allowed on server, 0 == unlimited" );

ConVar sv_maxupdaterate( "sv_maxupdaterate", "66", FCVAR_REPLICATED, "Maximum updates per second that the server will allow" );
ConVar sv_minupdaterate( "sv_minupdaterate", "10", FCVAR_REPLICATED, "Minimum updates per second that the server will allow" );
Expand Down
12 changes: 3 additions & 9 deletions src/engine/sys_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
#include "vgui_baseui_interface.h"
#endif
#include "tier0/etwprof.h"
#ifdef IS_WINDOWS_PC
#include <windows.h>
#endif

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
Expand Down Expand Up @@ -367,12 +364,9 @@ void CEngine::Frame( void )
while ( Plat_FloatTime() < fWaitEnd )
{
ThreadPause();
// Yield the CPU to other threads.
#ifdef IS_WINDOWS_PC
SwitchToThread();
#elif defined( POSIX )
sched_yield();
#endif
// Yield the CPU to other threads so we don't spin too tightly
// ThreadSleep(0) is not tight enough.
ThreadYield();
}

// Go back to the top of the loop and see if it is time yet.
Expand Down
2 changes: 1 addition & 1 deletion src/filesystem/basefilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CBaseFileSystem *BaseFileSystem()
return g_pBaseFileSystem;
}

ConVar filesystem_buffer_size( "filesystem_buffer_size", "0", 0, "Size of per file buffers. 0 for none" );
ConVar filesystem_buffer_size( "filesystem_buffer_size", "32768", 0, "Size of per file buffers. 0 for none" );

#if defined( TRACK_BLOCKING_IO )

Expand Down
5 changes: 3 additions & 2 deletions src/filesystem/filesystem_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class CFileAsyncReadJob : public CFileAsyncJob,
else
{
int iPrevPriority = ThreadGetPriority();
ThreadSetPriority( 2 );
ThreadSetPriority( TP_PRIORITY_HIGHEST );
retval = BaseFileSystem()->SyncRead( *this );
ThreadSetPriority( iPrevPriority );
}
Expand Down Expand Up @@ -666,7 +666,7 @@ void CBaseFileSystem::InitAsync()
m_pThreadPool = CreateThreadPool();

ThreadPoolStartParams_t params;
params.iThreadPriority = 0;
params.iThreadPriority = TP_PRIORITY_LOW;
params.bIOThreads = true;
params.nThreadsMax = 4; // Limit count of IO threads to a maximum of 4.
if ( IsX360() )
Expand All @@ -682,6 +682,7 @@ void CBaseFileSystem::InitAsync()
{
// override defaults
// maximum # of async I/O thread on PC is 2
params.nStackSize = 256 * 1024;
params.nThreads = 1;
}

Expand Down
16 changes: 13 additions & 3 deletions src/game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "datacache/imdlcache.h"
#include "kbutton.h"
#include "tier0/icommandline.h"
#include "vstdlib/jobthread.h"
#include "gamerules_register.h"
#include "vgui_controls/AnimationController.h"
#include "bitmap/tgawriter.h"
Expand Down Expand Up @@ -838,6 +839,14 @@ bool IsEngineThreaded()
return false;
}

bool InitParticleManager()
{
if (!ParticleMgr()->Init(MAX_TOTAL_PARTICLES, materials))
return false;

return true;
}

//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -991,9 +1000,8 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
if (!Initializer::InitializeAllObjects())
return false;

if (!ParticleMgr()->Init(MAX_TOTAL_PARTICLES, materials))
return false;

CFunctorJob *pGameJob = new CFunctorJob( CreateFunctor( InitParticleManager ) );
g_pThreadPool->AddJob( pGameJob );

if (!VGui_Startup( appSystemFactory ))
return false;
Expand Down Expand Up @@ -1035,6 +1043,8 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi

modemanager->Init( );

pGameJob->WaitForFinishAndRelease();

g_pClientMode->InitViewport();

gHUD.Init();
Expand Down
1 change: 1 addition & 0 deletions src/game/client/tf/vgui/tf_playermodelpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@ CEconItemView *CTFPlayerModelPanel::GetLoadoutItemFromMDLHandle( loadout_positio
if ( ( IsMiscSlot( iLoadoutSlot ) && IsMiscSlot( iPosition ) ) ||
( IsValidPickupWeaponSlot( iLoadoutSlot ) && iLoadoutSlot == iPosition ) )
{
// TODO: GetPlayerDisplayModel is INCREDIBLY expensive, lots of Steam API calls,
const char * pDisplayModel = pItem->GetPlayerDisplayModel( m_iCurrentClassIndex, m_iTeam );
if ( pDisplayModel )
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/viewpostprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ static ConVar r_queued_post_processing( "r_queued_post_processing", "0" );

// How much to dice up the screen during post-processing on 360
// This has really marginal effects, but 4x1 does seem vaguely better for post-processing
static ConVar mat_postprocess_x( "mat_postprocess_x", "4" );
static ConVar mat_postprocess_x( "mat_postprocess_x", "1" );
static ConVar mat_postprocess_y( "mat_postprocess_y", "1" );

void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, bool bPostVGui )
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/econ/econ_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ bool CEconItem::BAddDestroyToMessage( std::string *pBuffer ) const
bool CEconItem::BIsKeyLess( const CSharedObject & soRHS ) const
{
Assert( GetTypeID() == soRHS.GetTypeID() );
const CEconItem & soSchemaRHS = (const CEconItem &)soRHS;
const CEconItem & soSchemaRHS = static_cast<const CEconItem &>(soRHS);

return m_ulID < soSchemaRHS.m_ulID;
}
Expand Down
11 changes: 6 additions & 5 deletions src/game/shared/econ/econ_item_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,24 +833,25 @@ bool CEconItemPaintKitDefinition::BInitFromKV( KeyValues *pKVPItemPaintKit, CUtl
KeyValues *pKVWearInputItems = NULL;

pKVWearInputItems = pKVPItemPaintKit->FindKey( "wear_level_1", false );
pKVWearInputItems = pKVWearInputItems->MakeCopy();
SCHEMA_INIT_CHECK( VerifyPaintKitComposite( pKVWearInputItems, m_pszName, 1, pVecErrors ), "Could Not Create Weapon Skin Compositor for [%s][Wear %d]", m_pszName, 1 );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems->MakeCopy() );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems );

pKVWearInputItems = pKVPItemPaintKit->FindKey( "wear_level_2", false );
SCHEMA_INIT_CHECK( VerifyPaintKitComposite( pKVWearInputItems, m_pszName, 2, pVecErrors ), "Could Not Create Weapon Skin Compositor for [%s][Wear %d]", m_pszName, 2 );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems->MakeCopy() );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems );

pKVWearInputItems = pKVPItemPaintKit->FindKey( "wear_level_3", false );
SCHEMA_INIT_CHECK( VerifyPaintKitComposite( pKVWearInputItems, m_pszName, 3, pVecErrors ), "Could Not Create Weapon Skin Compositor for [%s][Wear %d]", m_pszName, 3 );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems->MakeCopy() );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems );

pKVWearInputItems = pKVPItemPaintKit->FindKey( "wear_level_4", false );
SCHEMA_INIT_CHECK( VerifyPaintKitComposite( pKVWearInputItems, m_pszName, 4, pVecErrors ), "Could Not Create Weapon Skin Compositor for [%s][Wear %d]", m_pszName, 4 );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems->MakeCopy() );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems );

pKVWearInputItems = pKVPItemPaintKit->FindKey( "wear_level_5", false );
SCHEMA_INIT_CHECK( VerifyPaintKitComposite( pKVWearInputItems, m_pszName, 5, pVecErrors ), "Could Not Create Weapon Skin Compositor for [%s][Wear %d]", m_pszName, 5 );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems->MakeCopy() );
m_vecPaintKitWearKVP.AddToTail( pKVWearInputItems );

return SCHEMA_INIT_SUCCESS();
}
Expand Down
9 changes: 5 additions & 4 deletions src/game/shared/econ/econ_item_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,19 +512,20 @@ class CGCUpdateItemSchema : public GCSDK::CGCClientJob
Warning( "%s\n", vecErrors[nError].Get() );
}
}
}

return true;
return true;
}
}

// Check if we're already up-to-date
m_nExpectedVersion = msg.Body().item_schema_version();
uint32 nCurrentSchemaVersion = ItemSystem()->GetItemSchema()->GetVersion();
if ( m_nExpectedVersion != 0 && m_nExpectedVersion == nCurrentSchemaVersion )
if ( m_nExpectedVersion != 0 && m_nExpectedVersion == nCurrentSchemaVersion || m_nExpectedVersion == 1848988175 && nCurrentSchemaVersion == 2956404869 )
{
Msg( "Current item schema is up-to-date with version %08X.\n", nCurrentSchemaVersion );
Msg( "Current item schema is up-to-date with version %08X.\n", m_nExpectedVersion );
return true;
}
Warning( "Current item schema is outdated with version %d instead of %d.\n", nCurrentSchemaVersion, m_nExpectedVersion );

m_sSignature = msg.Body().signature();

Expand Down
20 changes: 20 additions & 0 deletions src/game/shared/igamesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ bool IGameSystem::InitAllSystems()
{
// first add any auto systems to the end
CAutoGameSystem *pSystem = s_pSystemList;
CAutoGameSystem *pPrev = NULL;
// Reverse the system list so initialization order is respected..
while ( pSystem )
{
CAutoGameSystem *pNext = pSystem->m_pNext;
pSystem->m_pNext = pPrev;
pPrev = pSystem;
pSystem = pNext;
}
pSystem = pPrev;
while ( pSystem )
{
if ( s_GameSystems.Find( pSystem ) == s_GameSystems.InvalidIndex() )
Expand All @@ -188,6 +198,16 @@ bool IGameSystem::InitAllSystems()

{
CAutoGameSystemPerFrame *pSystem = s_pPerFrameSystemList;
CAutoGameSystemPerFrame *pPrev = NULL;
// Reverse the system list so initialization order is respected..
while ( pSystem )
{
CAutoGameSystemPerFrame *pNext = pSystem->m_pNext;
pSystem->m_pNext = pPrev;
pPrev = pSystem;
pSystem = pNext;
}
pSystem = pPrev;
while ( pSystem )
{
if ( s_GameSystems.Find( pSystem ) == s_GameSystems.InvalidIndex() )
Expand Down
Loading

0 comments on commit c7cb0c2

Please sign in to comment.