From eff6b5c54905e6cda3aa2396fbd097ab53ecbfec Mon Sep 17 00:00:00 2001 From: march <106459595+marchc1@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:24:15 -0800 Subject: [PATCH 1/2] Fix voice message being incorrect for gmod --- Source.Common/Networking/NetMessages.cs | 9 +++++---- Source.Engine/SV.cs | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source.Common/Networking/NetMessages.cs b/Source.Common/Networking/NetMessages.cs index c1b6c0e42..a3290fb92 100644 --- a/Source.Common/Networking/NetMessages.cs +++ b/Source.Common/Networking/NetMessages.cs @@ -496,13 +496,14 @@ public override string ToString() { public class SVC_VoiceInit : NetMessage { public SVC_VoiceInit() : base(SVC.VoiceInit) { } - public SVC_VoiceInit(ReadOnlySpan codec, int sampleRate) : base(SVC.VoiceInit) { + public SVC_VoiceInit(ReadOnlySpan codec, int quality) : base(SVC.VoiceInit) { VoiceCodec = codec.IsEmpty ? "" : new(codec.SliceNullTerminatedString()); - SampleRate = sampleRate; + Quality = quality; } public override NetChannelGroup GetGroup() => NetChannelGroup.SignOn; public string VoiceCodec = ""; + public int Quality; public int SampleRate; public override bool ReadFromBuffer(bf_read buffer) { @@ -513,6 +514,7 @@ public override bool ReadFromBuffer(bf_read buffer) { VoiceCodec = "steam"; byte legacyQuality = buffer.ReadByte(); + Quality = legacyQuality; if (legacyQuality == 255) { // v2 packet SampleRate = buffer.ReadShort(); @@ -544,8 +546,7 @@ public override bool ReadFromBuffer(bf_read buffer) { public override bool WriteToBuffer(bf_write buffer) { buffer.WriteNetMessageType(this); buffer.WriteString(VoiceCodec); - buffer.WriteByte( /* Legacy Quality Field */ 255); - buffer.WriteShort(SampleRate); + buffer.WriteByte(Quality); return !buffer.Overflowed; } } diff --git a/Source.Engine/SV.cs b/Source.Engine/SV.cs index 29cd0b4dd..85bcdb1c6 100644 --- a/Source.Engine/SV.cs +++ b/Source.Engine/SV.cs @@ -308,8 +308,7 @@ public static void WriteVoiceCodec(bf_write buf) { // Only send in multiplayer. Otherwise, we don't want voice. ReadOnlySpan codec = sv.IsMultiplayer() ? sv_voicecodec.GetString() : null; - int sampleRate = !codec.IsEmpty ? Voice.GetDefaultSampleRate(codec) : 0; - SVC_VoiceInit voiceinit = new(codec, sampleRate); + SVC_VoiceInit voiceinit = new(codec, 5); voiceinit.WriteToBuffer(buf); } From c108fbc34cf86edf95473f2a73f8ee6f251f11da Mon Sep 17 00:00:00 2001 From: march <106459595+marchc1@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:24:20 -0800 Subject: [PATCH 2/2] Fix missing stringtables on dedicated --- Game.Server/GameInterface.cs | 52 ++++++++++++++++++++- Game.Shared/GarrysMod/LuaGlobalFunctions.cs | 4 ++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Game.Server/GameInterface.cs b/Game.Server/GameInterface.cs index 3cd9092e0..8edc76cc9 100644 --- a/Game.Server/GameInterface.cs +++ b/Game.Server/GameInterface.cs @@ -37,10 +37,49 @@ public static class GameInterface public const int MAX_MATERIAL_STRING_BITS = 10; public const int MAX_MATERIAL_STRINGS = 1 << MAX_MATERIAL_STRING_BITS; + public const int MAX_PARTICLESYSTEMS_STRING_BITS = 12; + public const int MAX_PARTICLESYSTEMS_STRINGS = 1 << MAX_PARTICLESYSTEMS_STRING_BITS; + + public const int MAX_VGUI_SCREEN_STRING_BITS = 8; + public const int MAX_VGUI_SCREEN_STRINGS = 1 << MAX_VGUI_SCREEN_STRING_BITS; + + public static INetworkStringTable? g_pStringTableParticleEffectNames; public static INetworkStringTable? g_pStringTableEffectDispatch; + public static INetworkStringTable? g_pStringTableVguiScreen; public static INetworkStringTable? g_pStringTableClientSideChoreoScenes; public static INetworkStringTable? g_pStringTableMaterials; + public static void PrecacheParticleSystem(ReadOnlySpan particleSystemName) { + if (particleSystemName.IsStringEmpty) + return; + g_pStringTableParticleEffectNames?.AddString(true, particleSystemName); + } + + public static int GetParticleSystemIndex(ReadOnlySpan particleSystemName) { + if (particleSystemName.IsEmpty) + return 0; + + int index = g_pStringTableParticleEffectNames!.FindStringIndex(particleSystemName); + if (index != INetworkStringTable.INVALID_STRING_INDEX) + return index; + + if (!particleSystemName.IsStringEmpty) { + PrecacheParticleSystem(particleSystemName); + index = g_pStringTableParticleEffectNames.FindStringIndex(particleSystemName); + if (index != INetworkStringTable.INVALID_STRING_INDEX) + return index; + } + + DevWarning($"Server: Missing precache for particle system \"{particleSystemName}\"!\n"); + return 0; + } + + public static ReadOnlySpan GetParticleSystemNameFromIndex(int index) { + if (index < g_pStringTableParticleEffectNames!.GetMaxStrings()) + return g_pStringTableParticleEffectNames.GetString(index); + return "error"; + } + public static void PrecacheMaterial(ReadOnlySpan materialName) { g_pStringTableMaterials!.AddString(true, materialName); } @@ -260,9 +299,14 @@ public void BuildAdjacentMapList() { public void CreateNetworkStringTables() { // throw new NotImplementedException(); + g_pStringTableParticleEffectNames = networkstringtable.CreateStringTable("ParticleEffectNames", MAX_PARTICLESYSTEMS_STRINGS); g_pStringTableEffectDispatch = networkstringtable.CreateStringTable("EffectDispatch", EffectData.MAX_EFFECT_DISPATCH_STRINGS); - g_pStringTableClientSideChoreoScenes = networkstringtable.CreateStringTable("Scenes", MAX_CHOREO_SCENES_STRINGS); + g_pStringTableVguiScreen = networkstringtable.CreateStringTable("VguiScreen", MAX_VGUI_SCREEN_STRINGS); g_pStringTableMaterials = networkstringtable.CreateStringTable("Materials", MAX_MATERIAL_STRINGS); + g_pStringTableClientSideChoreoScenes = networkstringtable.CreateStringTable("Scenes", MAX_CHOREO_SCENES_STRINGS); + + g_pStringTableMaterials!.AddString(true, "debug/debugempty"); + PrecacheParticleSystem("error"); GameRulesRegister.CreateNetworkStringTables_GameRules(); @@ -445,7 +489,11 @@ public void GMOD_OnAllSoundsStoppedSV() { } public void GMOD_OnStringTablesRemoved() { - // todo: g_pStringTableParticleEffectNames, g_pStringTableEffectDispatch, g_pStringTableVguiScreen, g_pStringTableMaterials, g_pStringTableClientSideChoreoScenes = null + g_pStringTableParticleEffectNames = null; + g_pStringTableEffectDispatch = null; + g_pStringTableVguiScreen = null; + g_pStringTableMaterials = null; + g_pStringTableClientSideChoreoScenes = null; GameRulesRegister.ResetNetworkStringTables_GameRules(); #if GMOD_DLL Game.Server.GarrysMod.NetworkString.Reset(); diff --git a/Game.Shared/GarrysMod/LuaGlobalFunctions.cs b/Game.Shared/GarrysMod/LuaGlobalFunctions.cs index c6a5c05f0..405ed4c57 100644 --- a/Game.Shared/GarrysMod/LuaGlobalFunctions.cs +++ b/Game.Shared/GarrysMod/LuaGlobalFunctions.cs @@ -171,7 +171,11 @@ static int WorldToLocal(ILuaInterface lua) { [LuaGlobal] static int PrecacheParticleSystem(ILuaInterface lua) { string name = lua.CheckString(1); +#if GAME_DLL + GameInterface.PrecacheParticleSystem(name); +#else // PrecacheParticleSystem(name); // TODO! +#endif return 0; }