Skip to content

Commit 822f164

Browse files
committed
perf(init): lazily load parsed data for game DLL when on a listen server
during startup, the particles manifest and item schema were being parsed in both the server DLL and client DLL on startup. this greatly delays a player's ability quickly launch the game and queue into a match. so, we can instead just skip initializing for server DLL until we need the manifests at map load. particles are already parsed specifically for the map at level init, and pending item schema updates from the GC are also initialized at level init, so this should be a fine change. it also shouldn't touch the dedicated server path.
1 parent c43e2cb commit 822f164

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

src/game/server/gameinterface.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CServerGameDLL, IServerGameDLL, INTERFACEVERSI
565565
// When bumping the version to this interface, check that our assumption is still valid and expose the older version in the same way
566566
COMPILE_TIME_ASSERT( INTERFACEVERSION_SERVERGAMEDLL_INT == 10 );
567567

568+
static bool bParsedParticles = false;
569+
568570
bool CServerGameDLL::DLLInit( CreateInterfaceFn appSystemFactory,
569571
CreateInterfaceFn physicsFactory, CreateInterfaceFn fileSystemFactory,
570572
CGlobalVars *pGlobals)
@@ -727,7 +729,11 @@ bool CServerGameDLL::DLLInit( CreateInterfaceFn appSystemFactory,
727729
InvalidateQueryCache();
728730

729731
// Parse the particle manifest file & register the effects within it
730-
ParseParticleEffects( false, false );
732+
if ( engine->IsDedicatedServer() )
733+
{
734+
ParseParticleEffects( false, false );
735+
bParsedParticles = true;
736+
}
731737

732738
// try to get debug overlay, may be NULL if on HLDS
733739
debugoverlay = (IVDebugOverlay *)appSystemFactory( VDEBUG_OVERLAY_INTERFACE_VERSION, NULL );
@@ -958,6 +964,11 @@ bool CServerGameDLL::LevelInit( const char *pMapName, char const *pMapEntities,
958964
if ( pItemSchema )
959965
{
960966
pItemSchema->BInitFromDelayedBuffer();
967+
// First valid class must be non-zero if we have a valid schema
968+
if ( pItemSchema->GetFirstValidClass() == 0 )
969+
{
970+
InventoryManager()->InitializeInventory();
971+
}
961972
}
962973
#endif // USES_ECON_ITEMS
963974

@@ -970,6 +981,12 @@ bool CServerGameDLL::LevelInit( const char *pMapName, char const *pMapEntities,
970981
UpdateRichPresence();
971982
}
972983

984+
if ( !bParsedParticles )
985+
{
986+
ParseParticleEffects( false, false );
987+
bParsedParticles = true;
988+
}
989+
973990
//Tony; parse custom manifest if exists!
974991
ParseParticleEffectsMap( pMapName, false );
975992

src/game/shared/econ/econ_item_inventory.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ bool CInventoryManager::Init( void )
303303
// Purpose:
304304
//-----------------------------------------------------------------------------
305305
void CInventoryManager::PostInit( void )
306+
{
307+
#ifdef GAME_DLL
308+
if ( engine->IsDedicatedServer() )
309+
#endif
310+
{
311+
InitializeInventory();
312+
}
313+
}
314+
315+
void CInventoryManager::InitializeInventory()
306316
{
307317
// Initialize the item system.
308318
ItemSystem()->Init();
@@ -443,7 +453,6 @@ void CInventoryManager::LevelShutdownPostEntity( void )
443453
ItemSystem()->ResetAttribStringCache();
444454
}
445455

446-
447456
//-----------------------------------------------------------------------------
448457
// Purpose: Lets the client know that we're now connected to the GC
449458
//-----------------------------------------------------------------------------

src/game/shared/econ/econ_item_inventory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ class CInventoryManager : public CAutoGameSystemPerFrame
216216
virtual void LevelInitPreEntity( void ) OVERRIDE;
217217
virtual void LevelShutdownPostEntity( void ) OVERRIDE;
218218

219+
virtual void InitializeInventory( void );
220+
219221
#ifdef CLIENT_DLL
220222
// Gets called each frame
221223
virtual void Update( float frametime ) OVERRIDE;

src/game/shared/tf/tf_item_inventory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ CTFInventoryManager::~CTFInventoryManager( void )
220220
void CTFInventoryManager::PostInit( void )
221221
{
222222
BaseClass::PostInit();
223+
}
224+
225+
void CTFInventoryManager::InitializeInventory()
226+
{
227+
BaseClass::InitializeInventory();
223228
GenerateBaseItems();
224229
}
225230

src/game/shared/tf/tf_item_inventory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class CTFInventoryManager : public CInventoryManager
150150
~CTFInventoryManager();
151151

152152
virtual void PostInit( void );
153+
virtual void InitializeInventory();
153154

154155
#ifdef CLIENT_DLL
155156
virtual CPlayerInventory *GeneratePlayerInventoryObject() const { return new CTFPlayerInventory; }

0 commit comments

Comments
 (0)