Skip to content

Commit de2e54a

Browse files
committed
Fix DuplicateSlot ProtoFlux node crashing game when if OverrideParent is identical to Template
Yellow-Dog-Man/Resonite-Issues#3950
1 parent a6d99ca commit de2e54a

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FrooxEngine;
2+
using HarmonyLib;
3+
using MonkeyLoader.Resonite;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Reflection.Emit;
7+
using System.Text;
8+
9+
namespace CommunityBugFixCollection
10+
{
11+
[HarmonyPatch(typeof(Slot), nameof(Slot.Duplicate))]
12+
[HarmonyPatchCategory(nameof(CheckSelfForDuplicateSlot))]
13+
internal sealed class CheckSelfForDuplicateSlot : ResoniteMonkey<CheckSelfForDuplicateSlot>
14+
{
15+
public override IEnumerable<string> Authors => Contributors.Banane9;
16+
17+
public override bool CanBeDisabled => true;
18+
19+
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
20+
{
21+
var isChildOfMethod = AccessTools.DeclaredMethod(typeof(Slot), nameof(Slot.IsChildOf));
22+
23+
foreach (var instruction in instructions)
24+
{
25+
if (instruction.Calls(isChildOfMethod))
26+
{
27+
yield return new CodeInstruction(OpCodes.Pop);
28+
yield return new CodeInstruction(OpCodes.Ldc_I4_1);
29+
}
30+
31+
yield return instruction;
32+
}
33+
}
34+
}
35+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ just disable them in the settings in the meantime.
3838
* UserInspectors not listing existing users in the session for non-host users (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1964)
3939
* Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480)
4040
* Direct cursor size becoming very large when snapped to an object much closer than the true cursor (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3654)
41+
* DuplicateSlot ProtoFlux node crashes game when if OverrideParent is identical to Template (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3950)
4142

4243

4344
## Workarounds

0 commit comments

Comments
 (0)