"Transport Embark" Bug report (can't access OSDN)

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Post Reply
Lexxie
Veteran
Posts: 127
Joined: Fri Jun 23, 2017 4:18 pm

"Transport Embark" Bug report (can't access OSDN)

Post by Lexxie »

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
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: "Transport Embark" Bug report (can't access OSDN)

Post by Ignatus »

Seems like not only "Transport_Embark" is effectively broken in two parts (I didn't dig the code well but I would check the unit path mechanism that keeps many archaic traits). Something is broken in the mechanism when performing an action causes another pre-action while that pre-action may render the consequent action impossible. The Sveinnung's strict understanding of an action as something that a player specifically orders would do something to resolve it, but it seems being broken back in those days when his guidelines were written. Outline of this flaw may be considered the same as many Lua callbacks have: things that are intended for transitions from one regular game state to another are working in the middle of moving the pieces when state of things on the board may contradict the basic rules. Like, that should ever be fixed.
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: "Transport Embark" Bug report (can't access OSDN)

Post by cazfi »

(can't access OSDN)
Assuming that osdn won't be stable/well maintained platform in the future, we're setting up self-maintained redmine instance. Self-maintained because we've now had to migrate from a provider to provider three times in span of couple of years, as those providers have gone under. We have to be in control ourselves to stop that happening again (though I'm a bit worried about redmine's future as a platform, but for the time being it was the best option we had)

As said, this is still a bit work-in-progress, but you should be able to register, and do basic issue reporting already: https://redmine.freeciv.org/projects/freeciv
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: "Transport Embark" Bug report (can't access OSDN)

Post by cazfi »

Ignatus wrote: Fri Dec 08, 2023 6:47 pm Seems like not only "Transport_Embark" is effectively broken in two parts (I didn't dig the code well but I would check the unit path mechanism that keeps many archaic traits). Something is broken in the mechanism when performing an action causes another pre-action while that pre-action may render the consequent action impossible. The Sveinnung's strict understanding of an action as something that a player specifically orders would do something to resolve it, but it seems being broken back in those days when his guidelines were written. Outline of this flaw may be considered the same as many Lua callbacks have: things that are intended for transitions from one regular game state to another are working in the middle of moving the pieces when state of things on the board may contradict the basic rules. Like, that should ever be fixed.
Could you open a ticket (or tickets) about all this, as you clearly know the situation better than I do.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: "Transport Embark" Bug report (can't access OSDN)

Post by Ignatus »

cazfi wrote: Thu Dec 28, 2023 10:19 amCould you open a ticket (or tickets) about all this, as you clearly know the situation better than I do.
You are overestimating me much :roll: , actually I wrote that all not looking into code, just reading the supplied bug description and recalling what I have dealed with long ago. In fact, I have vague idea of how at all do the triggered actions happen, and hardly will look at it in considerable while.
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: "Transport Embark" Bug report (can't access OSDN)

Post by cazfi »

Reading the source code, it seems to me that "Embark" action is atomic in this sense (nowadays). Step that loads the unit to transport does not do any kind of movement points check.
Will need to construct a test case to confirm, though.
Post Reply