Fixed issues:
1. Server now stops when host returns to menu (Main.cs:342-356)
- Notifies clients with "Host disconnected" modal
- Prevents server from running in background
2. PlayerAddBuildingHook NullReferenceException (Main.cs:762-806)
- Added comprehensive null checks for reflection fields
- Added array bounds validation for landMass index
- Added registry initialization checks
- Fixes 98% building placement failure rate
3. IndexOutOfRangeException in WorldPlace (WorldPlace.cs:167-183)
- LandMassNames array auto-expands when needed
- Defensive code prevents index out of bounds errors
Updated README.md:
- Removed fixed issues from bug tracker
- Added "Fixed Issues" section documenting changes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
A README-ben leírt bugok pontos helyének és okának meghatározása
a kódbázisban, javítási javaslatokkal:
DOKUMENTÁLT HIBÁK:
1. Server nem áll le menüváltáskor
- Hely: KCServer.cs (hiányzó logika)
- Ok: OnApplicationQuit csak app bezáráskor hívódik
- Javítás: TransitionToHook-ban server.Stop() hívás
2. PlayerAddBuildingHook NullReferenceException (LEGKRITIKUSABB)
- Hely: Main.cs:764
- Ok: landMassBuildingRegistry.data[landMass] null/hibás indexelés
- Eredmény: 55/56 épület fail (98%!)
- Javítás: NULL check + array méret ellenőrzés
3. IndexOutOfRangeException WorldPlace-ben
- Hely: WorldPlace.cs:167-168
- Ok: LandMassNames tömb túl kicsi
- Okozó: #2 hiba miatt building nem adódik hozzá → tömb nem nő
- Javítás: Védekező kód + #2 javítása
ÖSSZEFÜGGÉSEK:
A három hiba cascade failure-t okoz: server fut menüben →
packeteket fogad → building placement fail (#2) →
IndexOutOfRange (#3) → 98% épület nem jelenik meg!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Új szekció hozzáadva a dokumentációs hibák részletes leírásával:
- Nyelvtani hibák (hiányzó ékezetek 6 helyen)
- Strukturális hiányosságok (bevezető, útmutatók)
- Konzisztencia problémák
A hibák NEM lettek javítva, csak dokumentálva, hogy hol találhatók
és hogyan kell őket javítani. Prioritások meghatározva.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
KRITIKUS: 55/56 (98%) building placement FAILS!
- 56 BUILDING PLACEMENT START
- Only 1 BUILDING PLACEMENT END
- 55 "Error in add building hook" NullReferenceException
- 9 IndexOutOfRangeException
- 2 StartGame.Start() crashes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
KRITIKUS bugs added:
- Server nem all le amikor host kilep menube
- Kliens nem lesz kidobva host kilepesekor
- Packetek erkeznek menu-ben
Building placement errors:
- PlayerAddBuildingHook NullReferenceException (~50+ occurrences)
- IndexOutOfRangeException in WorldPlace
Added log analysis timeline from 15:39-15:56 session.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Multiple Keeps can be placed on same island, causing original player to lose their Keep.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add LogSync() helper method in Main.cs for consistent sync logging
- Log all packet send/receive events in PacketHandler and Packet classes
- Add detailed building placement logging in WorldPlace.cs (all properties, final state)
- Add building state update logging in BuildingStatePacket.cs
- Add building state send logging in BuildingStateManager.cs
All sync logs are prefixed with [SYNC] for easy filtering.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add UpdateMaterialSelection() and UpdateRotation() calls after building
placement to fix visual issues when host views client's buildings.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The original PlayerSaveData.Unpack calls AddBuilding, PlaceFromLoad,
and UnpackStage2 after ProcessBuilding returns. The hook should only
create and initialize the building, not call these methods.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added step-by-step logging to identify where building load fails:
- GetPlaceableByUniqueName result
- Each initialization step
- Exception details if any step fails
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The hook was missing the critical World.inst.PlaceFromLoad() call which:
- Places building in world cells
- Sets up pathing data for villager navigation
- Registers building properly
Also added UnpackStage2() for complete building initialization.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The hook was skipping the original AddBuilding method but not calling
BakePathing(), which is required for villager pathfinding to work.
Without this, villagers cannot find paths to buildings.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove post-load villager TeleportTo refresh (breaks pathfinding)
- Remove periodic villager position sync (TeleportTo interrupts movement)
- Keep ClearVillagerPositionCache for API compatibility
The TeleportTo calls were resetting villager AI state and preventing
them from continuing their movement/work.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename lambda variable 'v' to 'w' to avoid conflict with local 'v'
- Rename local Villager 'v' to 'newVillager' for clarity
- Add missing 'using Assets.Interface' for IResourceStorage
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Server syncs villager positions every ~3 seconds to clients
- Only syncs villagers that moved more than 0.5 units (bandwidth optimization)
- Maintains position cache to detect movement
- Clears cache on lobby leave to prevent stale data
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Re-register all resource storages after load to fix missing resources
- Refresh building pathing for all players
- Teleport villagers to their position to reset stuck pathfinding/AI
- Add comprehensive error handling and logging
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add position property to AddVillagerPacket
- Teleport villager to correct position on client
- Add duplicate guid check to prevent double villager creation
- Send position from Main.cs hook
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 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>
- Clear clientSteamIds dictionary on disconnect
- Reset loadingSave flag to false
- Prevents stale data when rejoining servers
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove static constructor that registered MessageReceived handler
- Add proper cleanup in StartServer() before creating new instance
- Add null checks in IsRunning, Update(), and OnApplicationQuit()
- Prevents double event handler registration on reconnect
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Provides architecture overview, packet system docs, and common patterns
for future development assistance.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>