Files
Bubberstation/code/modules/unit_tests/breath.dm
LemonInTheDark dff635b7f6 Atmos init speedup, saves 4 seconds (#69697)
* Micro optimizes ssair's turf init, saving 2 seconds

Most of this is making existing operations do more legwork, or cheaper.
I did add cycle checking to ONLY init turf linking, which required
creating a new proc.
Did some horrible horrible things in said proc to save like 0.8 seconds.
I think it was worth it.
2022-09-06 02:53:46 -07:00

78 lines
3.1 KiB
Plaintext

/// Tests to make sure humans can breath in normal situations
/// Built to prevent regression on an issue surrounding QUANTIZE() and BREATH_VOLUME
/// See the comment on BREATH_VOLUME for more details
/datum/unit_test/breath_sanity
/datum/unit_test/breath_sanity/Run()
var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human)
var/obj/item/clothing/mask/breath/tube = allocate(/obj/item/clothing/mask/breath)
var/obj/item/tank/internals/emergency_oxygen/source = allocate(/obj/item/tank/internals/emergency_oxygen)
lab_rat.equip_to_slot_if_possible(tube, ITEM_SLOT_MASK)
lab_rat.equip_to_slot_if_possible(source, ITEM_SLOT_HANDS)
source.toggle_internals(lab_rat)
lab_rat.breathe()
TEST_ASSERT(!lab_rat.has_alert(ALERT_NOT_ENOUGH_OXYGEN), "Humans can't get a full breath from standard o2 tanks")
lab_rat.clear_alert(ALERT_NOT_ENOUGH_OXYGEN)
//Prep the mob
lab_rat.forceMove(run_loc_floor_bottom_left)
source.toggle_internals(lab_rat)
TEST_ASSERT(!lab_rat.internal, "toggle_internals() failed to toggle internals")
var/turf/open/to_fill = run_loc_floor_bottom_left
//Prep the floor
to_fill.initial_gas_mix = OPENTURF_DEFAULT_ATMOS
to_fill.air = to_fill.create_gas_mixture()
lab_rat.breathe()
TEST_ASSERT(!lab_rat.has_alert(ALERT_NOT_ENOUGH_OXYGEN), "Humans can't get a full breath from the standard initial_gas_mix on a turf")
/// Tests to make sure plasmaman can breath from their internal tanks
/datum/unit_test/breath_sanity_plasmamen
/datum/unit_test/breath_sanity_plasmamen/Run()
var/mob/living/carbon/human/species/plasma/lab_rat = allocate(/mob/living/carbon/human/species/plasma)
var/obj/item/clothing/mask/breath/tube = allocate(/obj/item/clothing/mask/breath)
var/obj/item/tank/internals/plasmaman/source = allocate(/obj/item/tank/internals/plasmaman)
lab_rat.equip_to_slot_if_possible(tube, ITEM_SLOT_MASK)
lab_rat.equip_to_slot_if_possible(source, ITEM_SLOT_HANDS)
source.toggle_internals(lab_rat)
lab_rat.breathe()
TEST_ASSERT(!lab_rat.has_alert(ALERT_NOT_ENOUGH_PLASMA), "Plasmamen can't get a full breath from a standard plasma tank")
lab_rat.clear_alert(ALERT_NOT_ENOUGH_PLASMA)
//Prep the mob
source.toggle_internals(lab_rat)
TEST_ASSERT(!lab_rat.internal, "Plasmaman toggle_internals() failed to toggle internals")
/// Tests to make sure ashwalkers can breath from the lavaland air
/datum/unit_test/breath_sanity_ashwalker
/datum/unit_test/breath_sanity_ashwalker/Run()
var/mob/living/carbon/human/species/lizard/ashwalker/lab_rat = allocate(/mob/living/carbon/human/species/lizard/ashwalker)
//Prep the mob
lab_rat.forceMove(run_loc_floor_bottom_left)
var/turf/open/to_fill = run_loc_floor_bottom_left
//Prep the floor
to_fill.initial_gas_mix = LAVALAND_DEFAULT_ATMOS
to_fill.air = to_fill.create_gas_mixture()
lab_rat.breathe()
TEST_ASSERT(!lab_rat.has_alert(ALERT_NOT_ENOUGH_OXYGEN), "Ashwalkers can't get a full breath from the Lavaland's initial_gas_mix on a turf")
/datum/unit_test/breath_sanity_ashwalker/Destroy()
//Reset initial_gas_mix to avoid future issues on other tests
var/turf/open/to_fill = run_loc_floor_bottom_left
to_fill.initial_gas_mix = OPENTURF_DEFAULT_ATMOS
return ..()