Skip to content

Commit

Permalink
Fix an issue with Brio's IPC causing a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Minmoose committed Jan 12, 2025
1 parent 7747f3c commit 5220fa5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Brio/Capabilities/Actor/ActionTimelineCapability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ public unsafe void ApplyBaseOverride(ushort actionTimeline, bool interrupt)

public async void StopSpeedAndResetTimeline(Action? postStopAction = null, bool resetSpeedAfterAction = false)
{
Brio.Log.Fatal($"StopSpeedAndResetTimeline {postStopAction is not null} {resetSpeedAfterAction}");
Brio.Log.Verbose($"StopSpeedAndResetTimeline {postStopAction is not null} {resetSpeedAfterAction}");

var oldSpeed = SpeedMultiplier;

SetOverallSpeedOverride(0);

Brio.Log.Fatal($"SetOverallSpeedOverride {oldSpeed} {SpeedMultiplier}");
Brio.Log.Verbose($"SetOverallSpeedOverride {oldSpeed} {SpeedMultiplier}");

await _framework.RunOnTick(() =>
{
Expand Down Expand Up @@ -168,23 +168,23 @@ await _framework.RunOnTick(() =>
}
catch(Exception ex)
{
Brio.Log.Fatal(ex, "StopSpeedAndResetTimeline");
Brio.Log.Verbose(ex, "StopSpeedAndResetTimeline");
}
}, delayTicks: 4);

postStopAction?.Invoke();

Brio.Log.Fatal($"postStopAction Invoke: {postStopAction is not null}");
Brio.Log.Verbose($"postStopAction Invoke: {postStopAction is not null}");

if(resetSpeedAfterAction)
{
await _framework.RunOnTick(() =>
{
Brio.Log.Fatal($"SetOverallSpeedOverride 0 {SpeedMultiplier}");
Brio.Log.Verbose($"SetOverallSpeedOverride 0 {SpeedMultiplier}");

SetOverallSpeedOverride(oldSpeed);

Brio.Log.Fatal($"SetOverallSpeedOverride 1 {SpeedMultiplier}");
Brio.Log.Verbose($"SetOverallSpeedOverride 1 {SpeedMultiplier}");
}, delayTicks: 2);
}
}
Expand Down
22 changes: 17 additions & 5 deletions Brio/Game/Posing/PhysicsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,33 @@ public bool FreezeRevert()
}
catch(Exception ex)
{
Brio.Log.Fatal($"Brio encountered Fatal Error, FreezeRevert faild: {ex}");
Brio.Log.Fatal($"Brio encountered Fatal Error, FreezeRevert failed: {ex}");
}

return IsFreezeEnabled;
}

public bool FreezeEnable()
{
using Process currentProcess = Process.GetCurrentProcess();
if(IsFreezeEnabled)
return IsFreezeEnabled;

try
{
using Process currentProcess = Process.GetCurrentProcess();

WriteProcessMemory(currentProcess.Handle, freezeSkeletonPhysics1, nopFreezeBytes1, nopFreezeBytes1.Length, out _);
WriteProcessMemory(currentProcess.Handle, freezeSkeletonPhysics1, nopFreezeBytes1, nopFreezeBytes1.Length, out _);

WriteProcessMemory(currentProcess.Handle, freezeSkeletonPhysics2, nopFreezeBytes2, nopFreezeBytes2.Length, out _);
WriteProcessMemory(currentProcess.Handle, freezeSkeletonPhysics2, nopFreezeBytes2, nopFreezeBytes2.Length, out _);

return IsFreezeEnabled = true;
IsFreezeEnabled = true;
}
catch(Exception ex)
{
Brio.Log.Fatal($"Brio encountered Fatal Error, FreezeRevert failed: {ex}");
}

return IsFreezeEnabled;
}

public void Dispose()
Expand Down
17 changes: 11 additions & 6 deletions Brio/IPC/BrioIPCService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Brio.IPC;
internal class BrioIPCService : IDisposable
{
public static readonly (int, int) CurrentApiVersion = (2, 0);
public static readonly (int, int) CurrentApiVersion = (2, 1);

public bool IsIPCEnabled { get; private set; } = false;

Expand Down Expand Up @@ -523,18 +523,18 @@ private unsafe float GetActorSpeed_Impl(IGameObject actor)
private unsafe bool FreezActor_Impl(IGameObject actor)
{
if(_gPoseService.IsGPosing == false) return false;
Brio.Log.Fatal($"FreezActor_Impl 0");
Brio.Log.Verbose($"FreezActor_Impl 0");

if(_entityManager.TryGetEntity(actor.Native(), out var entity))
{
Brio.Log.Fatal($"FreezActor_Impl 1");
Brio.Log.Verbose($"FreezActor_Impl 1");

if(entity.TryGetCapability<ActionTimelineCapability>(out var actionTimeline))
{
Brio.Log.Fatal($"FreezActor_Impl 2");
Brio.Log.Verbose($"FreezActor_Impl 2");

actionTimeline.StopSpeedAndResetTimeline();
Brio.Log.Fatal($"FreezActor_Impl 3");
Brio.Log.Verbose($"FreezActor_Impl 3");
return true;
}
}
Expand All @@ -558,10 +558,15 @@ private unsafe bool UnFreezActor_Impl(IGameObject actor)
}

public bool FreezePhysics_Impl()
{
Task.Run(() => { FreezePhysics(); });
return true;
}
public bool FreezePhysics()
{
if(_gPoseService.IsGPosing == false) return false;

Brio.Log.Fatal($"FreezeEnable 0");
Brio.Log.Verbose($"FreezeEnable 0");

return _physicsService.FreezeEnable();
}
Expand Down
4 changes: 4 additions & 0 deletions Brio/Resources/Embedded/Data/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ To open this window again click `Information` on the Scene Manager then -> `View
---> Brio, Version 0.4.4 <---
--------------------------------------------------------------------------------

---------- 0.4.4.3 ----------

- Fixed an issue with Brio's IPC causing a crash

---------- 0.4.4.1 ----------

- Fixed an issue with Ears when importing as Body or Expression
Expand Down

0 comments on commit 5220fa5

Please sign in to comment.