From 78cc6031878fe54a488b769b2e33132eb9ecebb9 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 19 Jan 2023 21:27:26 +0100 Subject: [PATCH] [MIRROR] Fixes strange geyser and geyser regen [MDB IGNORE] (#18808) Fixes strange geyser and geyser regen (#72221) Called the random reagent code after it was initialized Registered the reagent del/remove signal on the geyser, not the reagent datum of the geyser Closes #72037 :cl: fix: Strange geysers have random reagents again fix: Geysers regen reagents again /:cl: Co-authored-by: Time-Green --- .../objects/structures/lavaland/geyser.dm | 6 ++--- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/geyser.dm | 24 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 code/modules/unit_tests/geyser.dm diff --git a/code/game/objects/structures/lavaland/geyser.dm b/code/game/objects/structures/lavaland/geyser.dm index 4077238e409..cd556a79165 100644 --- a/code/game/objects/structures/lavaland/geyser.dm +++ b/code/game/objects/structures/lavaland/geyser.dm @@ -34,7 +34,7 @@ create_reagents(max_volume, DRAINABLE) reagents.add_reagent(reagent_id, max_volume) - RegisterSignals(src, list(COMSIG_REAGENTS_REM_REAGENT, COMSIG_REAGENTS_DEL_REAGENT), PROC_REF(start_chemming)) + RegisterSignals(reagents, list(COMSIG_REAGENTS_REM_REAGENT, COMSIG_REAGENTS_DEL_REAGENT), PROC_REF(start_chemming)) if(erupting_state) icon_state = erupting_state @@ -43,7 +43,6 @@ I.color = mix_color_from_reagents(reagents.reagent_list) add_overlay(I) - ///start making those CHHHHHEEEEEEMS. Called whenever chems are removed, it's fine because START_PROCESSING checks if we arent already processing /obj/structure/geyser/proc/start_chemming() START_PROCESSING(SSplumbing, src) //It's main function is to be plumbed, so use SSplumbing @@ -109,9 +108,10 @@ discovery_message = "It's a strange geyser! How does any of this even work?" //it doesnt /obj/structure/geyser/random/Initialize(mapload) - . = ..() reagent_id = get_random_reagent_id() + return ..() + ///A wearable tool that lets you empty plumbing machinery and some other stuff /obj/item/plunger name = "plunger" diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index c845423351b..be03c3c21f1 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -116,6 +116,7 @@ #include "food_edibility_check.dm" #include "gas_transfer.dm" #include "get_turf_pixel.dm" +#include "geyser.dm" #include "greyscale_config.dm" #include "hallucination_icons.dm" #include "heretic_knowledge.dm" diff --git a/code/modules/unit_tests/geyser.dm b/code/modules/unit_tests/geyser.dm new file mode 100644 index 00000000000..bdbaf9cc189 --- /dev/null +++ b/code/modules/unit_tests/geyser.dm @@ -0,0 +1,24 @@ +///Geysers listen to reagent signals to know when to start processing, which is very cool, smart, optimized and fragile +///Tests: +/// Check for reagent datum +/// Check if our geyser starts with the right reagent +/// Check if our geyser refills (by clearing the reagents, setting refresh rate to max and manually firing the subsystem) +/// Check if our geyser refilled with the right reagent +/datum/unit_test/geyser + +/datum/unit_test/geyser/Run() + //While we're at it just check em all + var/list/geysers = subtypesof(/obj/structure/geyser) + for(var/geyser_type as anything in geysers) + var/obj/structure/geyser/wittel/geyser = allocate(geyser_type) + geyser.potency = geyser.max_volume //make it recharge in 1 tick + + TEST_ASSERT(geyser.reagents, "Geyser does not have a reagent datum! Source: [geyser.type]") + TEST_ASSERT(geyser.reagents.has_reagent(geyser.reagent_id), "Geyser should start with [geyser.reagent_id], but started with [geyser.reagents.get_reagent_log_string()] instead. Source: [geyser.type]") + + geyser.reagents.clear_reagents() //this should awaken the geyser to start refilling + + SSplumbing.fire() //fire the subsystem, which calls process on the geyser which should refill it + + TEST_ASSERT(geyser.reagents.total_volume == geyser.max_volume, "Geyser is not refilling! Current volume: [geyser.reagents.total_volume]. Target volume: [geyser.max_volume]. Source: [geyser.type]") + TEST_ASSERT(geyser.reagents.has_reagent(geyser.reagent_id), "Geyser should produce [geyser.reagent_id], produced [geyser.reagents.get_reagent_log_string()] instead. Source: [geyser.type]")