Skip to content

Commit 49e14e6

Browse files
committed
Implement ValveSoftware#1483 with ways to easily disable it when needed.
1 parent 2e7cc6e commit 49e14e6

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ BDSBASE_ACHIEVEMENT_NOTIFICATIONS
9191
- Users can easily change the look of the panels with the cl_achievements_theme command.
9292
- This allows users to easily see unlocked achievements and achievement progress.
9393

94+
BDSBASE_TEMP_FIXDYNAMICMODELS
95+
- Games: All
96+
- This enables Pull Request #1483 (https://github.com/ValveSoftware/source-sdk-2013/pull/1483) by default which fixes issues with dynamic models in listen servers.
97+
- This is a temporary workaround and is not recomended to be enabled with future versions of the engine.
98+
- If this is disabled, use the command line variable -dynamicmodelsfix to enable the fix.
99+
94100
## Credits:
95101
- TheBetaM for the custom schema code. (https://github.com/TheBetaM/tf-solo)
96102
- rafradek for some bot AI changes (sigsegv-mvm) (https://github.com/rafradek/sigsegv-mvm)

src/game/client/cdll_client_int.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,24 @@ void CHLClient::ResetStringTablePointers()
19691969
#endif
19701970
}
19711971

1972+
#ifdef BDSBASE
1973+
static void ClearClientDynamicModelList()
1974+
{
1975+
#ifndef BDSBASE_TEMP_FIXDYNAMICMODELS
1976+
if (CommandLine()->CheckParm("-dynamicmodelsfix"))
1977+
#endif
1978+
{
1979+
// engine bugfix: clear out client dynamic model list for listen servers
1980+
// TODO remove this when the engine is updated
1981+
struct CModelInfo : IVModelInfoClient
1982+
{
1983+
CUtlVector< model_t* > m_vecDynamicModels;
1984+
};
1985+
static_cast<CModelInfo*>(modelinfo)->m_vecDynamicModels.Purge();
1986+
}
1987+
}
1988+
#endif
1989+
19721990
//-----------------------------------------------------------------------------
19731991
// Purpose: Per level de-init
19741992
//-----------------------------------------------------------------------------
@@ -2040,6 +2058,10 @@ void CHLClient::LevelShutdown( void )
20402058

20412059
messagechars->Clear();
20422060

2061+
#ifdef BDSBASE
2062+
ClearClientDynamicModelList();
2063+
#endif
2064+
20432065
#ifndef TF_CLIENT_DLL
20442066
// don't want to do this for TF2 because we have particle systems in our
20452067
// character loadout screen that can be viewed when we're not connected to a server

src/game/client/client_quiver.vpc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ $Configuration
3030
$PreprocessorDefinitions "$BASE;DISABLE_GC_CONNECTION;DISABLE_IN_SOURCESDK;INVENTORY_VIA_WEBAPI" [$SOURCESDK]
3131
//custom options
3232
$PreprocessorDefinitions "$BASE;QUIVER_DLL;BDSBASE_DISCORD;BDSBASE_USE_LOCAL_SCHEMA;BDSBASE_CUSTOM_SCHEMA;BDSBASE_LEGACY_MAINMENU;BDSBASE_CURATED_ITEMS;BDSBASE_LEGACY_VIEWMODELS;BDSBASE_CURATED_ITEMS_ALLOWCOSMETICWEAPONS;BDSBASE_CURATED_ITEMS_GIVEWHITELISTEDITEMS;BDSBASE_ACHIEVEMENT_NOTIFICATIONS"
33+
//temp
34+
$PreprocessorDefinitions "$BASE;BDSBASE_TEMP_FIXDYNAMICMODELS"
3335
}
3436
}
3537

src/game/server/baseentity.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,30 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CBaseEntity, DT_BaseEntity )
318318

319319
END_SEND_TABLE()
320320

