-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #660 from starfi5h/pr-fix
Fix various bugs
- Loading branch information
Showing
18 changed files
with
245 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
NebulaModel/Packets/Factory/Belt/BeltReverseRequestPacket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace NebulaModel.Packets.Factory.Belt; | ||
|
||
public class BeltReverseRequestPacket | ||
{ | ||
public BeltReverseRequestPacket() { } | ||
|
||
public BeltReverseRequestPacket(int beltId, int planetId, int authorId) | ||
{ | ||
BeltId = beltId; | ||
PlanetId = planetId; | ||
AuthorId = authorId; | ||
} | ||
Check warning on line 12 in NebulaModel/Packets/Factory/Belt/BeltReverseRequestPacket.cs GitHub Actions / build (Debug)
Check warning on line 12 in NebulaModel/Packets/Factory/Belt/BeltReverseRequestPacket.cs GitHub Actions / build (Debug)
Check warning on line 12 in NebulaModel/Packets/Factory/Belt/BeltReverseRequestPacket.cs GitHub Actions / build (Release)
|
||
|
||
public int BeltId { get; set; } | ||
public int PlanetId { get; set; } | ||
public int AuthorId { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 31 additions & 11 deletions
42
NebulaNetwork/PacketProcessors/Factory/Belt/BeltReverseProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,67 @@ | ||
#region | ||
|
||
using System; | ||
using NebulaAPI; | ||
using NebulaAPI.Networking; | ||
using NebulaAPI.Packets; | ||
using NebulaModel.Logger; | ||
using NebulaModel.Packets.Factory.Belt; | ||
using NebulaWorld; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Factory.Belt; | ||
|
||
[RegisterPacketProcessor] | ||
internal class BeltReverseProcessor : BasePacketProcessor<BeltReversePacket> | ||
internal class BeltReverseProcessor : BasePacketProcessor<BeltReverseRequestPacket> | ||
{ | ||
public override void ProcessPacket(BeltReversePacket packet, INebulaConnection conn) | ||
public override void ProcessPacket(BeltReverseRequestPacket packet, INebulaConnection conn) | ||
{ | ||
var factory = GameMain.galaxy.PlanetById(packet.PlanetId).factory; | ||
if (factory == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (IsHost) | ||
{ | ||
var starId = packet.PlanetId / 100; | ||
Multiplayer.Session.Server.SendPacketToStar(packet, starId); | ||
} | ||
|
||
using (NebulaModAPI.MultiplayerSession.Factories.IsIncomingRequest.On()) | ||
{ | ||
NebulaModAPI.MultiplayerSession.Factories.EventFactory = factory; | ||
NebulaModAPI.MultiplayerSession.Factories.TargetPlanet = packet.PlanetId; | ||
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost) | ||
NebulaModAPI.MultiplayerSession.Factories.PacketAuthor = packet.AuthorId; | ||
if (IsHost) | ||
{ | ||
// Load planet model | ||
NebulaModAPI.MultiplayerSession.Factories.AddPlanetTimer(packet.PlanetId); | ||
} | ||
|
||
var beltWindow = UIRoot.instance.uiGame.beltWindow; | ||
beltWindow._Close(); // close the window first to avoid changing unwant variable when setting beltId | ||
var tmpFactory = beltWindow.factory; | ||
var tmpBeltId = beltWindow.beltId; | ||
beltWindow.factory = factory; | ||
beltWindow.beltId = packet.BeltId; | ||
beltWindow.OnReverseButtonClick(0); | ||
beltWindow.factory = tmpFactory; | ||
beltWindow.beltId = tmpBeltId; | ||
try | ||
{ | ||
beltWindow._Close(); // close the window first to avoid changing unwant variable when setting beltId | ||
beltWindow.factory = factory; | ||
beltWindow.traffic = factory.cargoTraffic; | ||
beltWindow.player = GameMain.mainPlayer; | ||
beltWindow.beltId = packet.BeltId; | ||
beltWindow.OnReverseButtonClick(0); | ||
beltWindow._Close(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Log.Warn(e); | ||
beltWindow._tmp_ids.Clear(); | ||
beltWindow._tmp_cargos.Clear(); | ||
beltWindow._Close(); | ||
} | ||
|
||
NebulaModAPI.MultiplayerSession.Factories.EventFactory = null; | ||
NebulaModAPI.MultiplayerSession.Factories.TargetPlanet = NebulaModAPI.PLANET_NONE; | ||
NebulaModAPI.MultiplayerSession.Factories.PacketAuthor = NebulaModAPI.AUTHOR_NONE; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
NebulaPatcher/Patches/Dynamic/CombatModuleComponent_Patch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#region | ||
|
||
using System; | ||
using HarmonyLib; | ||
using NebulaModel.Logger; | ||
|
||
#endregion | ||
|
||
namespace NebulaPatcher.Patches.Dynamic; | ||
|
||
[HarmonyPatch(typeof(CombatModuleComponent))] | ||
internal class CombatModuleComponent_Patch | ||
{ | ||
static int s_errorCount = 0; | ||
|
||
[HarmonyFinalizer] | ||
[HarmonyPatch(typeof(CombatModuleComponent), nameof(CombatModuleComponent.GameTick))] | ||
public static Exception GameTick_Finalizer(Exception __exception) | ||
{ | ||
if (__exception != null) | ||
{ | ||
// After 10 exception triggered, suppress the following messages | ||
if (s_errorCount++ < 10) | ||
{ | ||
var msg = "GameTick_Finalizer suppressed exception: \n" + __exception.ToString(); | ||
Log.Error(msg); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#region | ||
|
||
using HarmonyLib; | ||
using NebulaWorld; | ||
|
||
#endregion | ||
|
||
namespace NebulaPatcher.Patches.Dynamic; | ||
|
||
[HarmonyPatch(typeof(PropertyLogic))] | ||
internal class PropertyLogic_Patch | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(PropertyLogic.GameTick))] | ||
public static bool PrepareTick_Prefix() | ||
{ | ||
if (!Multiplayer.IsActive) return true; | ||
|
||
// Disable UpdateProduction in client to prevent errror | ||
return Multiplayer.Session.IsServer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.