Skip to content

Commit

Permalink
fix for remote factory loading, games lacks a nullptr check.
Browse files Browse the repository at this point in the history
  • Loading branch information
sp00ktober committed Mar 13, 2021
1 parent 19e3c4e commit e9d2f3c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions NebulaPatcher/NebulaPatcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<Compile Include="Patches\Dynamic\GameLoader_Patch.cs" />
<Compile Include="Patches\Dynamic\DSPGame_Patch.cs" />
<Compile Include="Patches\Dynamic\PlanetModelingManager_Patch.cs" />
<Compile Include="Patches\Dynamic\UIPowerGizmo_OnUpdate_Patch.cs" />
<Compile Include="Patches\Transpilers\PlayerAction_Mine_Patch.cs" />
<Compile Include="Patches\Dynamic\UIEscMenu_Patch.cs" />
<Compile Include="Patches\Dynamic\UIMainMenu_Patch.cs" />
Expand Down
2 changes: 0 additions & 2 deletions NebulaPatcher/Patches/Dynamic/ArriveLeavePlanet_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using NebulaModel.Packets.Planet;
using NebulaWorld;

using UnityEngine;

namespace NebulaPatcher.Patches.Dynamic
{
[HarmonyPatch(typeof(GameData), "ArrivePlanet")]
Expand Down
26 changes: 26 additions & 0 deletions NebulaPatcher/Patches/Dynamic/UIPowerGizmo_OnUpdate_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using HarmonyLib;

/*
* This Patch is part of the remote factory loading process.
* As the client requests the factory the localPlanet is already set by the ArrivePlanet() method.
* As UIPowerGizmo::_OnUpdate() lacks a null check on the factory of the localPlanet we need to do that here
* because the factory data may not be received/loaded by this time.
*/
namespace NebulaPatcher.Patches.Dynamic
{
class UIPowerGizmo_OnUpdate_Patch
{
[HarmonyPatch(typeof(UIPowerGizmo), "_OnUpdate")]
class OnUpdatePatch
{
public static bool Prefix()
{
if(GameMain.localPlanet?.factory == null)
{
return false;
}
return true;
}
}
}
}

0 comments on commit e9d2f3c

Please sign in to comment.