125 Commits

Author SHA1 Message Date
cb82d3706f fix: Add missing using directive for Riptide.Demos.Steam.PlayerHosted in SaveTransferPacket 2025-12-14 23:58:51 +01:00
12a207989e fix: Reset save transfer state and streamline loading logic in SaveTransferPacket and StartGame 2025-12-14 23:56:41 +01:00
4afcaccf75 fix: Reset save transfer state and update progress bar calculations 2025-12-14 23:54:49 +01:00
8f13282e04 fix: Improve job type initialization and handle game state during loading 2025-12-14 23:45:12 +01:00
0d7d989f76 fix: Change log warning to info for invalid seed handling in world generation 2025-12-14 23:24:57 +01:00
1cc3042781 feat: Implement various multiplayer stability and synchronization fixes
This commit addresses several critical issues reported by the user to improve the stability and synchronization of the Kingdoms and Castles multiplayer mod.

Key changes include:

- Improved Lobby Stability: Fixed NullReferenceException during lobby entry.
- Enhanced Session Cleanup: Refined disconnection logic to prevent Steamworks shutdown and enable seamless new game starts without client restarts.
- Optimized Building Synchronization: Implemented a throttling mechanism for building state updates to reduce network traffic.
- Resolved Villager Freezing: Introduced a null check for destroyed observed buildings to prevent synchronization cascades.
- Fixed Map Desynchronization: Ensured the host reliably sends the world seed to all clients before game start.
- Reliable Save Game Transfer: Switched save file chunk transfer to reliable messaging mode to prevent incomplete save loads.
- Addressed Compilation Issues: Resolved all compilation errors and warnings that arose from the implemented fixes.
2025-12-14 23:22:57 +01:00
181936e3d4 Refactor seed handling in game start logic and improve packet sending reliability 2025-12-14 23:22:34 +01:00
62db70c1c4 Refactor packet sending to use SendReliable method for improved reliability and remove unnecessary logging 2025-12-14 23:18:23 +01:00
36acbb57c5 Enhance reliability of chunk data transmission and update world seed handling on game start 2025-12-14 23:13:43 +01:00
76f1033bd2 Fix null reference handling in building state updates 2025-12-14 23:00:23 +01:00
26b5f1201e Refactor player entry initialization and optimize building state update logic 2025-12-14 22:27:43 +01:00
9ee675ac19 Implement multiplayer session cleanup on client disconnection 2025-12-14 22:12:50 +01:00
3124f82a2f alap 2025-12-14 21:08:19 +01:00
3a7b81bfd7 save 2025-12-14 21:04:22 +01:00
c4eb7e944d Fix map synchronization between host and clients
Problem: Clients received WorldSeed packet before ServerSettings,
causing world generation with wrong mapSize/mapBias/mapRivers
parameters. Same seed but different parameters = different maps.

Solution: Include all map parameters directly in WorldSeed packet:
- WorldSize (map size)
- WorldType (map bias - continents/islands/etc)
- WorldRivers (river/lake density)

Now packet order doesn't matter - WorldSeed has everything needed
for identical world generation across all clients.

Changes:
- WorldSeed.cs: Add map parameters, set before Generate()
- ClientConnected.cs: Send full world params to joining clients
- ServerLobbyScript.cs: Send full params on new world generation
- Added [WORLD SYNC] debug logging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 21:00:15 +01:00
4057cf37c5 sex 2025-12-14 20:52:55 +01:00
fc467f4af8 Fix StartGame NullReferenceException in multiplayer
Remove MainMenuMode.StartGame() reflection call that expected
"Choose Your Map" screen state. Clients never see this screen
in multiplayer, causing null references. Now transitions directly
to playing mode like save loading does.

Fixes: NullReferenceException at MainMenuMode.StartGame()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 20:52:44 +01:00
dbc0328c6f Merge pull request 'codex-3' (#4) from codex-3 into main
Reviewed-on: #4
2025-12-14 20:29:45 +01:00
5f67f488f6 Fix compilation warnings and namespace issue
Fixed issues:
1. Added missing using directive for KCM.Packets namespace
   - Fixes ShowModal class not found error in Main.cs

2. Removed unused 'callTree' variable (Main.cs:460)
   - Variable was defined but never used

3. Removed unused 'awake' field (ServerLobbyScript.cs:63)
   - Field was assigned but never used

All compilation warnings resolved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 20:12:08 +01:00
b0f790cb6e Fix 3 critical bugs: server shutdown, building placement crashes
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>
2025-12-14 20:06:53 +01:00
deb0c0ad92 Document follow-up steps 2025-12-14 16:33:45 +01:00
10d20e29ad Kódban található KRITIKUS hibák részletes dokumentációja
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>
2025-12-14 16:11:48 +01:00
a3409a2d5c asd 2025-12-14 16:07:35 +01:00
5b0f957295 Dokumentálva a README.md fájlban található hibák
Ú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>
2025-12-14 16:04:41 +01:00
faaedcc0fd Update bug tracker with complete log analysis
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>
2025-12-14 16:00:25 +01:00
d87c12384e Update bug tracker with issues found from output.txt analysis
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>
2025-12-14 15:58:02 +01:00
560a985323 Add Keep placement bug to tracker
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>
2025-12-14 15:42:26 +01:00
490e0d74e6 Add bug tracker README with known issues and status
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 15:37:48 +01:00
c4e25f6c12 Add advanced sync logging for debugging host-client sync issues
- 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>
2025-12-14 15:35:57 +01:00
6b014c72db Fix building materials and road/aqueduct rotation for remote players
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>
2025-12-14 15:27:41 +01:00
c6ca1abc54 hm 2025-12-14 15:25:29 +01:00
c3e79c9adf Merge pull request 'codex-2' (#3) from codex-2 into main
Reviewed-on: #3
2025-12-14 15:10:39 +01:00
dca0140aab Improve multiplayer sync stability 2025-12-14 14:51:46 +01:00
55e3cd57e7 yes 2025-12-14 14:45:37 +01:00
4685bc61c2 asd 2025-12-14 14:41:35 +01:00
7a14303353 Initialize player entry banner before SetValues 2025-12-14 14:21:20 +01:00
a918262d99 Always point save dir to multiplayer folder 2025-12-14 14:18:03 +01:00
87f65320c0 Broadcast villager positions from FixedUpdate 2025-12-14 14:15:45 +01:00
97bbf059a9 Specify villager update signature 2025-12-14 14:14:21 +01:00
aa6fb797c2 Merge branch 'codex' 2025-12-14 14:12:29 +01:00
739eba8289 Cast villager to Component via object 2025-12-14 13:33:44 +01:00
1e6f09df18 Guard villager movement snapshot with component 2025-12-14 13:31:49 +01:00
15cad47b52 Broadcast villager movement from server 2025-12-14 13:30:23 +01:00
c074a86423 Find resource storage type via known assemblies 2025-12-14 13:20:48 +01:00
1035f06884 Lookup resource storage type safely 2025-12-14 13:12:08 +01:00
b05c3415f2 codex talán fixálta idk 2025-12-14 13:09:32 +01:00
b02af4d0c7 asd 2025-12-14 12:59:18 +01:00
5dba8137c3 Fix: Remove AddBuilding from ProcessBuildingHook
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>
2025-12-14 11:58:00 +01:00
b3d7108574 Debug: Add detailed logging to ProcessBuildingHook
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>
2025-12-14 11:50:31 +01:00
ce1c067fca Fix: Add PlaceFromLoad and UnpackStage2 in ProcessBuildingHook
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>
2025-12-14 11:45:59 +01:00