修复连锁Slide的读取逻辑(刹那旅程爆机bug)

pull/55/head
Minepig 2024-10-04 13:41:48 +08:00
parent bae5a7c838
commit c173b2a230
1 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,64 @@
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using Manager;
using MelonLoader;
using Monitor;
namespace AquaMai.Fix;
public class FixConnSlide
{
/* Patch bug:
* ConnSlide ConnSlide (Fes bug)
* method :
*
* if (this.IsSlideAll(noteData1.type) && (index1 + 1 < this._note._noteData.Count ? 1 : 0) != 0)
* {
* int targetNote = noteData1.slideData.targetNote;
* if (noteData1.slideData != null)
* targetNote = noteData1.slideData.targetNote;
* for (int index3 = index1; index3 < this._note._noteData.Count; ++index3)
* {
* NoteData noteData3 = this._note._noteData[index3];
* if (this.IsSlideAll(noteData3.type) && noteData3.time == noteData1.end && noteData3.startButtonPos == targetNote && noteData3.parent == null)
* {
* noteData3.parent = noteData1.parent;
* noteData1.child.Add(noteData3);
* noteData3.isUsed = true;
* noteData3.isJudged = true;
* break;
* }
* }
* }
*
* bug this.IsSlideAll() this.IsConnectNote(), 使 Transpiler
*/
[HarmonyTranspiler]
[HarmonyPatch(typeof(NotesReader), "calcSlide")]
private static IEnumerable<CodeInstruction> Fix(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> instList = new List<CodeInstruction>(instructions);
bool found = false;
MethodInfo methodIsSlideAll = AccessTools.Method(typeof(NotesReader), "IsSlideAll");
MethodInfo methodIsConnectNote = AccessTools.Method(typeof(NotesReader), "IsConnectNote");
for (int i = 0; i < instList.Count; i++)
{
CodeInstruction inst = instList[i];
if (!found && inst.Calls(methodIsSlideAll))
{
found = true;
continue;
}
if (found && inst.Calls(methodIsSlideAll))
{
inst.operand = methodIsConnectNote;
// MelonLogger.Msg($"[FixConnSlide] Successfully patched NotesReader::calcSlide");
break;
}
}
return instList;
}
}