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

fork update #42

Merged
merged 6 commits into from
Apr 24, 2021
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
1 change: 0 additions & 1 deletion NebulaClient/NebulaClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<Compile Include="PacketProcessors\Factory\Storage\StorageSyncResponseProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Storage\StorageSyncSetBansProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Storage\StorageSyncSortProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Entity\AddEntityPreviewRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Entity\BuildEntityRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Entity\DestructEntityRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Tank\TankInputOutputSwitchProcessor.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ public void ProcessPacket(BuildEntityRequest packet, NebulaConnection conn)
planet.audio.Init();
}

//Remove building from drone queue
GameMain.mainPlayer.mecha.droneLogic.serving.Remove(-packet.PrebuildId);
planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId);
if (!DroneManager.RemoveBuildRequest(-packet.PrebuildId))
{
Log.Warn($"Build Request was not succesfully removed.");
}
//Remove building from drone queue
GameMain.mainPlayer.mecha.droneLogic.serving.Remove(-packet.PrebuildId);
planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId);
DroneManager.RemoveBuildRequest(-packet.PrebuildId);

// Make sure to free the physics once the FlattenTerrain is done
if (packet.PlanetId != GameMain.localPlanet?.id)
Expand Down
1 change: 0 additions & 1 deletion NebulaHost/NebulaHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
<Compile Include="PacketProcessors\Factory\Storage\StorageSyncRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Storage\StorageSyncSetBansProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Storage\StorageSyncSortProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Entity\AddEntityPreviewRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Entity\BuildEntityRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Entity\DestructEntityRequestProcessor.cs" />
<Compile Include="PacketProcessors\Factory\Tank\TankInputOutputSwitchProcessor.cs" />
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion NebulaModel/NebulaModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<Compile Include="Packets\Factory\Assembler\AssemblerUpdateProducesPacket.cs" />
<Compile Include="Packets\Factory\Assembler\AssemblerUpdateStoragePacket.cs" />
<Compile Include="Networking\DisconnectionReason.cs" />
<Compile Include="Packets\Factory\AddEntityPreviewRequest.cs" />
<Compile Include="Packets\Factory\BuildEntityRequest.cs" />
<Compile Include="Packets\Factory\CreatePrebuildsRequest.cs" />
<Compile Include="Packets\Factory\DestructEntityRequest.cs" />
Expand Down
32 changes: 0 additions & 32 deletions NebulaModel/Packets/Factory/AddEntityPreviewRequest.cs

This file was deleted.

2 changes: 1 addition & 1 deletion NebulaPatcher/NebulaPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace NebulaPatcher
{
[BepInPlugin("com.github.hubertgendron.nebula", "Nebula - Multiplayer Mod", "0.0.1.0")]
[BepInPlugin("com.github.hubertgendron.nebula", "Nebula - Multiplayer Mod", "0.0.2.0")]
[BepInProcess("DSPGAME.exe")]
public class NebulaPlugin : BaseUnityPlugin
{
Expand Down
16 changes: 7 additions & 9 deletions NebulaPatcher/Patches/Dynamic/PlanetFactory_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ namespace NebulaPatcher.Patches.Dynamic
[HarmonyPatch(typeof(PlanetFactory))]
class BuildFinally_patch
{
[HarmonyPrefix]
[HarmonyPatch("AddPrebuildDataWithComponents")]
public static bool AddPrebuildDataWithComponents_Prefix(PlanetFactory __instance, PrebuildData prebuild)
[HarmonyPostfix]
[HarmonyPatch("AddPrebuildData")]
public static void AddPrebuildData_Postfix(PlanetFactory __instance, PrebuildData prebuild, ref int __result)
{
if (!SimulatedWorld.Initialized)
return true;
return;

// If the host game called the method, we need to compute the PrebuildId ourself
if (LocalPlayer.IsMasterClient && !FactoryManager.EventFromClient)
{
int nextPrebuildId = FactoryManager.GetNextPrebuildId(__instance);
FactoryManager.SetPrebuildRequest(__instance.planetId, nextPrebuildId, LocalPlayer.PlayerId);

FactoryManager.SetPrebuildRequest(__instance.planetId, __result, LocalPlayer.PlayerId);
}

return true;
}

[HarmonyPrefix]
Expand Down Expand Up @@ -56,7 +54,7 @@ public static bool BuildFinally_Prefix(PlanetFactory __instance, Player player,
LocalPlayer.SendPacket(new BuildEntityRequest(__instance.planetId, prebuildId, FactoryManager.PacketAuthor == -1 ? LocalPlayer.PlayerId : FactoryManager.PacketAuthor));
}

if (!LocalPlayer.IsMasterClient && !FactoryManager.EventFromServer)
if (!LocalPlayer.IsMasterClient && !FactoryManager.EventFromServer && !DroneManager.IsPendingBuildRequest(-prebuildId))
{
DroneManager.AddBuildRequestSent(-prebuildId);
}
Expand Down
2 changes: 1 addition & 1 deletion NebulaWorld/Factory/FactoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static int GetNextPrebuildId(PlanetFactory factory)

int prebuildRecycleCursor = GetPrebuildRecycleCursor(factory);
int[] prebuildRecycle = GetPrebuildRecycle(factory);
return prebuildRecycleCursor <= 0 ? factory.prebuildCursor : prebuildRecycle[prebuildRecycleCursor - 1];
return prebuildRecycleCursor <= 0 ? factory.prebuildCursor+1 : prebuildRecycle[prebuildRecycleCursor - 1];
}
}

Expand Down
8 changes: 8 additions & 0 deletions NebulaWorld/Player/DroneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ public static class DroneManager
public static List<int> PendingBuildRequests = new List<int>();
public static Dictionary<ushort, Vector3> CachedPositions = new Dictionary<ushort, Vector3>();

public static void Initialize()
{
DronePriorities = new int[255];
PlayerDroneBuildingPlans = new Dictionary<ushort, List<int>>();
PendingBuildRequests = new List<int>();
CachedPositions = new Dictionary<ushort, Vector3>();
}

public static void BroadcastDroneOrder(int droneId, int entityId, int stage)
{
if (!SimulatedWorld.Initialized)
Expand Down
2 changes: 2 additions & 0 deletions NebulaWorld/SimulatedWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using NebulaWorld.Player;

namespace NebulaWorld
{
Expand All @@ -37,6 +38,7 @@ public static Locker GetRemotePlayersModels(out Dictionary<ushort, RemotePlayerM

public static void Initialize()
{
DroneManager.Initialize();
FactoryManager.Initialize();
PlanetManager.Initialize();
Initialized = true;
Expand Down