From 60d509344cd744e40d422a54bb230d0d8b956807 Mon Sep 17 00:00:00 2001 From: devbeni Date: Sun, 14 Dec 2025 01:42:22 +0100 Subject: [PATCH] fix? --- Main.cs | 4 ++- Packets/Game/SetSpeed.cs | 54 +++------------------------------------- 2 files changed, 7 insertions(+), 51 deletions(-) diff --git a/Main.cs b/Main.cs index 55b21bc..86ab564 100644 --- a/Main.cs +++ b/Main.cs @@ -637,7 +637,9 @@ namespace KCM lastVillagerMoveMs = now; } - if ((now - lastVillagerMoveMs) >= 15000 && (now - lastVillagerStallLogMs) >= 15000) + // Note: We now have proactive loadTickDelay refresh above, so villager stall detection + // is less critical. Only log if there's an actual extended stall with bad delay values. + if ((now - lastVillagerMoveMs) >= 30000 && (now - lastVillagerStallLogMs) >= 30000) { lastVillagerStallLogMs = now; Main.helper.Log( diff --git a/Packets/Game/SetSpeed.cs b/Packets/Game/SetSpeed.cs index 6e15b91..3fa81b4 100644 --- a/Packets/Game/SetSpeed.cs +++ b/Packets/Game/SetSpeed.cs @@ -21,57 +21,11 @@ namespace KCM.Packets.Game try { - // Apply speed setting + Main.helper.Log($"Received SetSpeed packet: speed={speed}, isPaused={isPaused}"); + + // Simply apply the speed - SpeedControlUISetSpeedHook will handle this correctly + // since we're coming from a packet (PacketHandler.IsHandlingPacket will be true) SpeedControlUI.inst.SetSpeed(speed); - - // Handle pause/unpause state - if (isPaused && Time.timeScale > 0) - { - // Game should be paused - Time.timeScale = 0f; - Main.helper.Log("Game paused via network sync"); - } - else if (!isPaused && Time.timeScale == 0) - { - // Game should be unpaused - restore speed - Time.timeScale = 1f; - SpeedControlUI.inst.SetSpeed(speed); - Main.helper.Log("Game unpaused via network sync"); - } - - // Force AI system update when speed changes - if (speed > 0) - { - try - { - // Force villager system refresh to ensure they continue working - if (VillagerSystem.inst != null) - { - // Use reflection to call any refresh methods on VillagerSystem - var villagerSystemType = typeof(VillagerSystem); - var refreshMethods = villagerSystemType.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) - .Where(m => m.Name.Contains("Refresh") || m.Name.Contains("Update") || m.Name.Contains("Restart")); - - foreach (var method in refreshMethods) - { - if (method.GetParameters().Length == 0) - { - try - { - method.Invoke(VillagerSystem.inst, null); - Main.helper.Log($"Called VillagerSystem.{method.Name} for speed change"); - } - catch { } - } - } - } - Main.helper.Log($"AI systems refreshed for speed change to {speed}"); - } - catch (Exception e) - { - Main.helper.Log("Error refreshing AI on speed change: " + e.Message); - } - } } catch (Exception e) {