"Transport Embark" Bug report (can't access OSDN)
Posted: Thu Dec 07, 2023 3:51 pm
Please disregard this bug report if this has recently been changed in freeciv server 3.x
Background
When a land unit does a GOTO that goes offshore onto a transport vessel, OR when doing the "Transport Embark" action onto the offshore tile onto a transport, it appears the server is doing a "Move" and "Transport Board" double action sequence as a "proxy" for a single Transport Embark action.
Bug Description
The problem with this "double action proxy" version of "Transport Embark" is that after doing the first part (Move), move points are subtracted. This can change the unit's state vis-à-vis the actionenabler legality. For example, if "Transport Embark" is legal with 1 move left, and "Transport Board" is not legal with 0 moves left, and a unit with 1 move executes Transport Embark on the offshore tile with a transporter, then...
1. Server moves unit onto the same tile as transport. Server subtracts 1 move point for doing so.
2. Unit attempts a "Transport Board" action, actionenabler checks the reqs and sees that unit has 0 moves left, so disallows Transport Board.
3. Land unit is left swimming alone in the Ocean, and player with Transport moves away thinking he has cargo, only to find out he left the cargo swimming in the ocean yelling "help I'm drowning!"
Rulesets affected
Obviously, this bug will not happen in rulesets where boarding is legal for units with 0 moves left. Such rulesets shouldn't feel smug about escaping this bug, because allowing boarding with 0 moves left opens a giant Pandora Box for physics-breaking double movement exploits that savvy expert players can use to "hack" very unreasonable OP unrealistic tactical advantages from, leading to you eventually making stricter requirements for boarding and unloading and the move costs and legalities associated with those. And then getting this bug.
Current Workaround
For now there is a workaround to this bug in the ruleset itself. You can make an actionenabler for Transport Board that makes boarding always legal for units with 0 moves left, IFF OnlivableTile is false, etc. Even though the actionenabler is for Transport Board, it will affect the bug in Transport Embark due to the fact that Embark uses "Move"+"Board" as a proxy for a true embarkation. And since it only works for units who aren't on livable tiles, it basically only applies to catching any unit who got bugged into being stranded on a nonlivable tile. The Transport Embark action will then automatically work.
Obviously, this kind of hacked fix inside the ruleset is suboptimal to a server fix.
Server-side bug-fix discussion
Besides completely rewriting Transport Embark as its own separate action (instead of Move-and-Board proxy double action), one idea to fix this is something like this: use a temp var to save the move points right before doing the order Move, and a temp var for the move-points right after doing the Order Move, restore the original move points back into the unit right before doing the Transport Board actionenabler, then after completing Transport Board, go back to the saved var representing the movepoints lost after doing the Order Move.
Cheers
Background
When a land unit does a GOTO that goes offshore onto a transport vessel, OR when doing the "Transport Embark" action onto the offshore tile onto a transport, it appears the server is doing a "Move" and "Transport Board" double action sequence as a "proxy" for a single Transport Embark action.
Bug Description
The problem with this "double action proxy" version of "Transport Embark" is that after doing the first part (Move), move points are subtracted. This can change the unit's state vis-à-vis the actionenabler legality. For example, if "Transport Embark" is legal with 1 move left, and "Transport Board" is not legal with 0 moves left, and a unit with 1 move executes Transport Embark on the offshore tile with a transporter, then...
1. Server moves unit onto the same tile as transport. Server subtracts 1 move point for doing so.
2. Unit attempts a "Transport Board" action, actionenabler checks the reqs and sees that unit has 0 moves left, so disallows Transport Board.
3. Land unit is left swimming alone in the Ocean, and player with Transport moves away thinking he has cargo, only to find out he left the cargo swimming in the ocean yelling "help I'm drowning!"
Rulesets affected
Obviously, this bug will not happen in rulesets where boarding is legal for units with 0 moves left. Such rulesets shouldn't feel smug about escaping this bug, because allowing boarding with 0 moves left opens a giant Pandora Box for physics-breaking double movement exploits that savvy expert players can use to "hack" very unreasonable OP unrealistic tactical advantages from, leading to you eventually making stricter requirements for boarding and unloading and the move costs and legalities associated with those. And then getting this bug.
Current Workaround
For now there is a workaround to this bug in the ruleset itself. You can make an actionenabler for Transport Board that makes boarding always legal for units with 0 moves left, IFF OnlivableTile is false, etc. Even though the actionenabler is for Transport Board, it will affect the bug in Transport Embark due to the fact that Embark uses "Move"+"Board" as a proxy for a true embarkation. And since it only works for units who aren't on livable tiles, it basically only applies to catching any unit who got bugged into being stranded on a nonlivable tile. The Transport Embark action will then automatically work.
Obviously, this kind of hacked fix inside the ruleset is suboptimal to a server fix.
Server-side bug-fix discussion
Besides completely rewriting Transport Embark as its own separate action (instead of Move-and-Board proxy double action), one idea to fix this is something like this: use a temp var to save the move points right before doing the order Move, and a temp var for the move-points right after doing the Order Move, restore the original move points back into the unit right before doing the Transport Board actionenabler, then after completing Transport Board, go back to the saved var representing the movepoints lost after doing the Order Move.
Cheers