Skip to content

Commit

Permalink
Patch for active bodies leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Equinox- committed Mar 7, 2024
1 parent 46300e2 commit d6001b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Meds.Wrapper/Shim/MecPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
using Havok;
using Medieval.Entities.Components;
using Medieval.Entities.Components.Crafting;
using Medieval.GameSystems;
using Medieval.World.Persistence;
using Meds.Wrapper.Utils;
using Microsoft.Extensions.Logging;
using Sandbox.Engine.Multiplayer;
using Sandbox.Engine.Physics;
using Sandbox.Game.Entities.Character;
using Sandbox.Game.Entities.Entity.Stats;
using Sandbox.Game.EntityComponents;
Expand Down Expand Up @@ -683,4 +685,19 @@ public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructio
return instructions;
}
}

// https://communityedition.medievalengineers.com/mantis/view.php?id=419a
[HarmonyPatch(typeof(MyPhysicsSandbox), nameof(MyPhysicsSandbox.CreateHkWorld))]
[AlwaysPatch(VersionRange = "[,0.7.4)")]
public static class MecUnidentifiedActiveRigidBodiesLeak
{
public static void Postfix(HkWorld __result)
{
__result.OnRigidBodyRemoved += body =>
{
if (body is HkRigidBody rb)
__result.ActiveRigidBodies.Remove(rb);
};
}
}
}
4 changes: 2 additions & 2 deletions Meds.Wrapper/Shim/MiscPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static bool CorrectSpawnPosition(float charSizeRad, ref MatrixD position
{
var okay = PositionPayload.TryCreate(originalLocation, out var positionPayload, player?.Identity?.Id);
Entrypoint.LoggerFor(typeof(MyMedievalPlanetRespawnComponent))
.ZLogInformationWithPayload(StackUtils.CaptureGameLogicStackPayload(),
.ZLogInformation(
"Failed to correct spawn location on call {0} while spawning {1} ({2}). Originally at {3} ({4}/{5}/{6})",
call,
player?.Id.SteamId,
Expand All @@ -43,7 +43,7 @@ private static bool CorrectSpawnPosition(float charSizeRad, ref MatrixD position
{
var okay = PositionPayload.TryCreate(originalLocation, out var positionPayload, player?.Identity?.Id);
Entrypoint.LoggerFor(typeof(MyMedievalPlanetRespawnComponent))
.ZLogInformationWithPayload(StackUtils.CaptureGameLogicStackPayload(),
.ZLogInformation(
"Corrected spawn location on call {0} while spawning {1} ({2}). Originally at {3} ({4}/{5}/{6}), moved {7}m",
call,
player?.Id.SteamId,
Expand Down

0 comments on commit d6001b0

Please sign in to comment.