Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for game version 0.10.30.22292 #681

Merged
merged 9 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/thunderstore_bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function generateManifest() {
const manifest = {
name: pluginInfo.name,
description:
"With this mod you will be able to play with your friends in the same game! Now supports combat mode in game version 0.10.29",
"With this mod you will be able to play with your friends in the same game! Now supports combat mode in game version 0.10.30",
version_number: pluginInfo.version,
dependencies: [
BEPINEX_DEPENDENCY,
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Changelog

0.9.4:
- Compatible with Steam or Game Pass version 0.10.30.22292
- @PhantomGamers: Prevent errors with Ngrok from crashing the game
- @PhantomGamers: Added error descriptions to Ngrok errors
- @starfi5h: Sync interstellar routes
- @starfi5h: Sync tilted conveyor belts

0.9.3:
- @starfi5h: Change chat message format. Player's name now has an underlined link to navigate
- @starfi5h: Add new config option Chat - Show Timestamp to enable/disable timestamp before the chat message
Expand All @@ -10,7 +17,7 @@
- @starfi5h: Fix enemies and ILS related errors

0.9.2:
- Compatible to Steam version 0.10.29.22015 or Game Pass version 0.10.29.21943
- Compatible with Steam version 0.10.29.22015 or Game Pass version 0.10.29.21943
- @sk7725: Added Korean font and TextMeshPro fallback
- @starfi5h: Add new chat command `/playerdata`
- @starfi5h: Launch construction drones if local player is closer or within 15m
Expand Down
2 changes: 2 additions & 0 deletions NebulaModel/Packets/Factory/CreatePrebuildsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static void DeserializeBuildPreview(BuildPreview buildPreview, IReadOnlyL
buildPreview.lpos2 = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
buildPreview.lrot = new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
buildPreview.lrot2 = new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
buildPreview.tilt = br.ReadSingle();
buildPreview.condition = (EBuildCondition)br.ReadInt32();
}

Expand Down Expand Up @@ -184,6 +185,7 @@ public static void SerializeBuildPreview(BuildPreview buildPreview, IList<BuildP
bw.Write(buildPreview.lrot2.y);
bw.Write(buildPreview.lrot2.z);
bw.Write(buildPreview.lrot2.w);
bw.Write(buildPreview.tilt);
bw.Write((int)buildPreview.condition);
}
}
22 changes: 10 additions & 12 deletions NebulaModel/Packets/Logistics/ILSIdleShipBackToWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ public class ILSIdleShipBackToWork
{
public ILSIdleShipBackToWork() { }

public ILSIdleShipBackToWork(ShipData ShipData, int thisGId, int stationMaxShipCount, int stationWarperCount)
public ILSIdleShipBackToWork(in ShipData shipData, int thisGId, int stationMaxShipCount, int stationWarperCount)
{
ThisGId = thisGId;
PlanetA = ShipData.planetA;
PlanetB = ShipData.planetB;
OtherGId = ShipData.otherGId;
ItemId = ShipData.itemId;
ItemCount = ShipData.itemCount;
Inc = ShipData.inc;
Gene = ShipData.gene;
ShipIndex = ShipData.shipIndex;
ShipWarperCount = ShipData.warperCnt;
PlanetA = shipData.planetA;
PlanetB = shipData.planetB;
OtherGId = shipData.otherGId;
ItemId = shipData.itemId;
ItemCount = shipData.itemCount;
Inc = shipData.inc;
ShipIndex = shipData.shipIndex;
ShipWarperCount = (byte)shipData.warperCnt;
StationMaxShipCount = stationMaxShipCount;
StationWarperCount = stationWarperCount;
}
Expand All @@ -27,9 +26,8 @@ public ILSIdleShipBackToWork(ShipData ShipData, int thisGId, int stationMaxShipC
public int ItemId { get; set; }
public int ItemCount { get; set; }
public int Inc { get; set; }
public int Gene { get; set; }
public int ShipIndex { get; set; }
public int ShipWarperCount { get; set; }
public byte ShipWarperCount { get; set; } // Max count for round-trip: 2
public int StationMaxShipCount { get; set; }
public int StationWarperCount { get; set; }
}
15 changes: 0 additions & 15 deletions NebulaModel/Packets/Logistics/ILSShipEnterWarp.cs

This file was deleted.

34 changes: 34 additions & 0 deletions NebulaModel/Packets/Logistics/ILSUpdateRoute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace NebulaModel.Packets.Logistics;

// Sync route update events in GalacticTransport
public class ILSUpdateRoute
{
public ILSUpdateRoute() { }

public ILSUpdateRoute(ERouteEvent type, int id0, int id1 = 0, int itemId = 0)
{
Type = type;
Id0 = id0;
Id1 = id1;
ItemId = itemId;
}

public ERouteEvent Type { get; set; }
public int Id0 { get; set; }
public int Id1 { get; set; }
public int ItemId { get; set; }
public bool Enable { get; set; }
public string Comment { get; set; }

public enum ERouteEvent
{
None = 0,
AddStation2StationRoute,
RemoveStation2StationRoute_Single,
RemoveStation2StationRoute_Pair,
AddAstro2AstroRoute,
RemoveAstro2AstroRoute,
SetAstro2AstroRouteEnable,
SetAstro2AstroRouteComment
}
}
2 changes: 1 addition & 1 deletion NebulaModel/Packets/Logistics/ILSWorkShipBackToIdle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class ILSWorkShipBackToIdle
{
public ILSWorkShipBackToIdle() { }

public ILSWorkShipBackToIdle(StationComponent stationComponent, ShipData shipData, int workShipIndex)
public ILSWorkShipBackToIdle(StationComponent stationComponent, in ShipData shipData, int workShipIndex)
{
GId = stationComponent.gid;
PlanetA = shipData.planetA;
Expand Down
18 changes: 5 additions & 13 deletions NebulaModel/Packets/Logistics/StationUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public enum EUISettings
PilerCount,
MaxMiningSpeed,
DroneAutoReplenish,
ShipAutoReplenish
ShipAutoReplenish,
RemoteGroupMask,
RoutePriority
}

public StationUI() { }

public StationUI(int planetId, int stationId, int stationGId, EUISettings settingIndex, float value,
public StationUI(int planetId, int stationId, int stationGId, EUISettings settingIndex, double value,
bool warperShouldTakeFromStorage = false)
{
PlanetId = planetId;
Expand All @@ -35,21 +37,11 @@ public StationUI(int planetId, int stationId, int stationGId, EUISettings settin
WarperShouldTakeFromStorage = warperShouldTakeFromStorage;
}

public StationUI(int planetId, int stationId, int stationGId, EUISettings settingIndex, string settingString)
{
PlanetId = planetId;
StationId = stationId;
StationGId = stationGId;
SettingIndex = settingIndex;
SettingString = settingString;
}

public int PlanetId { get; set; }
public int StationId { get; set; }
public int StationGId { get; set; }
public EUISettings SettingIndex { get; set; }
public float SettingValue { get; set; }
public string SettingString { get; set; }
public double SettingValue { get; set; }
public bool WarperShouldTakeFromStorage { get; set; }
public bool ShouldRefund { get; set; }
}
1 change: 1 addition & 0 deletions NebulaModel/Packets/Session/GlobalGameDataResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public GlobalGameDataResponse(EDataType dataType, byte[] binaryData)
public enum EDataType : byte
{
History = 1,
GalacticTransport,
SpaceSector,
MilestoneSystem,
TrashSystem,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#region

using NebulaAPI.Packets;
using NebulaModel.Logger;
using NebulaModel.Networking;
using NebulaModel.Packets;
using NebulaModel.Packets.Logistics;
using NebulaWorld;

#endregion

namespace NebulaNetwork.PacketProcessors.Logistics;

[RegisterPacketProcessor]
public class ILSUpdateRouteProcessor : PacketProcessor<ILSUpdateRoute>
{
protected override void ProcessPacket(ILSUpdateRoute packet, NebulaConnection conn)
{
Log.Debug($"{packet.Type} id0:{packet.Id0} id1:{packet.Id1}");
using (Multiplayer.Session.Ships.PatchLockILS.On())
{
var galacticTransport = GameMain.data.galacticTransport;
switch (packet.Type)
{
case ILSUpdateRoute.ERouteEvent.AddStation2StationRoute:
galacticTransport.AddStation2StationRoute(packet.Id0, packet.Id1);
break;

case ILSUpdateRoute.ERouteEvent.RemoveStation2StationRoute_Single:
galacticTransport.RemoveStation2StationRoute(packet.Id0);
break;

case ILSUpdateRoute.ERouteEvent.RemoveStation2StationRoute_Pair:
galacticTransport.RemoveStation2StationRoute(packet.Id0, packet.Id1);
break;

case ILSUpdateRoute.ERouteEvent.AddAstro2AstroRoute:
galacticTransport.AddAstro2AstroRoute(packet.Id0, packet.Id1, packet.ItemId);
break;

case ILSUpdateRoute.ERouteEvent.RemoveAstro2AstroRoute:
galacticTransport.RemoveAstro2AstroRoute(packet.Id0, packet.Id1, packet.ItemId);
break;

case ILSUpdateRoute.ERouteEvent.SetAstro2AstroRouteEnable:
galacticTransport.SetAstro2AstroRouteEnable(packet.Id0, packet.Id1, packet.ItemId, packet.Enable);
break;

case ILSUpdateRoute.ERouteEvent.SetAstro2AstroRouteComment:
galacticTransport.SetAstro2AstroRouteComment(packet.Id0, packet.Id1, packet.ItemId, packet.Comment);
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ protected override void ProcessPacket(ILSgStationPoolSync packet, NebulaConnecti
}

gTransport.Arragement();
gTransport.RefreshTraffic(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ protected override void ProcessPacket(GlobalGameDataRequest packet, NebulaConnec
GlobalGameDataResponse.EDataType.History, writer.CloseAndGetBytes()));
}

using (var writer = new BinaryUtils.Writer())
{
GameMain.data.galacticTransport.Export(writer.BinaryWriter);

conn.SendPacket(new GlobalGameDataResponse(
GlobalGameDataResponse.EDataType.GalacticTransport, writer.CloseAndGetBytes()));
}

using (var writer = new BinaryUtils.Writer())
{
// Note: Initial syncing from vanilla. May be refined later in future
Expand Down
80 changes: 80 additions & 0 deletions NebulaPatcher/Patches/Dynamic/GalacticTransport_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region

using System;
using HarmonyLib;
using NebulaModel.Packets.Logistics;
using NebulaWorld;
Expand Down Expand Up @@ -36,4 +37,83 @@ public static bool RemoveStationComponent_Prefix()
{
return !Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost || Multiplayer.Session.Ships.PatchLockILS;
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.GameTick))]
public static bool GameTick_Prefix()
{
return !Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost;
// Let host determine when ships will dispatch. Client will send out ships once receiving ILSIdleShipBackToWork packet
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.AddStation2StationRoute))]
public static void AddStation2StationRoute_Prefix(int gid0, int gid1)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

Multiplayer.Session.Network.SendPacket(new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.AddStation2StationRoute, gid0, gid1));
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.RemoveStation2StationRoute), new Type[] { typeof(int) })]
public static void RemoveStation2StationRoute_Single_Prefix(int gid)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

Multiplayer.Session.Network.SendPacket(new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.RemoveStation2StationRoute_Single, gid));
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.RemoveStation2StationRoute), new Type[] { typeof(int), typeof(int) })]
public static void RemoveStation2StationRoute_Pair_Prefix(int gid0, int gid1)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

