@@ -126,7 +126,7 @@ public static void Load()
126126
127127 IL . Celeste . FakeWall . Update += State_DreamDashNotEqual ;
128128 IL . Celeste . Spring . OnCollide += State_DreamDashEqual ;
129- IL . Celeste . Solid . Update += State_DreamDashNotEqual_And ;
129+ IL . Celeste . Solid . Update += State_DreamDashNotEqual ;
130130 }
131131
132132 public static void Unload ( )
@@ -159,7 +159,7 @@ public static void Unload()
159159
160160 IL . Celeste . FakeWall . Update -= State_DreamDashNotEqual ;
161161 IL . Celeste . Spring . OnCollide -= State_DreamDashEqual ;
162- IL . Celeste . Solid . Update -= State_DreamDashNotEqual_And ;
162+ IL . Celeste . Solid . Update -= State_DreamDashNotEqual ;
163163 }
164164
165165 public static void InitializeParticles ( )
@@ -365,22 +365,22 @@ private static void Player_IsRiding_JumpThru(ILContext il)
365365 if ( il . Instrs [ 0 ] . OpCode == OpCodes . Nop )
366366 State_DreamDashEqual ( il ) ;
367367 else
368- State_DreamDashNotEqual_And ( il ) ;
368+ State_DreamDashNotEqual ( il ) ;
369369 }
370370
371371 private static void Player_BeforeUpTransition ( ILContext il )
372372 {
373373 ILCursor cursor = new ( il ) ;
374374
375375 CheckState ( cursor , Player . StRedDash , false ) ;
376- CheckState ( cursor , Player . StRedDash , false , true ) ;
376+ CheckState ( cursor , Player . StRedDash , false ) ;
377377 }
378378
379379 private static void Player_BeforeDownTransition ( ILContext il )
380380 {
381381 ILCursor cursor = new ( il ) ;
382382
383- CheckState ( cursor , Player . StRedDash , false , true ) ;
383+ CheckState ( cursor , Player . StRedDash , false ) ;
384384 }
385385
386386 private static void Player_TransitionTo ( ILContext il )
@@ -438,54 +438,46 @@ private static void NaiveMoveTowardsY(Player player, float targetY, float maxAmo
438438 /// Use if decompilation says <c>State!=9</c> and NOT followed by <c>&&</c>.
439439 /// </summary>
440440 private static readonly ILContext . Manipulator State_DreamDashNotEqual = il => CheckState ( new ILCursor ( il ) , Player . StDreamDash , false ) ;
441- /// <summary>
442- /// Use if decompilation says <c>State==9</c> and IS followed by <c>&&</c>.
443- /// </summary>
444- private static readonly ILContext . Manipulator State_DreamDashEqual_And = il => CheckState ( new ILCursor ( il ) , Player . StDreamDash , true , true ) ;
445- /// <summary>
446- /// Use if decompilation says <c>State!=9</c> and IS followed by <c>&&</c>.
447- /// </summary>
448- private static readonly ILContext . Manipulator State_DreamDashNotEqual_And = il => CheckState ( new ILCursor ( il ) , Player . StDreamDash , false , true ) ;
441+
449442 /// <summary>
450443 /// Patch any method that checks the player's state.
451444 /// </summary>
452445 /// <remarks>Checks for <c>ldc.i4.s <state></c></remarks>
453446 /// <param name="cursor">The ILCursor to use</param>
454447 /// <param name="state">The state to check for</param>
455448 /// <param name="equal">Whether the decompilation says <c>State == <state></c></param>
456- /// <param name="and">Whether the check is followed by <c>&&</c></param>
457- private static void CheckState ( ILCursor cursor , int state , bool equal , bool and = false )
449+ private static void CheckState ( ILCursor cursor , int state , bool equal )
458450 {
459451 if ( cursor . TryGotoNext ( instr => instr . MatchLdcI4 ( state ) &&
460452 instr . Previous != null && instr . Previous . MatchCallvirt < StateMachine > ( "get_State" ) ) )
461453 {
462454 Instruction idx = cursor . Next ;
463455 // Duplicate the Player State
464456 cursor . Emit ( OpCodes . Dup ) ;
465- // Check whether the state matches St.DreamTunnelDash AND we want them to match
466- cursor . EmitDelegate < Func < int , bool > > ( st => st == St . DreamTunnelDash == equal ^ and ) ;
457+ // Check whether the state matches St.DreamTunnelDash
458+ cursor . EmitDelegate < Func < int , bool > > ( st => st == St . DreamTunnelDash ) ;
467459 // If not, skip the rest of the emitted instructions
468- cursor . Emit ( OpCodes . Brfalse_S , cursor . Next ) ;
460+ cursor . Emit ( OpCodes . Brfalse , cursor . Next ) ;
469461
470462 // Else
471463 // Duplicated Player State value will be unused, so it must be trashed
472464 cursor . Emit ( OpCodes . Pop ) ;
473465
474466 // Retrieve the next break instruction that checks equality
475- Instruction breakInstr = cursor . Clone ( ) . GotoNext ( instr => instr . Match ( OpCodes . Beq_S ) || instr . Match ( OpCodes . Bne_Un_S ) || instr . Match ( OpCodes . Ceq ) ) . Next ;
467+ Instruction breakInstr = cursor . Clone ( ) . GotoNext ( instr => instr . MatchBeq ( out ILLabel _ ) || instr . MatchBneUn ( out ILLabel _ ) || instr . MatchCeq ( ) ) . Next ;
476468
477469 // For SteamFNA, if there is a check for equality just break to after it after pushing the appropriate value to the stack
478- if ( breakInstr . OpCode == OpCodes . Ceq )
470+ if ( breakInstr . MatchCeq ( ) )
479471 {
480472 cursor . Emit ( equal ? OpCodes . Ldc_I4_1 : OpCodes . Ldc_I4_0 ) ;
481- cursor . Emit ( OpCodes . Br_S , breakInstr . Next ) ;
473+ cursor . Emit ( OpCodes . Br , breakInstr . Next ) ;
482474 }
483475 // If our intended behaviour matches what the break instruction is checking for, break to its target
484- else if ( breakInstr . OpCode == OpCodes . Beq_S == equal ^ and )
485- cursor . Emit ( OpCodes . Br_S , breakInstr . Operand ) ;
476+ else if ( breakInstr . MatchBeq ( out ILLabel to ) )
477+ cursor . Emit ( OpCodes . Br , to ) ;
486478 // Otherwise, break to after the break instruction (skip it)
487479 else
488- cursor . Emit ( OpCodes . Br_S , breakInstr . Next ) ;
480+ cursor . Emit ( OpCodes . Br , breakInstr . Next ) ;
489481
490482 cursor . Goto ( idx , MoveType . After ) ;
491483 }
@@ -495,10 +487,10 @@ private static void Player_orig_Update(ILContext il)
495487 {
496488 ILCursor cursor = new ( il ) ;
497489 CheckState ( cursor , Player . StDreamDash , true ) ;
498- CheckState ( cursor , Player . StDreamDash , false , true ) ;
499- CheckState ( cursor , Player . StDreamDash , false , true ) ;
490+ CheckState ( cursor , Player . StDreamDash , false ) ;
491+ CheckState ( cursor , Player . StDreamDash , false ) ;
500492 // Not used because we DO want to enforce Level bounds.
501- //Check_State_DreamDash(cursor, false, true );
493+ //Check_State_DreamDash(cursor, false);
502494 }
503495
504496 private static void Level_EnforceBounds ( ILContext il )
0 commit comments