-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix disembarking without losing MP through adjacent transport #2025
Conversation
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.
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. |
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. |
Ok I recreated with a Mech too. |
There was a problem hiding this 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
It might be possible to move from a ship into a transport plane or something like this that would normally be forbidden. |
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:
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.