Compare commits
4 Commits
c3e79c9adf
...
490e0d74e6
| Author | SHA1 | Date | |
|---|---|---|---|
| 490e0d74e6 | |||
| c4e25f6c12 | |||
| 6b014c72db | |||
| c6ca1abc54 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -23,4 +23,5 @@ Desktop.ini
|
||||
|
||||
/.claude
|
||||
/*.png
|
||||
/*.txt
|
||||
/*.txt
|
||||
/*.jpg
|
||||
|
||||
6
Main.cs
6
Main.cs
@@ -56,6 +56,12 @@ namespace KCM
|
||||
public static Dictionary<ushort, string> clientSteamIds = new Dictionary<ushort, string>();
|
||||
public static Dictionary<Guid, BuildingStatePacket> pendingBuildingStatePackets = new Dictionary<Guid, BuildingStatePacket>();
|
||||
|
||||
// Advanced sync logging helper
|
||||
public static void LogSync(string message)
|
||||
{
|
||||
helper.Log($"[SYNC] {message}");
|
||||
}
|
||||
|
||||
public static KCPlayer GetPlayerByClientID(ushort clientId)
|
||||
{
|
||||
return kCPlayers[clientSteamIds[clientId]];
|
||||
|
||||
@@ -46,7 +46,16 @@ namespace KCM.Packets.Game.GameWorld
|
||||
|
||||
public void PlaceBuilding()
|
||||
{
|
||||
Main.helper.Log("Received place building packet for " + uniqueName + " from " + player.name + $"({player.id})");
|
||||
Main.LogSync("========== BUILDING PLACEMENT START ==========");
|
||||
Main.LogSync($"Building: {uniqueName} from player: {player?.name} (id={player?.id})");
|
||||
Main.LogSync($" guid={guid}");
|
||||
Main.LogSync($" globalPosition={globalPosition}");
|
||||
Main.LogSync($" localPosition={localPosition}");
|
||||
Main.LogSync($" rotation={rotation} (euler={rotation.eulerAngles})");
|
||||
Main.LogSync($" built={built}, placed={placed}, open={open}");
|
||||
Main.LogSync($" constructionProgress={constructionProgress}, constructionPaused={constructionPaused}");
|
||||
Main.LogSync($" life={life}, ModifiedMaxLife={ModifiedMaxLife}");
|
||||
Main.LogSync($" yearBuilt={yearBuilt}, decayProtection={decayProtection}");
|
||||
|
||||
// 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);
|
||||
@@ -125,6 +134,23 @@ namespace KCM.Packets.Game.GameWorld
|
||||
Main.helper.Log("unpack stage 2");
|
||||
structureData.UnpackStage2(building);
|
||||
|
||||
// Update materials/textures for correct display
|
||||
building.UpdateMaterialSelection();
|
||||
|
||||
// Update road rotation for proper visuals
|
||||
Road roadComp = building.GetComponent<Road>();
|
||||
if (roadComp != null)
|
||||
{
|
||||
roadComp.UpdateRotation();
|
||||
}
|
||||
|
||||
// Update aqueduct rotation
|
||||
Aqueduct aqueductComp = building.GetComponent<Aqueduct>();
|
||||
if (aqueductComp != null)
|
||||
{
|
||||
aqueductComp.UpdateRotation();
|
||||
}
|
||||
|
||||
building.SetVisibleForFog(false);
|
||||
|
||||
Main.helper.Log("Landmass owner take ownership");
|
||||
@@ -139,15 +165,24 @@ namespace KCM.Packets.Game.GameWorld
|
||||
Main.helper.Log($"Client player ({player.name}) Landmass Names Count: {player.inst.LandMassNames.Count}, Contents: {string.Join(", ", player.inst.LandMassNames)}");
|
||||
|
||||
player.inst.LandMassNames[building.LandMass()] = player.kingdomName;
|
||||
Player.inst.LandMassNames[building.LandMass()] = player.kingdomName;
|
||||
Player.inst.LandMassNames[building.LandMass()] = player.kingdomName;
|
||||
|
||||
//Player.inst = originalPlayer;
|
||||
// Log final building state after placement
|
||||
Main.LogSync("---------- BUILDING PLACED FINAL STATE ----------");
|
||||
Main.LogSync($" Final position: {building.transform.position}");
|
||||
if (building.transform.childCount > 0)
|
||||
{
|
||||
Main.LogSync($" Child[0] rotation: {building.transform.GetChild(0).rotation} (euler={building.transform.GetChild(0).rotation.eulerAngles})");
|
||||
Main.LogSync($" Child[0] localPosition: {building.transform.GetChild(0).localPosition}");
|
||||
}
|
||||
Main.LogSync($" IsBuilt={building.IsBuilt()}, IsPlaced={building.IsPlaced()}");
|
||||
Main.LogSync($" TeamID={building.TeamID()}, LandMass={building.LandMass()}");
|
||||
Main.LogSync("========== BUILDING PLACEMENT END ==========");
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.helper.Log(structureData.uniqueName + " failed to load correctly");
|
||||
Main.LogSync($"FAILED to place building: {structureData.uniqueName} - GetPlaceableByUniqueName returned null");
|
||||
}
|
||||
//building.Init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -128,8 +128,7 @@ namespace KCM.Packets.Handlers
|
||||
|
||||
IPacket packet = DeserialisePacket(messageReceived);
|
||||
|
||||
//Main.helper.Log($"Server Received packet {Packets[id].packet.GetType().Name} from {messageReceived.FromConnection.Id}");
|
||||
|
||||
Main.LogSync($"SERVER RECV: {Packets[id].packet.GetType().Name} (id={id}) from client {messageReceived.FromConnection.Id}");
|
||||
|
||||
if (KCServer.IsRunning)
|
||||
{
|
||||
@@ -169,11 +168,9 @@ namespace KCM.Packets.Handlers
|
||||
var id = messageReceived.MessageId;
|
||||
|
||||
|
||||
//Main.helper.Log($"Client Received packet {Packets[id].packet.GetType().Name} from {messageReceived.FromConnection.Id}");
|
||||
|
||||
IPacket packet = DeserialisePacket(messageReceived);
|
||||
|
||||
//Main.helper.Log($"Client Received packet {Packets[id].packet.GetType().Name} from {packet.clientId}");
|
||||
Main.LogSync($"CLIENT RECV: {Packets[id].packet.GetType().Name} (id={id}) from client {packet.clientId}");
|
||||
|
||||
if (KCClient.client.IsConnected)
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace KCM.Packets
|
||||
{
|
||||
try
|
||||
{
|
||||
Main.LogSync($"SEND TO ALL: {this.GetType().Name} (id={packetId}) except={exceptToClient}");
|
||||
if (exceptToClient == 0)
|
||||
{
|
||||
if (KCServer.IsRunning)
|
||||
@@ -75,6 +76,7 @@ namespace KCM.Packets
|
||||
{
|
||||
try
|
||||
{
|
||||
Main.LogSync($"SEND: {this.GetType().Name} (id={packetId}) to={toClient} myId={KCClient.client?.Id}");
|
||||
if (KCClient.client.IsConnected && toClient == 0)
|
||||
{
|
||||
this.clientId = KCClient.client.Id;
|
||||
|
||||
@@ -58,6 +58,14 @@ namespace KCM.Packets.State
|
||||
if (building == null)
|
||||
return;
|
||||
|
||||
Main.LogSync($"========== BUILDING STATE UPDATE ==========");
|
||||
Main.LogSync($"Building: {uniqueName} guid={guid}");
|
||||
Main.LogSync($" globalPosition={globalPosition}");
|
||||
Main.LogSync($" localPosition={localPosition}");
|
||||
Main.LogSync($" rotation={rotation} (euler={rotation.eulerAngles})");
|
||||
Main.LogSync($" built={built}, placed={placed}, open={open}");
|
||||
Main.LogSync($" constructionProgress={constructionProgress}");
|
||||
|
||||
try
|
||||
{
|
||||
building.UniqueName = uniqueName;
|
||||
|
||||
38
README.md
38
README.md
@@ -0,0 +1,38 @@
|
||||
# Kingdoms and Castles Multiplayer Mod - Bug Tracker
|
||||
|
||||
## Ismert hibak / Known Issues
|
||||
|
||||
### Host-Client Sync Problems
|
||||
|
||||
| Hiba | Status | Megjegyzes |
|
||||
|------|--------|------------|
|
||||
| Rossz kapcsolat, "server disconnected" hibak | Reszben javitva | Event handler duplikacio es session cleanup javitva |
|
||||
| Jatek ujrainditasa szukseges lobby/save valtas utan | Reszben javitva | Session cleanup hozzaadva LobbyManager-ben |
|
||||
| Utak/epuletek nem toltenek be helyesen vagy atfednek | Vizsgalat alatt | UpdateMaterialSelection() es UpdateRotation() hozzaadva |
|
||||
| Eroforrasok nem mentenek/toltenek helyesen | Meg nincs elkezdve | |
|
||||
| NPC-k veletlenszeruen megallnak es nem mozognak load utan | Vizsgalat alatt | TeleportTo problema javitva, BakePathing hozzaadva |
|
||||
| Orientaciok (rotaciok) nem szinkronizalodnak | Reszben javitva | Rotation es localPosition kozvetlenul alkalmazva WorldPlace-ben |
|
||||
| Host torol valamit -> kliens nem latja | Meg nincs elkezdve | BuildingDestroy packet szukseges |
|
||||
| Host nem latja a kliens epuleteit helyesen (rossz textúrak) | Javitva | UpdateMaterialSelection() hozzaadva WorldPlace.cs-ben |
|
||||
|
||||
### Status Definiciok
|
||||
|
||||
- **Javitva**: A hiba javitva lett es tesztelve
|
||||
- **Reszben javitva**: Javitas megkezdve, de meg nem teljes
|
||||
- **Vizsgalat alatt**: Debug logging hozzaadva, vizsgaljuk a problemat
|
||||
- **Meg nincs elkezdve**: A hiba ismert, de meg nem kezdtuk el javitani
|
||||
|
||||
## Recent Changes
|
||||
|
||||
### 2024-12-14
|
||||
- Advanced sync logging hozzaadva `[SYNC]` prefix-szel
|
||||
- Building placement reszletes logging (minden property)
|
||||
- Packet send/receive logging
|
||||
- Building state update logging
|
||||
|
||||
### Korabbi javitasok
|
||||
- KCServer.cs: Event handler duplikacio javitas
|
||||
- LobbyManager.cs: Session cleanup (clientSteamIds, loadingSave)
|
||||
- WorldPlace.cs: Building guid duplikacio check, rotation/localPosition fix
|
||||
- AddVillagerPacket.cs: Villager position sync + duplikacio check
|
||||
- Main.cs: BakePathing() hozzaadva PlayerAddBuildingHook-ban
|
||||
|
||||
@@ -26,7 +26,12 @@ namespace KCM.StateManagement.BuildingState
|
||||
|
||||
Building building = (Building)observer.state;
|
||||
|
||||
//Main.helper.Log("Should send building network update for: " + building.UniqueName);
|
||||
Main.LogSync($"SENDING building state update for: {building.UniqueName} guid={building.guid}");
|
||||
Main.LogSync($" position={building.transform.position}");
|
||||
if (building.transform.childCount > 0)
|
||||
{
|
||||
Main.LogSync($" rotation={building.transform.GetChild(0).rotation} (euler={building.transform.GetChild(0).rotation.eulerAngles})");
|
||||
}
|
||||
|
||||
new BuildingStatePacket()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user