Page 1 of 1

what happens when...

Posted: Sun Apr 17, 2022 2:06 am
by Dino the Dinosore
In some rulesets, like mp2-caravel, the Legion unit has the "Settlers" flag and can irrigate and build roads. So what happens when it starts irrigating and then gets auto-upgraded to a Musketeer by Leonardo's Workshop? The answer is - it depends. If you save the game, and then re-load the saved game the tile is not irrigated and the Musketeer is waiting to move. Otherwise it continues working until the tile is irrigated. Now you know.

Re: what happens when...

Posted: Sun Apr 17, 2022 3:30 am
by cazfi
So legality of the actions is not checked after an upgrade? Doesn't this leave to sanity check errors on following turns?

Sanity of save games is checked when they are loaded, so that explains why you don't see the issue after that.

Please open a ticket. I've already got some other fixes related to cancelling illegal activities in the pipeline, so likely handling this would fit nicely to the rewrite of that area.

Re: what happens when...

Posted: Sun Apr 17, 2022 7:16 pm
by Dino the Dinosore
Yes there's an inconsistency here but I'm not convinced what is the correct behaviour. I can see the argument that it's OK to let the tile improvement continue til completed.

I didn't notice sanity check errors on following turns but I also wasn't looking for them.

Re: what happens when...

Posted: Sun Apr 17, 2022 7:50 pm
by Ignatus
Dino the Dinosore wrote:Yes there's an inconsistency here but I'm not convinced what is the correct behaviour. I can see the argument that it's OK to let the tile improvement continue til completed.
Like, if it digs when it can't dig any more, it is an error. Let me file a bug for you: OSDN#44410

Re: what happens when...

Posted: Mon Apr 18, 2022 12:25 am
by Dino the Dinosore
Thanks. Although I can see both sides of the argument that it's OK to let the tile improvement continue til completed, it looks like it's a much easier fix to stop it. I'm OK with that.

Re: what happens when...

Posted: Mon Apr 18, 2022 12:28 pm
by nef
Another option to consider is to not allow the upgrade while the unit is doing something the upgrade can`t do. I believe this is the case for the unit being somewhere the upgrade can`t be.

Re: what happens when...

Posted: Mon Apr 18, 2022 12:59 pm
by cazfi
True. That would also be consistent with another fix currently in review (-> still subject to change itself) that unit currently in the middle of conversion activity is not allowed to upgrade: https://osdn.net/projects/freeciv/ticket/43328

Re: what happens when...

Posted: Mon Apr 18, 2022 6:42 pm
by Ignatus
Headscratches: we, in newer versions, basically test if an activity is legal in the ruleset by testing if a unit can do an action switching to this activity from "Idle". But we actually don't switch to it from "Idle" neither do any other action. Does continuing the activity each time we check it count as auto-performed action? Is it, in the game's philosophy of actions and stuff, a clean conception?..
nef wrote:Another option to consider is to not allow the upgrade while the unit is doing something the upgrade can`t do. I believe this is the case for the unit being somewhere the upgrade can`t be.
Actually, I requested unhardcoding autoupgrade for the purpose of handing the behaviour in such twisted corners to ruleset authors (but the API we have now can't tell this specific point). Just we should not allow getting situations we consider illegal on the gameboard.

Re: what happens when...

Posted: Sun May 15, 2022 5:31 am
by cazfi
nef wrote:Another option to consider is to not allow the upgrade while the unit is doing something the upgrade can`t do. I believe this is the case for the unit being somewhere the upgrade can`t be.
We didn't go that way at this time, as it would have been technically much more complex - we don't currently have good utility functions to predict, in all cases of complex action enablers, what activities would be legal for the upgraded unit before we have actually done the upgrade.