Ticket #41523

Lua API: remove move unit side effects

Eröffnet am: 2021-02-09 00:36 Letztes Update: 2021-03-17 13:39

Auswertung:
Verantwortlicher:
Typ:
Status:
Geschlossen
Komponente:
Meilenstein:
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Accepted
Datei:
2

Details

Unit:move() and Unit:teleport() accumulated many exceptions to enabler defined rules as more and more parts of regular unit move can under action enabler control. They were able to conquer cities, embark into transports, conquer extras and pop huts. The

The reason for the exceptions was strict backwards compatibility. Freeciv can't know if a ruleset or scenario author intended a move as what now was an enabler controlled action. The action side effect of the move may have been intended by, irrelevant to or overlooked by the script author.

Keeping this stirct backwards compatibility made it difficult to move certain rules to the ruleset. The best that could be done for them was obligatory hard requirements.This is why much hasn't moved to the ruleset yet.

The exceptions can also make a ruleset author - assuming a call to unit_move() is a regular move - accidentally trigger behavior currently controlled by actions and end up breaking his own rules in a Lua script.

A unit can now be forced to perform an action - as long as it is legal - with Unit:perform_action().

Given the above I say that the time has come to purge some side effects. Remove the city conquest, extra conquest and hut popping side effects. Allow embarking to stay for now. Someone may use one of the functions to teleport into a transport or something like that.

Ticket-Verlauf (3/11 Historien)

2021-02-09 00:36 Aktualisiert von: kvilhaugsvik
  • New Ticket "Lua API: remove move unit side effects" created
2021-02-09 00:45 Aktualisiert von: cazfi
Kommentar

They currently work in S3_1, don't they?

We are assumed to keep compatibility over at least one version, during which the author can migrate. So this could be targeted to 3.2 at the earliest.

2021-02-09 00:45 Aktualisiert von: kvilhaugsvik
  • Details Updated
2021-02-09 00:46 Aktualisiert von: kvilhaugsvik
2021-02-09 00:52 Aktualisiert von: kvilhaugsvik
Kommentar

So add a deprecation warning that the side effects will go away in 3.2?

2021-02-09 01:27 Aktualisiert von: kvilhaugsvik
Kommentar

Is there any documentation on the exact policy for Lua?

Do we have a policy against adding additional parameters to a Lua-function as long as the old call still works? (Missing parameters are nil)

I think I have an idea on how to make it easy to migrate to 3.2.

2021-03-12 07:24 Aktualisiert von: kvilhaugsvik
Kommentar

Once #41730 lands and we have a way of looking for the diplomatic relationship war and preferably also unit class flags from Lua the current Unit:move() and Unit:teleport() can be deprecated.

2021-03-13 04:28 Aktualisiert von: kvilhaugsvik
  • Lösung Update from Keine to Accepted
Kommentar

New attempt. This time after deprecation in 3.1.

2021-03-17 13:39 Aktualisiert von: kvilhaugsvik
  • Status Update from Offen to Geschlossen

Bearbeiten

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Anmelden