Reply To cazfi
Ruledit should show number of counters in the ruleset in the statistics.
First patch suggestion was made. Only one think not clear to me is: ruledit_disabled . Why this is introduced? Should counters have the same field as (for example) multipliers?
Reply To lachu
Only one think not clear to me is: ruledit_disabled . Why this is introduced?
It allows "removing" ruleset item without very complex rearrangements in the memory. That is; item in an array just gets marked as "ruledit_disabled" and later items in the array remain where they are, instead of all the later items moving to fill the hole. It would be practically impossible to update all the references to those later items.
Reply To cazfi
Reply To lachu
Only one think not clear to me is: ruledit_disabled . Why this is introduced?
It allows "removing" ruleset item without very complex rearrangements in the memory. That is; item in an array just gets marked as "ruledit_disabled" and later items in the array remain where they are, instead of all the later items moving to fill the hole. It would be practically impossible to update all the references to those later items.
Hi. Should I introduce ruledit_enable in counter's struct? I introduced routine to remove counter in #45892 and there is small amount of entries in counter's array. Also, we do not have to keep specialized counter array (for city' counter, for example), because for ruledit we do not need it - there is no gameplay active, so we not need cache or mateinformation for city generation purposes.
I think adding bool ruledit_enabled is not necessary for counters.
Reply To lachu
Hi. Should I introduce ruledit_enable in counter's struct? I introduced routine to remove counter in #45892 and there is small amount of entries in counter's array.
So, what happens, e.g, to requirements of the "Counter" type, pointing to a later counter than the removed one, when a counter is removed?
Reply To cazfi
Reply To lachu
Hi. Should I introduce ruledit_enable in counter's struct? I introduced routine to remove counter in #45892 and there is small amount of entries in counter's array.
So, what happens, e.g, to requirements of the "Counter" type, pointing to a later counter than the removed one, when a counter is removed?
Yes. You are right. I have other question. How freeciv track reference count, so I am sure that I can reuse counter index?
Ok. I figure out is_counter_needed is necessary, which I implemented. If counter is not needed, I can mark it as disabled and free one's memory.
In addition to already mentioned city_counters_re_active_iterate() change (implementation of the macros, and using them):
- Place this to the middle column (currently leftmost has one row more than others, should add that row to middle one before the rightmost one)
- Use postfix 'count++;' instead of prefix '++count;'
2022-12-31 04:35 Updated by: lachu
Suggested changes was apply by this patch.
2022-12-31 05:25 Updated by: lachu
I do not known if should I send this patch here or on editing ruleset ticket. It brings ruledit_disabled entity and add new macro-iterator for ruledit purposes. But.. After all, this code (counting counter) should look like this. Also, when counter is disabled, it should not be counted. right?
- Does not apply to current HEAD (counters.c)
- While we currently have only city counters, there's no point in making things specific for them when generic counters support would be as easy (or easier!):
- There's trailing space in the macro. You may want to check your git/terminal settings to make sure 'git diff' shows these to you on easily noticed color.
- What you are including "support.h" for, to counters.h? Don't see rest of the change to the file requiring anything from there. If it does, add "/* utility */" header for the include group
Reply To cazfi
- Does not apply to current HEAD (counters.c)
- While we currently have only city counters, there's no point in making things specific for them when generic counters support would be as easy (or easier!):
- Drop the "city_" -prefix from the iterator macro name
- Make it to iterate over all counters (up to game.control.num_counters)
- There's trailing space in the macro. You may want to check your git/terminal settings to make sure 'git diff' shows these to you on easily noticed color.
- What you are including "support.h" for, to counters.h? Don't see rest of the change to the file requiring anything from there. If it does, add "/* utility */" header for the include group
I included support.h for boolean type.
Reply To cazfi
- Does not apply to current HEAD (counters.c)
- While we currently have only city counters, there's no point in making things specific for them when generic counters support would be as easy (or easier!):
- Drop the "city_" -prefix from the iterator macro name
- Make it to iterate over all counters (up to game.control.num_counters)
- There's trailing space in the macro. You may want to check your git/terminal settings to make sure 'git diff' shows these to you on easily noticed color.
- What you are including "support.h" for, to counters.h? Don't see rest of the change to the file requiring anything from there. If it does, add "/* utility */" header for the include group
2022-12-31 23:22 Updated by: lachu
Looks good now.
Ruledit should show number of counters in the ruleset in the statistics.