Skip to content

Commit

Permalink
Merge pull request NebulaModTeam#570 from hubastard/dsp-0.9.26
Browse files Browse the repository at this point in the history
fix compatibility with dsp 0.9.26.12891
  • Loading branch information
starfi5h authored Jun 13, 2022
2 parents 1759cd8 + dab6ed6 commit a006e85
Show file tree
Hide file tree
Showing 53 changed files with 895 additions and 80 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Changelog

0.8.9:

- @PhantomGamers: Fixed compilation with 0.9.26
- @starfi5h: Added syncing of all of the new Sandbox features introduced in 0.9.26
- @starfi5h: Fixed bug that caused the host to sink into the ground
- @starfi5h: Increased connection timeout to prevent issues with higher latency connections

0.8.8:

- @starfi5h: Added RemoteAccessPassword setting for servers so that users can authenticate to use admin commands
Expand Down
27 changes: 27 additions & 0 deletions NebulaModel/Packets/Factory/EntityBoostSwitchPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace NebulaModel.Packets.Factory
{
public class EntityBoostSwitchPacket
{
public int PlanetId { get; set; }
public EBoostEntityType EntityType { get; set; }
public int Id { get; set; }
public bool Enable { get; set; }

public EntityBoostSwitchPacket() { }

public EntityBoostSwitchPacket(int planetId, EBoostEntityType entityType, int id, bool enable)
{
PlanetId = planetId;
EntityType = entityType;
Id = id;
Enable = enable;
}
}

public enum EBoostEntityType
{
ArtificialStar,
Ejector,
Silo
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NebulaAPI;
using UnityEngine;

namespace NebulaModel.Packets.Factory
namespace NebulaModel.Packets.Factory.Foundation
{
public class FoundationBuildUpdatePacket
{
Expand Down
21 changes: 21 additions & 0 deletions NebulaModel/Packets/Factory/Foundation/PlanetReformPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace NebulaModel.Packets.Factory.Foundation
{
public class PlanetReformPacket
{
public int PlanetId { get; set; }
public bool IsReform { get; set; } // true = reform all, false = revert
public int Type { get; set; }
public int Color { get; set; }
public bool Bury { get; set; }

public PlanetReformPacket() { }
public PlanetReformPacket(int planetId, bool isReform, int type = 0, int color = 0, bool bury = false)
{
PlanetId = planetId;
IsReform = isReform;
Type = type;
Color = color;
Bury = bury;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum MonitorSettingEvent
SetCargoFilter = 6,
SetTargetCargoBytes = 7,
SetPeriodTickCount = 8,
SetTargetBelt = 9
SetTargetBelt = 9,
SetSpawnOperator = 10
}
}
15 changes: 15 additions & 0 deletions NebulaModel/Packets/GameHistory/GameHistoryFeatureKeyPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace NebulaModel.Packets.GameHistory
{
public class GameHistoryFeatureKeyPacket
{
public int FeatureId { get; set; }
public bool Add { get; set; }

public GameHistoryFeatureKeyPacket() { }
public GameHistoryFeatureKeyPacket(int featureId, bool add)
{
FeatureId = featureId;
Add = add;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public GameHistoryNotificationPacket(GameHistoryEvent Event)
public enum GameHistoryEvent
{
PauseQueue = 1,
ResumeQueue = 2
ResumeQueue = 2,
OneKeyUnlock = 3
}
}
11 changes: 11 additions & 0 deletions NebulaModel/Packets/Logistics/StorageUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class StorageUI
public int ItemCount { get; set; }
public int ItemInc { get; set; }
public bool ShouldRefund { get; set; }
public byte KeepMode { get; set; }

public StorageUI() { }
public StorageUI(int planetId, int stationId, int stationGId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic)
Expand All @@ -39,5 +40,15 @@ public StorageUI(int planetId, int stationId, int stationGId, int storageIdx, in
ItemCount = itemCount;
ItemInc = itemInc;
}
public StorageUI(int planetId, int stationId, int stationGId, int storageIdx, byte keepMode)
{
ItemCount = -2; //Indicate it is other settings update

PlanetId = planetId;
StationId = stationId;
StationGId = stationGId;
StorageIdx = storageIdx;
KeepMode = keepMode;
}
}
}
17 changes: 17 additions & 0 deletions NebulaModel/Packets/Planet/VegeAddPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace NebulaModel.Packets.Planet
{
public class VegeAddPacket
{
public int PlanetId { get; set; }
public bool IsVein { get; set; }
public byte[] Data { get; set; }

public VegeAddPacket() { }
public VegeAddPacket(int planetId, bool isVein, byte[] data)
{
PlanetId = planetId;
IsVein = isVein;
Data = data;
}
}
}
16 changes: 9 additions & 7 deletions NebulaModel/Packets/Session/HandshakeResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ namespace NebulaModel.Packets.Session
{
public class HandshakeResponse
{
public int AlgoVersion { get; set; }
public int GalaxyAlgo { get; set; }
public int GalaxySeed { get; set; }
public int StarCount { get; set; }
public float ResourceMultiplier { get; set; }
public bool IsSandboxMode { get; set; }
public int[] SavedThemeIds { get; set; }
public bool IsNewPlayer { get; set; }
public PlayerData LocalPlayerData { get; set; }
Expand All @@ -19,13 +20,14 @@ public class HandshakeResponse

public HandshakeResponse() { }

public HandshakeResponse(int algoVersion, int galaxySeed, int starCount, float resourceMultiplier, int[] savedThemeIds, bool isNewPlayer, PlayerData localPlayerData, byte[] modsSettings, int settingsCount, bool syncSoil, ushort numPlayers, string discordPartyId)
public HandshakeResponse(in GameDesc gameDesc, bool isNewPlayer, PlayerData localPlayerData, byte[] modsSettings, int settingsCount, bool syncSoil, ushort numPlayers, string discordPartyId)
{
AlgoVersion = algoVersion;
GalaxySeed = galaxySeed;
StarCount = starCount;
ResourceMultiplier = resourceMultiplier;
SavedThemeIds = savedThemeIds;
GalaxyAlgo = gameDesc.galaxyAlgo;
GalaxySeed = gameDesc.galaxySeed;
StarCount = gameDesc.starCount;
ResourceMultiplier = gameDesc.resourceMultiplier;
IsSandboxMode = gameDesc.isSandboxMode;
SavedThemeIds = gameDesc.savedThemeIds;
IsNewPlayer = isNewPlayer;
LocalPlayerData = localPlayerData;
ModsSettings = modsSettings;
Expand Down
14 changes: 8 additions & 6 deletions NebulaModel/Packets/Session/LobbyResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ public class LobbyResponse
public int GalaxySeed { get; set; }
public int StarCount { get; set; }
public float ResourceMultiplier { get; set; }
public bool IsSandboxMode { get; set; }
public int[] SavedThemeIds { get; set; }
public byte[] ModsSettings { get; set; }
public int ModsSettingsCount { get; set; }
public ushort NumPlayers { get; set; }
public string DiscordPartyId { get; set; }

public LobbyResponse() { }
public LobbyResponse(int galaxyAlgo, int galaxySeed, int starCount, float resourceMultiplier, int[] savedThemeIds, byte[] modsSettings, int settingsCount, ushort numPlayers, string discordPartyId)
public LobbyResponse(in GameDesc gameDesc, byte[] modsSettings, int settingsCount, ushort numPlayers, string discordPartyId)
{
GalaxyAlgo = galaxyAlgo;
GalaxySeed = galaxySeed;
StarCount = starCount;
ResourceMultiplier = resourceMultiplier;
SavedThemeIds = savedThemeIds;
GalaxyAlgo = gameDesc.galaxyAlgo;
GalaxySeed = gameDesc.galaxySeed;
StarCount = gameDesc.starCount;
ResourceMultiplier = gameDesc.resourceMultiplier;
IsSandboxMode = gameDesc.isSandboxMode;
SavedThemeIds = gameDesc.savedThemeIds;
ModsSettings = modsSettings;
ModsSettingsCount = settingsCount;
NumPlayers = numPlayers;
Expand Down
5 changes: 4 additions & 1 deletion NebulaModel/Packets/Session/LobbyUpdateValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ public class LobbyUpdateValues
public int GalaxySeed { get; set; }
public int StarCount { get; set; }
public float ResourceMultiplier { get; set; }
public bool IsSandboxMode { get; set; }

public LobbyUpdateValues() { }
public LobbyUpdateValues(int galaxyAlgo, int galaxySeed, int starCount, float resourceMultiplier)
public LobbyUpdateValues(int galaxyAlgo, int galaxySeed, int starCount, float resourceMultiplier, bool isSandboxMode)
{
GalaxyAlgo = galaxyAlgo;
GalaxySeed = galaxySeed;
StarCount = starCount;
ResourceMultiplier = resourceMultiplier;
IsSandboxMode = isSandboxMode;
}
}
}
35 changes: 35 additions & 0 deletions NebulaModel/Packets/Universe/DysonSailDataPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma warning disable IDE1006
namespace NebulaModel.Packets.Universe
{
public class DysonSailDataPacket
{
public int StarIndex { get; set; }
public int OrbitId { get; set; }
public long ExpiryTime { get; set; }
public float st { get; set; }
public float px { get; set; }
public float py { get; set; }
public float pz { get; set; }
public float vx { get; set; }
public float vy { get; set; }
public float vz { get; set; }
public float gs { get; set; }

public DysonSailDataPacket() { }
public DysonSailDataPacket(int starIndex, ref DysonSail sail, int orbitId, long expiryTime)
{
StarIndex = starIndex;
OrbitId = orbitId;
ExpiryTime = expiryTime;
st = sail.st;
px = sail.px;
py = sail.py;
pz = sail.pz;
vx = sail.vx;
vy = sail.vy;
vz = sail.vz;
gs = sail.gs;
}
}
}
#pragma warning restore IDE1006
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum SwarmRemoveOrbitEvent
{
Remove,
Disable,
Enable
Enable,
RemoveSails
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using NebulaAPI;
using NebulaModel.Networking;
using NebulaModel.Packets;
using NebulaModel.Packets.Factory;

namespace NebulaNetwork.PacketProcessors.Factory.Entity
{
[RegisterPacketProcessor]
class EntityBoostSwitchProcessor : PacketProcessor<EntityBoostSwitchPacket>
{
public override void ProcessPacket(EntityBoostSwitchPacket packet, NebulaConnection conn)
{
PlanetFactory factory = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;
if (factory == null)
{
return;
}

switch (packet.EntityType)
{
case EBoostEntityType.ArtificialStar:
if (packet.Id < factory.powerSystem.genCursor)
{
factory.powerSystem.genPool[packet.Id].SetBoost(packet.Enable);
if (UIRoot.instance.uiGame.generatorWindow.generatorId == packet.Id)
{
UIRoot.instance.uiGame.generatorWindow.boostSwitch.SetImmediately(packet.Enable);
}
}
break;

case EBoostEntityType.Ejector:
if (packet.Id < factory.factorySystem.ejectorCursor)
{
factory.factorySystem.ejectorPool[packet.Id].SetBoost(packet.Enable);
if (UIRoot.instance.uiGame.ejectorWindow.ejectorId == packet.Id)
{
UIRoot.instance.uiGame.ejectorWindow.boostSwitch.SetImmediately(packet.Enable);
}
}
break;

case EBoostEntityType.Silo:
if (packet.Id < factory.factorySystem.siloCursor)
{
factory.factorySystem.siloPool[packet.Id].SetBoost(packet.Enable);
if (UIRoot.instance.uiGame.siloWindow.siloId == packet.Id)
{
UIRoot.instance.uiGame.siloWindow.boostSwitch.SetImmediately(packet.Enable);
}
}
break;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NebulaAPI;
using NebulaModel.Networking;
using NebulaModel.Packets;
using NebulaModel.Packets.Factory;
using NebulaModel.Packets.Factory.Foundation;
using NebulaWorld;
using System;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using NebulaAPI;
using NebulaModel.Networking;
using NebulaModel.Packets;
using NebulaModel.Packets.Factory.Foundation;
using NebulaWorld;

namespace NebulaNetwork.PacketProcessors.Factory.Foundation
{
[RegisterPacketProcessor]
internal class PlanetReformProcessor : PacketProcessor<PlanetReformPacket>
{
public override void ProcessPacket(PlanetReformPacket packet, NebulaConnection conn)
{
using (Multiplayer.Session.Planets.IsIncomingRequest.On())
{
PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);
if (planet?.factory == null)
{
return;
}
Multiplayer.Session.Factories.TargetPlanet = packet.PlanetId;
Multiplayer.Session.Factories.AddPlanetTimer(packet.PlanetId);
PlanetData pData = GameMain.gpuiManager.specifyPlanet;
GameMain.gpuiManager.specifyPlanet = planet;

if (packet.IsReform)
{
// Reform whole planet
planet.factory.PlanetReformAll(packet.Type, packet.Color, packet.Bury);
}
else
{
// Revert whole planet
planet.factory.PlanetReformRevert();
}

GameMain.gpuiManager.specifyPlanet = pData;
Multiplayer.Session.Factories.TargetPlanet = NebulaModAPI.PLANET_NONE;
}
}
}
}
Loading

0 comments on commit a006e85

Please sign in to comment.