Ticket #42666

Lua: API to unhardcode autoupgrade

오픈 날짜: 2021-07-24 23:41 마지막 업데이트: 2022-02-10 07:55

Reporter:
소유자:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
4

Details

This is a sub-task of #42659. Needed functions (test ones are probably common, edit ones are server scripting):

  • test if a unit may be converted (upgraded) to a given type regarding its current position, transporter and cargo;
  • get a unit type a player may upgrade a unit type to;
  • convert (upgrade) a unit to a given type (if it is possible; a double testing will likely occur in the loop but it's not fatal);
  • promote a unit given number of veteranship ranks (may be negative) clipped by its veteran system, no notifications sent; naturally accompanied by general veteranship getting functions;
  • an algorithm (in Lua or C) to get a random selection from a list.

Ticket History (3/14 Histories)

2021-07-24 23:41 Updated by: ihnatus
  • New Ticket "Lua: API to unhardcode autoupgrade" created
2022-02-06 06:44 Updated by: ihnatus
댓글 올리기

Done. Based on a patch from #43778

2022-02-07 07:51 Updated by: cazfi
댓글 올리기

default case from api_methods_unit_transform_problem() switch should be removed, and the assert placed after the block (all valid 'uu' values cause function to return from inside the switch). That way we get compiler warning in the future if there's a new 'enum unit_upgrade_result' added, but not handled in the switch.

2022-02-08 02:29 Updated by: ihnatus
  • File 3_1-lua-api-upgrades2.patch (File ID: 8482) is attached
2022-02-08 02:29 Updated by: ihnatus
댓글 올리기

Switch edited.

2022-02-08 04:03 Updated by: ihnatus
  • File 3_1-lua-api-upgrades2.patch (File ID: 8482) is deleted
2022-02-08 15:34 Updated by: cazfi
댓글 올리기

Patch looks good to me (haven't tested it yet). The only concern is that is this future-proof (to not cause compatibility issues) concerning what ever way #43251 will get resolved.

2022-02-08 16:07 Updated by: cazfi
  • 소유자 Update from (None) to cazfi
  • Resolution Update from None to Accepted
댓글 올리기

Git was complaining about a new trailing whitespace. Attached version with that fixed.

Reply To cazfi

The only concern is that is this future-proof (to not cause compatibility issues) concerning what ever way #43251 will get resolved.

Beginning review period regardless. People have 36h to comment, and that includes possibility to comment about #43251 compatibility.

2022-02-09 19:48 Updated by: cazfi
댓글 올리기

Reply To cazfi

Git was complaining about a new trailing whitespace. Attached version with that fixed. Reply To cazfi

The only concern is that is this future-proof (to not cause compatibility issues) concerning what ever way #43251 will get resolved.

Beginning review period regardless. People have 36h to comment, and that includes possibility to comment about #43251 compatibility.

My own take is that after this goes in (and to a released datafile format), we just need to resolve #43251 in a way that retains compatibility. It can add stuff, but will have some limitations how it can rework existing functionality.

2022-02-10 07:55 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Attachment File List

Edit

Please login to add comment to this ticket » Login