#47292: Unit counters framework Open Date: 2023-02-03 03:25 Last Update: 2023-05-27 01:39 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/47292 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=47292 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2023-05-27 01:39 Updated by: lachu Comment: Reply To cazfi - Patch does not apply (any more?) - Missing ruleset documentation about "target" field - Following check is not strict enough. What if target was given as "blabla"? Even in compat mode, we should only accept the case where the "target" is completely missing: {{{ if (!counter_target_is_valid(ct)) { ... + if (compat->version > RSFORMAT_3_2) { + ruleset_error(NULL, LOG_ERROR, + "\"%s\" unknown counter target \"%s\".", + filename, counter_type); + ok = FALSE; + break; + } + ct = CTGT_CITY; } }}} 2023-05-27 01:35 Updated by: lachu File 0001-OSDN-47292-S-awomir-Lach-slawek-lach.art.pl.patch (File ID: 12477) is attached I noticed small problem. When modder set invalid, but not blank target for newer ruleset, one condition check to not bypass, but should and else statement-related-instruction was executed. Still, during trying to handle this issue, unconditionally I badly noticed some other error (it shown error that counter type is null), so I though It wrote that counter target is null and try to solve that, so (maybe?) code is ugly. Tell me if I should clean-up-it. It uses entry struct instead of testing if string is null from secfile_lookup_str_default function. --------------------------------------------------------------------- Ticket Status: Reporter: cazfi Owner: (None) Type: Patches Status: Open Priority: 5 - Medium MileStone: 3.3.0 Component: General Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: Add initial support for unit counters. No need to implement any counter behavior in this ticket - current counters code should be flexible enough to work (iterate over) zero counter behaviors and counter instances. --- - Add counter_target type "Unit" - Add counters_get_unit_counters_count() - Implement unit_counters_iterate(pcount) macro (mostly by copying ciyt_counters_iterate() and modifying a bit) - Add "counter_values" to unit structure Savegame part likely isn't as trivial "copy from city counters implementation" -> let's leave that to another ticket. -- Ticket information of Freeciv project Freeciv Project is hosted on OSDN Project URL: https://osdn.net/projects/freeciv/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/freeciv/ticket/47292 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=47292