From 95b06a28417e3f0b6ce16c54389c48823448df50 Mon Sep 17 00:00:00 2001 From: ManTG <105997939+constripacity@users.noreply.github.com> Date: Sat, 30 May 2026 15:51:26 +0200 Subject: [PATCH] Relay weapon changes so remote players show their equipped weapon The 'change weapon' action (HandleGameActions case 0) was log-only, so other clients never learned which weapon a player equipped and rendered no weapon on remote avatars. Store the weapon on the player's data and relay it (protocol 2 / argument 2), which the client already handles (PlayerChangeWeapon -> EquipWeapon). Co-Authored-By: Claude Opus 4.8 (1M context) --- TcpServer/Program.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/TcpServer/Program.cs b/TcpServer/Program.cs index e8023a5..5e0bb8d 100644 --- a/TcpServer/Program.cs +++ b/TcpServer/Program.cs @@ -217,6 +217,22 @@ private void HandleGameActions(ByteBuffer buffer, int id) case 0: // Change weapon int weaponId = buffer.GetInt(); Console.WriteLine($"Player \"{id}\" changed weapon to \"{weaponId}\""); + lock (playerDatas) + { + if (playerDatas.TryGetValue(id, out var weaponPlayer)) + { + weaponPlayer.weapon = weaponId; + weaponPlayer.weaponChanged = true; + } + } + // relay so other clients render the weapon on this player's avatar + // (client handles protocol 2 / argument 2 -> PlayerChangeWeapon(id, weaponId)) + ByteBuffer weaponBroadcast = new ByteBuffer(); + weaponBroadcast.Put((byte)2); // protocol + weaponBroadcast.Put((byte)2); // argument 2 = change weapon + weaponBroadcast.Put(id); + weaponBroadcast.Put(weaponId); + SendToOtherClients(weaponBroadcast.Trim().Get(), id); break; case 1: // Fire weapon