Incidencia #41523

Lua API: remove move unit side effects

Abrir Fecha: 2021-02-09 00:36 Última actualización: 2021-03-17 13:39

Informador:
Propietario:
Tipo:
Estado:
Cerrado
Componente:
Hito:
Prioridad:
5 - Medium
Gravedad:
5 - Medium
Resolución:
Accepted
Fichero:
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 History (3/11 Histories)

2021-02-09 00:36 Updated by: kvilhaugsvik
  • New Ticket "Lua API: remove move unit side effects" created
2021-02-09 00:45 Updated by: cazfi
Comentario

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 Updated by: kvilhaugsvik
  • Details Updated
2021-02-09 00:46 Updated by: kvilhaugsvik
2021-02-09 00:52 Updated by: kvilhaugsvik
Comentario

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

2021-02-09 01:27 Updated by: kvilhaugsvik
Comentario

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 Updated by: kvilhaugsvik
Comentario

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 Updated by: kvilhaugsvik
  • Resolución Update from Ninguno to Accepted
Comentario

New attempt. This time after deprecation in 3.1.

2021-03-17 13:39 Updated by: kvilhaugsvik
  • Estado Update from Open to Cerrado

Editar

Please login to add comment to this ticket » Entrar