Fixes footprint stacking (#58918)

* Fixes footprint stacking, replace_decal needed to return parent, and just, didn't. I'm not sure where the fuck
this came from, or even how to test for it, but here you are

* Adds a unit test to prevent regressions on this error in future

* Uses TEST_ASSERT_EQUAL instead of TEST_ASSERT

Thank you moth man

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>

* Updates a comment to more accurately describe my pain

* maybe fixes it?

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
LemonInTheDark
2021-05-14 13:58:19 -07:00
committed by GitHub
parent c0799a0593
commit 356afaa40d
5 changed files with 66 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/testroom
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
name = "Test Room"
icon_state = "storage"

View File

@@ -288,8 +288,8 @@
/obj/effect/decal/cleanable/blood/footprints/replace_decal(obj/effect/decal/cleanable/C)
if(blood_state != C.blood_state) //We only replace footprints of the same type as us
return
..()
return FALSE
return ..()
/obj/effect/decal/cleanable/blood/footprints/can_bloodcrawl_in()
if((blood_state != BLOOD_STATE_OIL) && (blood_state != BLOOD_STATE_NOT_BLOODY))

View File

@@ -43,6 +43,7 @@
#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"

View File

@@ -0,0 +1,61 @@
///Tests to make sure bloody footprits work as expected
///So no stacking, they actually apply, and shoe staining thrown in for free
/datum/unit_test/bloody_footprints
/datum/unit_test/bloody_footprints/Run()
var/mob/living/carbon/human/blood_master = allocate(/mob/living/carbon/human)
var/obj/item/clothing/shoes/holds_blood = allocate(/obj/item/clothing/shoes)
blood_master.equip_to_slot_if_possible(holds_blood, ITEM_SLOT_FEET)
var/turf/open/move_to = get_step(blood_master, get_dir(blood_master, run_loc_floor_top_right))
//We need to not be "on" the same tile as the pool
blood_master.forceMove(move_to)
var/obj/effect/decal/cleanable/blood/pool = allocate(/obj/effect/decal/cleanable/blood)
//Max out the pools blood, so each step will make things stained enough to matter
pool.bloodiness = BLOOD_POOL_MAX
pool.forceMove(run_loc_floor_bottom_left)
blood_master.forceMove(run_loc_floor_bottom_left)
var/datum/component/bloodysoles/soles = holds_blood.GetComponent(/datum/component/bloodysoles)
var/blood_type = pool.blood_state
TEST_ASSERT(soles.bloody_shoes[blood_type], "Shoes didn't become stained after stepping in a pool of [blood_type]")
//The bloody soles component handles the order of stepping on blood/stepping on a bloody tile in a constranating way
//Which means it needs to check and see if any time has passed between steps, so it can be sure the player is stepping onto a new tile (that should become bloody)
//I on the other hand need to do all my movements in one tick, so we need to sidestep this check
//Please kill me slowly
soles.last_pickup -= 1
//Move off the bloody tile, time to do some testing
blood_master.forceMove(move_to)
soles.last_pickup -= 1
blood_master.forceMove(run_loc_floor_bottom_left)
var/footprint_total = 0
for(var/obj/effect/decal/cleanable/blood/footprints/print_set in move_to)
if(print_set.blood_state == blood_type)
footprint_total += 1
TEST_ASSERT(footprint_total, "The floor didn't get covered in [blood_type] after being walked over")
soles.last_pickup -= 1
//Another set of movements to try and make some doubled up prints
blood_master.forceMove(move_to)
soles.last_pickup -= 1
blood_master.forceMove(run_loc_floor_bottom_left)
footprint_total = 0
for(var/obj/effect/decal/cleanable/blood/footprints/print_set in move_to)
if(print_set.blood_state == blood_type)
footprint_total += 1
TEST_ASSERT(footprint_total, "The floor somehow lost its footprints after being walked over")
TEST_ASSERT_EQUAL(footprint_total, 1, "The floor had more than one set of footprints in it, something is fucked")

View File

@@ -50,7 +50,7 @@ GLOBAL_VAR(test_log)
// clear the test area
for (var/turf/turf in block(locate(1, 1, run_loc_floor_bottom_left.z), locate(world.maxx, world.maxy, run_loc_floor_bottom_left.z)))
for (var/content in turf.contents)
if (iseffect(content))
if (istype(content, /obj/effect/landmark))
continue
qdel(content)
return ..()