From af1c4ad21c62a202fe9ea736a006c6e3effec74d Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:40:18 +0800 Subject: [PATCH 1/4] Remove packet size debug log in release build --- NebulaModel/Networking/Serialization/NebulaNetPacketProcessor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/NebulaModel/Networking/Serialization/NebulaNetPacketProcessor.cs b/NebulaModel/Networking/Serialization/NebulaNetPacketProcessor.cs index 017779066..b18cca92b 100644 --- a/NebulaModel/Networking/Serialization/NebulaNetPacketProcessor.cs +++ b/NebulaModel/Networking/Serialization/NebulaNetPacketProcessor.cs @@ -131,7 +131,6 @@ public void EnqueuePacketForProcessing(byte[] rawData, object userData) lock (pendingPackets) { pendingPackets.Enqueue(new PendingPacket(rawData, userData)); - Log.Debug($"Received packet of size: {rawData.Length}"); } } From 470e7054251035da5b65920eeee97d334446f72c Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:42:25 +0800 Subject: [PATCH 2/4] Clear block skill of enemy units after client load factory --- NebulaWorld/Combat/EnemyManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NebulaWorld/Combat/EnemyManager.cs b/NebulaWorld/Combat/EnemyManager.cs index d79d06a5d..89c1278da 100644 --- a/NebulaWorld/Combat/EnemyManager.cs +++ b/NebulaWorld/Combat/EnemyManager.cs @@ -126,6 +126,8 @@ public void OnFactoryLoadFinished(PlanetFactory factory) { var enemyId = unitBuffer[i].enemyId; targets[enemyId] = unitBuffer[i].hatred.max.target; + // clear the blocking skill to prevent error due to skills are not all present in client + unitBuffer[i].ClearBlockSkill(); } } From e38d69b8be0660dc9232c09eaebd43dc91f33972 Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Fri, 19 Jul 2024 20:19:30 +0800 Subject: [PATCH 3/4] Set DFRelayComponent.RelaySailLogic keyFrame = false in client --- .../DFRelay/DFRelayDirectionStateChangePacket.cs | 8 +------- .../DFRelay/DFRelayDirectionStateChangeProcessor.cs | 5 ++--- .../Patches/Dynamic/DFRelayComponent_Patch.cs | 13 ++++++++++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/NebulaModel/Packets/Combat/DFRelay/DFRelayDirectionStateChangePacket.cs b/NebulaModel/Packets/Combat/DFRelay/DFRelayDirectionStateChangePacket.cs index c22efbb91..1402fb982 100644 --- a/NebulaModel/Packets/Combat/DFRelay/DFRelayDirectionStateChangePacket.cs +++ b/NebulaModel/Packets/Combat/DFRelay/DFRelayDirectionStateChangePacket.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NebulaModel.Packets.Combat.DFRelay +namespace NebulaModel.Packets.Combat.DFRelay { public class DFRelayDirectionStateChangePacket { diff --git a/NebulaNetwork/PacketProcessors/Combat/DFRelay/DFRelayDirectionStateChangeProcessor.cs b/NebulaNetwork/PacketProcessors/Combat/DFRelay/DFRelayDirectionStateChangeProcessor.cs index dde994e3f..ae41586b1 100644 --- a/NebulaNetwork/PacketProcessors/Combat/DFRelay/DFRelayDirectionStateChangeProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Combat/DFRelay/DFRelayDirectionStateChangeProcessor.cs @@ -14,7 +14,7 @@ protected override void ProcessPacket(DFRelayDirectionStateChangePacket packet, { var hiveSystem = GameMain.spaceSector.GetHiveByAstroId(packet.HiveAstroId); if (hiveSystem == null) return; - + var dfRelayComponent = hiveSystem.relays.buffer[packet.RelayId]; if (dfRelayComponent?.id != packet.RelayId) return; @@ -27,11 +27,10 @@ protected override void ProcessPacket(DFRelayDirectionStateChangePacket packet, dfRelayComponent.baseState = 0; dfRelayComponent.baseId = 0; dfRelayComponent.baseTicks = 0; - dfRelayComponent.baseEvolve = default(EvolveData); + dfRelayComponent.baseEvolve = default; dfRelayComponent.baseRespawnCD = 0; dfRelayComponent.direction = -1; dfRelayComponent.param0 = 0f; - dfRelayComponent.stage = packet.Stage; Log.Debug($"Relay {dfRelayComponent.id} returning home"); diff --git a/NebulaPatcher/Patches/Dynamic/DFRelayComponent_Patch.cs b/NebulaPatcher/Patches/Dynamic/DFRelayComponent_Patch.cs index 4869092e6..0b88e7003 100644 --- a/NebulaPatcher/Patches/Dynamic/DFRelayComponent_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/DFRelayComponent_Patch.cs @@ -107,11 +107,22 @@ public static bool LogicTickBaseMaintain_Prefix(DFRelayComponent __instance) { if (!Multiplayer.IsActive || Multiplayer.Session.IsServer) return true; - if (__instance.baseState == 2 && __instance.hive.galaxy.astrosFactory[__instance.targetAstroId] == null) + if (__instance.baseState == DFRelayComponent.REALIZED_BASE && __instance.hive.galaxy.astrosFactory[__instance.targetAstroId] == null) { //the target factory is not loaded on client return false; } return true; } + + [HarmonyPrefix] + [HarmonyPatch(nameof(DFRelayComponent.RelaySailLogic))] + public static void RelaySailLogic_Prefix(ref bool keyFrame) + { + if (!Multiplayer.IsActive || Multiplayer.Session.IsServer) return; + + // Prevent clients from changing the direction or stage themselves + // The changing event is server autoreactive (DFRelayDirectionStateChangePacket) + keyFrame = false; + } } From 8e0a517a182b867c4ad0008771b8d4a42af9614a Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:23:15 +0800 Subject: [PATCH 4/4] Fix NRE in Bomb.TickSkillLogic for client --- .../Patches/Dynamic/SkillSystem_Common_Patch.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs b/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs index cc51d0f1e..e9d46421d 100644 --- a/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs @@ -11,8 +11,20 @@ namespace NebulaPatcher.Patches.Dynamic; internal class SkillSystem_Common_Patch { [HarmonyPrefix] - [HarmonyPatch(typeof(GeneralShieldBurst), nameof(GeneralShieldBurst.TickSkillLogic))] + [HarmonyPatch(typeof(Bomb_Explosive), nameof(Bomb_Explosive.TickSkillLogic))] + [HarmonyPatch(typeof(Bomb_Liquid), nameof(Bomb_Liquid.TickSkillLogic))] + [HarmonyPatch(typeof(Bomb_EMCapsule), nameof(Bomb_EMCapsule.TickSkillLogic))] + public static void Bomb_TickSkillLogic(ref int ___nearPlanetAstroId, ref int ___life) + { + if (___nearPlanetAstroId > 0 && GameMain.spaceSector.skillSystem.astroFactories[___nearPlanetAstroId] == null) + { + // The nearest planetFactory hasn't loaded yet, skip and remove + ___life = 0; + } + } + [HarmonyPrefix] + [HarmonyPatch(typeof(GeneralShieldBurst), nameof(GeneralShieldBurst.TickSkillLogic))] public static bool GeneralShieldBurst_Prefix(ref GeneralShieldBurst __instance, SkillSystem skillSystem) { if (!Multiplayer.IsActive || __instance.caster.type != ETargetType.Player) return true;