Multiplayer.Session.Network.SendPacket(new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.RemoveStation2StationRoute_Pair, gid0, gid1));
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.AddAstro2AstroRoute))]
public static void AddAstro2AstroRoute_Prefix(int astroId0, int astroId1, int itemId)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

Multiplayer.Session.Network.SendPacket(new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.AddAstro2AstroRoute, astroId0, astroId1, itemId));
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.RemoveAstro2AstroRoute))]
public static void RemoveAstro2AstroRoute_Prefix(int astroId0, int astroId1, int itemId)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

Multiplayer.Session.Network.SendPacket(new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.RemoveAstro2AstroRoute, astroId0, astroId1, itemId));
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.SetAstro2AstroRouteEnable))]
public static void SetAstro2AstroRouteEnable_Prefix(int astroId0, int astroId1, int itemId, bool enable)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

var packet = new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.SetAstro2AstroRouteEnable, astroId0, astroId1, itemId)
{
Enable = enable
};
Multiplayer.Session.Network.SendPacket(packet);
}

[HarmonyPrefix]
[HarmonyPatch(nameof(GalacticTransport.SetAstro2AstroRouteComment))]
public static void SetAstro2AstroRouteComment_Prefix(int astroId0, int astroId1, int itemId, string comment)
{
if (!Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) return;

var packet = new ILSUpdateRoute(ILSUpdateRoute.ERouteEvent.SetAstro2AstroRouteComment, astroId0, astroId1, itemId)
{
Comment = comment
};
Multiplayer.Session.Network.SendPacket(packet);
}
}
Loading