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

Fix disembarking without losing MP through adjacent transport #2025

Merged

Conversation

lmoureaux
Copy link
Contributor

Say we have two transports A and B next to the coast C, with a land
unit in A. Consider the following orders for the land unit:

  1. Unload from A to B->tile
  2. Move from B->tile to C

This sequence should not succeed because the unit should still be loaded
after the first step. However, in practice the unit was not loaded after
step 1, resulting in an invalid state that confused ORDER_MOVED. Do the
same when bumping units after a transport is killed.

The fix to that is obviously to load the unit after step 1. There is a
catch though: this is (and has always been) done without considering
action enablers. It might be possible to exploit this to bypass loading
rules.

Path finding support is also included in this PR.
Backport candidate.

Say we have two transports A and B next to the coast C, with a land
unit in A. Consider the following orders for the land unit:

1. Unload from A to B->tile
2. Move from B->tile to C

This sequence should not succeed because the unit should still be loaded
after the first step. However, in practice the unit was not loaded after
step 1, resulting in an invalid state that confused ORDER_MOVED. Do the
same when bumping units after a transport is killed.

The fix to that is obviously to load the unit after step 1. There is a
catch though: this is (and has always been) done without considering
action enablers. It might be possible to exploit this to bypass loading
rules.

Spotted by mu in LT78.
It had two branches with identical code.
Since units are (now) automatically loaded back after unloading to a
non-native tile, make the goto code aware of this to avoid generating
invalid paths. Also unify the handling of ACTION_TRANSPORT_DISEMBARK1
and 2.
@lmoureaux lmoureaux requested a review from jwrober August 27, 2023 20:17
@jwrober
Copy link
Collaborator

jwrober commented Aug 28, 2023

Does this bug only impact combat units, or would it also work on engineers or other non-combat units? I can't recreate on an unpatched install.

@lmoureaux
Copy link
Contributor Author

All units are affected as long as they have at least 3 MP (1 for ship hopping, 1 to disembark, 1 to attack). I used Mechs in my tests.

@jwrober
Copy link
Collaborator

jwrober commented Aug 28, 2023

Ok I recreated with a Mech too.

Copy link
Collaborator

@jwrober jwrober left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does resolve the issue. I am a little concerned about the FIXME added to path_finder.cpp

@jwrober jwrober added the back-port back-port candidate label Aug 28, 2023
@lmoureaux
Copy link
Contributor Author

I am a little concerned about the FIXME added to path_finder.cpp

It might be possible to move from a ship into a transport plane or something like this that would normally be forbidden.

@lmoureaux lmoureaux merged commit 2111a76 into longturn:master Aug 30, 2023
@lmoureaux lmoureaux deleted the bugfix/unit-disembark-adjacent-transport branch August 30, 2023 18:48
@lmoureaux lmoureaux self-assigned this Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-port back-port candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants