Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump-mode backspace past beginning of move queue locks game #5348

Closed
WeaverThree opened this issue Apr 10, 2024 · 5 comments · Fixed by #5352
Closed

Jump-mode backspace past beginning of move queue locks game #5348

WeaverThree opened this issue Apr 10, 2024 · 5 comments · Fixed by #5352
Labels

Comments

@WeaverThree
Copy link
Collaborator

WeaverThree commented Apr 10, 2024

Environment

Megamek 0.49.18

Tested under Adoptium Java 11 and 17 on Windows 10, and OpenJDK 11 and Adoptum 17 on current Fedora Linux, problem persists in all cases.

Description

When you're in movement phase with a mek and in jump mode and backspace past the beginning of the movement list, the game completely freezes and needs to be task killed to close. This can be done just be pressing the 'jump' button and backspace once.

Files

megamek.log - doesn't appear to have anything from this problem
jump-backspace-to-crash-0.49.18.sav.gz - playername Weaver - this is just a pxh-1 by itself ready to move on turn one, so select 'jump' and hit backspace to crash it.

@kuronekochomusuke
Copy link
Collaborator

looks like it gets into an infinite loop here in MovementDisplay

        // Keep removing last step until it's a valid movement step.
        while (cmd.getLastStepMovementType() == EntityMovementType.MOVE_ILLEGAL) {
            removeLastStep();
            removed = true;
        }

@Lu9us
Copy link
Contributor

Lu9us commented Apr 11, 2024

It looks like this is due to an issue in MovementDisplay.removeIllegalSteps() as stated as it treats the start of the jump as Illegal since you can't end a jump without moving then when it is in the MovementDisplay.removeLastStep() this will call cmd.removeLastStep() which clears cmd's steps as expected but when MovementDisplay.clear() is called it will re-add a START_JUMP step because the entity is in jump mode which is once again deemed illegal causing an infinite loop.

Theres some extra steps that I don't quite have a full handle on yet but this is the gist of the issue.

@gsparks3
Copy link
Collaborator

Interestingly, that makes this related to #4970 - jumping into your starting hex shouldn't be illegal for non-infantry units. Although it would still be illegal for infantry, so you can't just use that as the fix instead, have to do both.

@Lu9us
Copy link
Contributor

Lu9us commented Apr 11, 2024

So this is pretty explictily excluded in MoveStep.isLegalEndPos:

... 
else if (isJumping() && (distance == 0)) {
            // Can't jump zero hexes.
            legal = false;
}....

Not sure if the rules have changed since this code was written or I'm missing something.

@HoneySkull
Copy link
Collaborator

Thank you for the bug report @WeaverThree and for the fix @Lu9us. I definitely did not anticipate removing move steps would also create move steps in the case of jump mode. I feel like the fix by @Lu9us is consistent with the intent of the "undo" nature of the backspace key.

HammerGS added a commit that referenced this issue Apr 12, 2024
…when-deleting-movement

#5348 stop adding jump start step when deleting movement
HammerGS added a commit that referenced this issue Apr 12, 2024
+ PR #5353: Utility update and small icon error correction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants