mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 14:45:05 +00:00
* 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>
116 lines
3.6 KiB
Plaintext
116 lines
3.6 KiB
Plaintext
//include unit test files in this module in this ifdef
|
|
//Keep this sorted alphabetically
|
|
|
|
#if defined(UNIT_TESTS) || defined(SPACEMAN_DMM)
|
|
|
|
/// Asserts that a condition is true
|
|
/// If the condition is not true, fails the test
|
|
#define TEST_ASSERT(assertion, reason) if (!(assertion)) { return Fail("Assertion failed: [reason || "No reason"]") }
|
|
|
|
/// Asserts that the two parameters passed are equal, fails otherwise
|
|
/// Optionally allows an additional message in the case of a failure
|
|
#define TEST_ASSERT_EQUAL(a, b, message) do { \
|
|
var/lhs = ##a; \
|
|
var/rhs = ##b; \
|
|
if (lhs != rhs) { \
|
|
return Fail("Expected [isnull(lhs) ? "null" : lhs] to be equal to [isnull(rhs) ? "null" : rhs].[message ? " [message]" : ""]"); \
|
|
} \
|
|
} while (FALSE)
|
|
|
|
/// Asserts that the two parameters passed are not equal, fails otherwise
|
|
/// Optionally allows an additional message in the case of a failure
|
|
#define TEST_ASSERT_NOTEQUAL(a, b, message) do { \
|
|
var/lhs = ##a; \
|
|
var/rhs = ##b; \
|
|
if (lhs == rhs) { \
|
|
return Fail("Expected [isnull(lhs) ? "null" : lhs] to not be equal to [isnull(rhs) ? "null" : rhs].[message ? " [message]" : ""]"); \
|
|
} \
|
|
} while (FALSE)
|
|
|
|
/// *Only* run the test provided within the parentheses
|
|
/// This is useful for debugging when you want to reduce noise, but should never be pushed
|
|
/// Intended to be used in the manner of `TEST_FOCUS(/datum/unit_test/math)`
|
|
#define TEST_FOCUS(test_path) ##test_path { focus = TRUE; }
|
|
|
|
/// Constants indicating unit test completion status
|
|
#define UNIT_TEST_PASSED 0
|
|
#define UNIT_TEST_FAILED 1
|
|
#define UNIT_TEST_SKIPPED 2
|
|
|
|
#define TEST_DEFAULT 1
|
|
#define TEST_DEL_WORLD INFINITY
|
|
|
|
/// A trait source when adding traits through unit tests
|
|
#define TRAIT_SOURCE_UNIT_TESTS "unit_tests"
|
|
|
|
#include "anchored_mobs.dm"
|
|
#include "bespoke_id.dm"
|
|
#include "binary_insert.dm"
|
|
#include "bloody_footprints.dm"
|
|
#include "breath.dm"
|
|
#include "card_mismatch.dm"
|
|
#include "chain_pull_through_space.dm"
|
|
#include "chat_filter.dm"
|
|
#include "circuit_component_category.dm"
|
|
#include "closets.dm"
|
|
#include "combat.dm"
|
|
#include "component_tests.dm"
|
|
#include "connect_loc.dm"
|
|
#include "confusion.dm"
|
|
#include "crayons.dm"
|
|
#include "create_and_destroy.dm"
|
|
#include "designs.dm"
|
|
#include "dynamic_ruleset_sanity.dm"
|
|
#include "egg_glands.dm"
|
|
#include "emoting.dm"
|
|
#include "food_edibility_check.dm"
|
|
#include "greyscale_config.dm"
|
|
#include "heretic_knowledge.dm"
|
|
#include "holidays.dm"
|
|
#include "hydroponics_harvest.dm"
|
|
#include "hydroponics_self_mutations.dm"
|
|
#include "keybinding_init.dm"
|
|
#include "machine_disassembly.dm"
|
|
#include "medical_wounds.dm"
|
|
#include "merge_type.dm"
|
|
#include "metabolizing.dm"
|
|
#include "ntnetwork_tests.dm"
|
|
#include "outfit_sanity.dm"
|
|
#include "pills.dm"
|
|
#include "plantgrowth_tests.dm"
|
|
#include "preferences.dm"
|
|
#include "projectiles.dm"
|
|
#include "quirks.dm"
|
|
#include "rcd.dm"
|
|
#include "reagent_id_typos.dm"
|
|
#include "reagent_mod_expose.dm"
|
|
#include "reagent_mod_procs.dm"
|
|
#include "reagent_recipe_collisions.dm"
|
|
#include "resist.dm"
|
|
#include "say.dm"
|
|
#include "security_officer_distribution.dm"
|
|
#include "serving_tray.dm"
|
|
#include "siunit.dm"
|
|
#include "spawn_humans.dm"
|
|
#include "spawn_mobs.dm"
|
|
#include "species_config_sanity.dm"
|
|
#include "species_whitelists.dm"
|
|
#include "stomach.dm"
|
|
#include "strippable.dm"
|
|
#include "subsystem_init.dm"
|
|
#include "surgeries.dm"
|
|
#include "teleporters.dm"
|
|
#include "tgui_create_message.dm"
|
|
#include "timer_sanity.dm"
|
|
#include "unit_test.dm"
|
|
#include "wizard.dm"
|
|
#ifdef REFERENCE_TRACKING //Don't try and parse this file if ref tracking isn't turned on. IE: don't parse ref tracking please mr linter
|
|
#include "find_reference_sanity.dm"
|
|
#endif
|
|
|
|
#undef TEST_ASSERT
|
|
#undef TEST_ASSERT_EQUAL
|
|
#undef TEST_ASSERT_NOTEQUAL
|
|
#undef TEST_FOCUS
|
|
#endif
|