321+
#ifdef BDSBASE
322+
static bool g_bInRegisterModelLoadCallback = false;
323+
static void MarkDynamicModelLoadedStringTable(const model_t* pModel)
324+
{
325+
#ifndef BDSBASE_TEMP_FIXDYNAMICMODELS
326+
if (CommandLine()->CheckParm("-dynamicmodelsfix"))
327+
#endif
328+
{
329+
// engine bugfix: ensure this dynamic model is marked as loaded in the string table
330+
// TODO remove this when the engine is updated
331+
extern INetworkStringTable* g_pStringTableDynamicModels;
332+
if (g_pStringTableDynamicModels)
333+
{
334+
const char* pModelName = modelinfo->GetModelName(pModel);
335+
int nIdx = g_pStringTableDynamicModels->FindStringIndex(pModelName);
336+
if (nIdx != INVALID_STRING_INDEX)
337+
{
338+
bool bLoaded = true;
339+
g_pStringTableDynamicModels->SetStringUserData(nIdx, sizeof(bLoaded), &bLoaded);
340+
}
341+
}
342+
}
343+
}
344+
#endif
321345

322346
// dynamic models
323347
class CBaseEntityModelLoadProxy
@@ -335,7 +359,16 @@ class CBaseEntityModelLoadProxy
335359
public:
336360
explicit CBaseEntityModelLoadProxy( CBaseEntity *pEntity ) : m_pHandler( new Handler( pEntity ) ) { }
337361
~CBaseEntityModelLoadProxy() { delete m_pHandler; }
362+
#ifdef BDSBASE
363+
void Register(int nModelIndex) const
364+
{
365+
g_bInRegisterModelLoadCallback = true;
366+
modelinfo->RegisterModelLoadCallback(nModelIndex, m_pHandler);
367+
g_bInRegisterModelLoadCallback = false;
368+
}
369+
#else
338370
void Register( int nModelIndex ) const { modelinfo->RegisterModelLoadCallback( nModelIndex, m_pHandler ); }
371+
#endif
339372
operator CBaseEntity * () const { return m_pHandler->m_pEntity; }
340373

341374
private:
@@ -347,6 +380,9 @@ static CUtlHashtable< CBaseEntityModelLoadProxy, empty_t, PointerHashFunctor, Po
347380

348381
void CBaseEntityModelLoadProxy::Handler::OnModelLoadComplete( const model_t *pModel )
349382
{
383+
#ifdef BDSBASE
384+
MarkDynamicModelLoadedStringTable(pModel);
385+
#endif
350386
m_pEntity->OnModelLoadComplete( pModel );
351387
sg_DynamicLoadHandlers.Remove( m_pEntity ); // NOTE: destroys *this!
352388
}

src/game/server/gameinterface.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ INetworkStringTable *g_pStringTableServerPopFiles = NULL;
236236
INetworkStringTable *g_pStringTableServerMapCycleMvM = NULL;
237237
#endif
238238

239+
#ifdef BDSBASE
240+
INetworkStringTable* g_pStringTableDynamicModels = NULL;
241+
#endif
242+
239243
CStringTableSaveRestoreOps g_VguiScreenStringOps;
240244

241245
// Holds global variables shared between engine and game.
@@ -1514,6 +1518,10 @@ void CServerGameDLL::CreateNetworkStringTables( void )
15141518
g_pStringTableServerMapCycleMvM = networkstringtable->CreateStringTable( "ServerMapCycleMvM", 128 );
15151519
#endif
15161520

1521+
#ifdef BDSBASE
1522+
g_pStringTableDynamicModels = networkstringtable->FindTable("DynamicModels");
1523+
#endif
1524+
15171525
bool bPopFilesValid = true;
15181526
(void)bPopFilesValid; // Avoid unreferenced variable warning
15191527

src/game/server/server_quiver.vpc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ $Configuration
2323
$PreprocessorDefinitions "$BASE;DISABLE_GC_CONNECTION;DISABLE_IN_SOURCESDK;INVENTORY_VIA_WEBAPI" [$SOURCESDK]
2424
//custom options
2525
$PreprocessorDefinitions "$BASE;QUIVER_DLL;BDSBASE_DISCORD;BDSBASE_USE_LOCAL_SCHEMA;BDSBASE_CUSTOM_SCHEMA;BDSBASE_LEGACY_MAINMENU;BDSBASE_CURATED_ITEMS;BDSBASE_LEGACY_VIEWMODELS;BDSBASE_CURATED_ITEMS_ALLOWCOSMETICWEAPONS;BDSBASE_CURATED_ITEMS_GIVEWHITELISTEDITEMS;BDSBASE_ACHIEVEMENT_NOTIFICATIONS"
26+
//temp
27+
$PreprocessorDefinitions "$BASE;BDSBASE_TEMP_FIXDYNAMICMODELS"
2628
}
2729
}
2830

0 commit comments

Comments
 (0)