From 7d6c915b49eae699b3631b7c572994d0ffc19e85 Mon Sep 17 00:00:00 2001 From: devbeni Date: Sun, 14 Dec 2025 10:51:53 +0100 Subject: [PATCH] Fix: Prevent duplicate building placement via guid check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Check if building with same guid already exists before placing - Prevents buildings overlapping from network packet retries - Logs skip when duplicate detected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- Packets/Game/GameWorld/WorldPlace.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Packets/Game/GameWorld/WorldPlace.cs b/Packets/Game/GameWorld/WorldPlace.cs index 34b8249..ab82561 100644 --- a/Packets/Game/GameWorld/WorldPlace.cs +++ b/Packets/Game/GameWorld/WorldPlace.cs @@ -48,6 +48,14 @@ namespace KCM.Packets.Game.GameWorld { Main.helper.Log("Received place building packet for " + uniqueName + " from " + player.name + $"({player.id})"); + // Check for duplicate building by guid to prevent double placement from network retries + var existingBuilding = player.inst.Buildings.data.FirstOrDefault(b => b != null && b.guid == guid); + if (existingBuilding != null) + { + Main.helper.Log($"Building with guid {guid} already exists for player {player.name}, skipping duplicate placement"); + return; + } + //var originalPlayer = Player.inst; //Player.inst = player.inst;