任务单 #41523

Lua API: remove move unit side effects

开放日期: 2021-02-09 00:36 最后更新: 2021-03-17 13:39

报告人:
属主:
类型:
状态:
关闭
组件:
里程碑:
优先:
5 - Medium
严重性:
5 - Medium
处理结果:
Accepted
文件:
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.

任务单历史 (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 » 登录名