Fix: Prevent duplicate building placement via guid check

- 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 <noreply@anthropic.com>
This commit is contained in:
2025-12-14 10:51:53 +01:00
parent f7fc5a3969
commit 7d6c915b49

View File

@@ -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;