Skip to content

Commit 1ae3926

Browse files
committed
fix inventory initialization
1 parent 8ccf8e2 commit 1ae3926

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
@@ -296,13 +296,23 @@ void CInventoryManager::OnPersonaStateChanged( PersonaStateChange_t *info )
296296
//-----------------------------------------------------------------------------
297297
bool CInventoryManager::Init( void )
298298
{
299+
#ifdef GAME_DLL
300+
if ( engine->IsDedicatedServer() )
301+
#endif
302+
{
303+
InitializeInventory();
304+
}
299305
return true;
300306
}
301307

302308
//-----------------------------------------------------------------------------
303309
// Purpose:
304310
//-----------------------------------------------------------------------------
305311
void CInventoryManager::PostInit( void )
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)