Skip to content

Commit d35f820

Browse files
committed
Documentation tweaks part 100000
1 parent ff6efd2 commit d35f820

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/DashStates/DreamTunnelDash/DreamTunnelDash.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,22 @@ private static void CheckState(ILCursor cursor, int state, bool equal)
474474

475475
bool matchedBeqOrBne = false, matchedCeq = false;
476476
ILLabel failedCheck = null;
477-
Instruction ceqInstr = null;
477+
Instruction checkInstr = null;
478478

479479
// retrieve info about the current check
480480
ILCursor cloned = cursor.Clone();
481481
if (!cloned.TryGotoNext(MoveType.After, instr =>
482482
{
483-
// we grab a lot of stuff here: whether we matched a beq/bne.un or a ceq, the "fail state" label of the beq/bne.un
484-
// (if we matched one of those) and the actual ceq instruction (if we matched that).
485-
486-
// equality checks usually use bne.un (for ==) or beq (for !=) to branch past the block of the if statement when the values don't match
483+
// we grab a lot of stuff here: whether we matched a beq/bne.un or a ceq, the "fail state" label of the beq/bne.un (if we matched one of those)
484+
// and the check instruction itself.
485+
486+
// equality checks usually use bne.un (for `==`) or beq (for `!=`) in order to branch past the block of the if statement when the values don't match
487487
matchedBeqOrBne = equal ? instr.MatchBneUn(out failedCheck) : instr.MatchBeq(out failedCheck);
488488
// alternatively they could use ceq and then a brtrue/brfalse to do the same, though i don't think there are any for this purpose in vanilla
489-
matchedCeq = (ceqInstr = instr).MatchCeq();
490-
489+
matchedCeq = instr.MatchCeq();
490+
// the instruction we're testing is the one doing the check; grab it
491+
checkInstr = instr;
492+
491493
return matchedBeqOrBne || matchedCeq;
492494
})) return;
493495
// and the instruction after the current check
@@ -528,7 +530,7 @@ private static void CheckState(ILCursor cursor, int state, bool equal)
528530
// duplicate player on stack
529531
cursor.Emit(OpCodes.Dup);
530532
// go to the ceq instruction and modify the value it returns
531-
cursor.Goto(ceqInstr, MoveType.After);
533+
cursor.Goto(checkInstr, MoveType.After);
532534
// our desired value for what the ceq instruction returns depends on whether we check equality or not. but we don't control that, the brtrue/brfalse after the ceq does.
533535
// to solve this, our desired conditions can be shown equivalent to `player.StateMachine.State == state || player.StateMachine.State == St.DreamTunnelDash` (for equality)
534536
// and `!(player.StateMachine.State == state || player.StateMachine.State == St.DreamTunnelDash)` (for inequality). notice how the desired condition for inequality is

0 commit comments

Comments
 (0)