待辦事項 #41523

Lua API: remove move unit side effects

啟用日期: 2021-02-09 00:36 最後更新: 2021-03-17 13:39

回報者:
負責人:
類型:
狀態:
關閉
元件:
里程碑:
優先權:
5 - 中
嚴重程度:
5 - 中
處理結果:
Accepted
檔案:
2

細節

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
評語

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
評語

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

2021-02-09 01:27 Updated by: kvilhaugsvik
評語

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
評語

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
  • 處理結果 Update from to Accepted
評語

New attempt. This time after deprecation in 3.1.

2021-03-17 13:39 Updated by: kvilhaugsvik
  • 狀態 Update from 開啟 to 關閉

編輯

Please login to add comment to this ticket » 登入