@@ -37,10 +37,49 @@ public static class GameInterface
3737 public const int MAX_MATERIAL_STRING_BITS = 10 ;
3838 public const int MAX_MATERIAL_STRINGS = 1 << MAX_MATERIAL_STRING_BITS ;
3939
40+ public const int MAX_PARTICLESYSTEMS_STRING_BITS = 12 ;
41+ public const int MAX_PARTICLESYSTEMS_STRINGS = 1 << MAX_PARTICLESYSTEMS_STRING_BITS ;
42+
43+ public const int MAX_VGUI_SCREEN_STRING_BITS = 8 ;
44+ public const int MAX_VGUI_SCREEN_STRINGS = 1 << MAX_VGUI_SCREEN_STRING_BITS ;
45+
46+ public static INetworkStringTable ? g_pStringTableParticleEffectNames ;
4047 public static INetworkStringTable ? g_pStringTableEffectDispatch ;
48+ public static INetworkStringTable ? g_pStringTableVguiScreen ;
4149 public static INetworkStringTable ? g_pStringTableClientSideChoreoScenes ;
4250 public static INetworkStringTable ? g_pStringTableMaterials ;
4351
52+ public static void PrecacheParticleSystem ( ReadOnlySpan < char > particleSystemName ) {
53+ if ( particleSystemName . IsStringEmpty )
54+ return ;
55+ g_pStringTableParticleEffectNames ? . AddString ( true , particleSystemName ) ;
56+ }
57+
58+ public static int GetParticleSystemIndex ( ReadOnlySpan < char > particleSystemName ) {
59+ if ( particleSystemName . IsEmpty )
60+ return 0 ;
61+
62+ int index = g_pStringTableParticleEffectNames ! . FindStringIndex ( particleSystemName ) ;
63+ if ( index != INetworkStringTable . INVALID_STRING_INDEX )
64+ return index ;
65+
66+ if ( ! particleSystemName . IsStringEmpty ) {
67+ PrecacheParticleSystem ( particleSystemName ) ;
68+ index = g_pStringTableParticleEffectNames . FindStringIndex ( particleSystemName ) ;
69+ if ( index != INetworkStringTable . INVALID_STRING_INDEX )
70+ return index ;
71+ }
72+
73+ DevWarning ( $ "Server: Missing precache for particle system \" { particleSystemName } \" !\n ") ;
74+ return 0 ;
75+ }
76+
77+ public static ReadOnlySpan < char > GetParticleSystemNameFromIndex ( int index ) {
78+ if ( index < g_pStringTableParticleEffectNames ! . GetMaxStrings ( ) )
79+ return g_pStringTableParticleEffectNames . GetString ( index ) ;
80+ return "error" ;
81+ }
82+
4483 public static void PrecacheMaterial ( ReadOnlySpan < char > materialName ) {
4584 g_pStringTableMaterials ! . AddString ( true , materialName ) ;
4685 }
@@ -260,9 +299,14 @@ public void BuildAdjacentMapList() {
260299 public void CreateNetworkStringTables ( ) {
261300 // throw new NotImplementedException();
262301
302+ g_pStringTableParticleEffectNames = networkstringtable . CreateStringTable ( "ParticleEffectNames" , MAX_PARTICLESYSTEMS_STRINGS ) ;
263303 g_pStringTableEffectDispatch = networkstringtable . CreateStringTable ( "EffectDispatch" , EffectData . MAX_EFFECT_DISPATCH_STRINGS ) ;
264- g_pStringTableClientSideChoreoScenes = networkstringtable . CreateStringTable ( "Scenes " , MAX_CHOREO_SCENES_STRINGS ) ;
304+ g_pStringTableVguiScreen = networkstringtable . CreateStringTable ( "VguiScreen " , MAX_VGUI_SCREEN_STRINGS ) ;
265305 g_pStringTableMaterials = networkstringtable . CreateStringTable ( "Materials" , MAX_MATERIAL_STRINGS ) ;
306+ g_pStringTableClientSideChoreoScenes = networkstringtable . CreateStringTable ( "Scenes" , MAX_CHOREO_SCENES_STRINGS ) ;
307+
308+ g_pStringTableMaterials ! . AddString ( true , "debug/debugempty" ) ;
309+ PrecacheParticleSystem ( "error" ) ;
266310
267311 GameRulesRegister . CreateNetworkStringTables_GameRules ( ) ;
268312
@@ -445,7 +489,11 @@ public void GMOD_OnAllSoundsStoppedSV() {
445489 }
446490
447491 public void GMOD_OnStringTablesRemoved ( ) {
448- // todo: g_pStringTableParticleEffectNames, g_pStringTableEffectDispatch, g_pStringTableVguiScreen, g_pStringTableMaterials, g_pStringTableClientSideChoreoScenes = null
492+ g_pStringTableParticleEffectNames = null ;
493+ g_pStringTableEffectDispatch = null ;
494+ g_pStringTableVguiScreen = null ;
495+ g_pStringTableMaterials = null ;
496+ g_pStringTableClientSideChoreoScenes = null ;
449497 GameRulesRegister . ResetNetworkStringTables_GameRules ( ) ;
450498#if GMOD_DLL
451499 Game . Server . GarrysMod . NetworkString . Reset ( ) ;
0 commit comments