Skip to content

Commit

Permalink
Merge pull request #694 from starfi5h/pr-bugfix0720
Browse files Browse the repository at this point in the history
Bugfix 2024-07-20
  • Loading branch information
starfi5h authored Jul 19, 2024
2 parents b184d9b + 8e0a517 commit e90591a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Expand Down
13 changes: 12 additions & 1 deletion NebulaPatcher/Patches/Dynamic/DFRelayComponent_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
14 changes: 13 additions & 1 deletion NebulaPatcher/Patches/Dynamic/SkillSystem_Common_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions NebulaWorld/Combat/EnemyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit e90591a

Please sign in to comment.