Files
Bubberstation/code/controllers/configuration/entries
SkyratBot a31e4bedfa [MIRROR] Tackles various problems with keyed_list config entries, fixing broken roundstart races and more! [MDB IGNORE] (#9131)
* Tackles various problems with keyed_list config entries, fixing broken roundstart races and more! (#62359)

While helping RaveRadbury debug some issues with enabling Halloween species early via the brute force method of enabling them in the config rather than the gentleman's solution of testmerging a PR that changes the Halloween date, we discovered something dreadful.

Cloth golems cannot be enabled! Infact, any species with a space in the ID cannot be enabled.

It uses the splitter despite VALUE_MODE_FLAG being set. So a key entry like ROUNDSTART_RACES cloth golem would get parsed as cloth = golem, then entered into the config as cloth = TRUE
NEW AND IMPROVED PART HERE

I've re-written how keyed_list config entries are parsed, splitting it into a number of procs to do some discrete block of logic.

Based on feedback from MSO, he expected that VALUE_MODE_FLAG keyed_list entries could have elements overridden. However, this functionality was not present in the code.

I have implemented it. We now support 3 methods of setting VALUE_MODE_FLAGS.

Implicitly enable the config entry: CONFIG_ENTRY config_key_goes_here
Explicitly enable the config entry: CONFIG_ENTRY config_key_goes_here 1
Explicitly disable the config entry: CONFIG_ENTRY config_key_goes_here 0

There have been functionality changes too. Previously, everything before the first splitter was the key and everything after was the value. However, in ambiguous config entries (Such as ROUNDSTART_RACES cloth golem 0) it would be unclear if the intent was (cloth, golem 0) or (cloth golem, 0) or indeed if the intent was (cloth golem 0, 1).

As a result, there is now the following paradigm in place: Everything after the LAST splitter is the value, everything before is the key and a log_config warning is now given explaining the problem and showing how it was resolved.

[2021-10-27 19:48:12.840] WARNING: Multiple splitter characters (" ") found. Using "cloth golem" as config key and "1" as config value.

This warning will trigger if multiple splitters are present for any keyed_list config entry, and will trigger on implicit VALUE_MODE_FLAGS entries that have splitters. The example above is it triggering on ROUNDSTART_RACES cloth golem - It has detected that there is potential ambiguity between (cloth, golem) or (cloth golem, 1), has picked a sensible option for the data type and has warned about it.

The intent is that no config entry should be ambiguous. It should be clear what is key and what is value when dealing with keyed_list config entries.

There's probably more work to do on other config entries to bring them up to this standard, but this is the thing I'm hitting in this PR.

Similarly, I have improved the validation aspect of keyed_list config entries with additional logging in general.
[2021-10-27 19:47:53.135] ERROR: Invalid KEY_MODE_TYPE typepath. Is not a valid typepath: /mob/living/carbon/monkey

I have added a unit test to make sure species IDs do not contain splitters from the two keyed_list subtypes relating to species.

I have added sanity checking to the race config subtypes since we have a big dick global list of all races sorted by ID, so a race not existing will fail validation and output a meaningful config log entry.

I have removed /datum/config_entry/keyed_list/probability from the code as it is unused with the removal of all game modes except Dynamic.

The config change necessitated the renaming of all golem species IDs. Doing so and renaming the clothgolem.ts file to match has fixed the broken cloth golem page too.

* Tackles various problems with keyed_list config entries, fixing broken roundstart races and more!

Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
2021-10-29 21:07:21 +01:00
..
2021-09-26 01:48:37 +01:00