mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 15:47:15 +01:00
[MIRROR] Frame stacking fix and unit test addition. (#2833)
* Frame stacking fix and unit test addition. (#56287) * Reverts #56205 * Allow things without density to bypass checks * The rest of the owl * The rest of the owl * Doc and tweak * More feex * RCD machine frame unit test * I suck * AAAAA * Bad at unit tests * Revert unit tests (for including in another PR) * Fix windoor_assembly return logic * Comment /mob/living/proc/PushAM logic * Windoor assembley logic tweak * Fix frame stacking * Unit test * Better wording from macros? * Frame stacking fix and unit test addition. Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
This commit is contained in:
@@ -221,13 +221,23 @@
|
||||
if(!client && (mob_size < MOB_SIZE_SMALL))
|
||||
return
|
||||
now_pushing = TRUE
|
||||
var/t = get_dir(src, AM)
|
||||
var/dir_to_target = get_dir(src, AM)
|
||||
|
||||
// If there's no dir_to_target then the player is on the same turf as the atom they're trying to push.
|
||||
// This can happen when a player is stood on the same turf as a directional window. All attempts to push
|
||||
// the window will fail as get_dir will return 0 and the player will be unable to move the window when
|
||||
// it should be pushable.
|
||||
// In this scenario, we will use the facing direction of the /mob/living attempting to push the atom as
|
||||
// a fallback.
|
||||
if(!dir_to_target)
|
||||
dir_to_target = dir
|
||||
|
||||
var/push_anchored = FALSE
|
||||
if((AM.move_resist * MOVE_FORCE_CRUSH_RATIO) <= force)
|
||||
if(move_crush(AM, move_force, t))
|
||||
if(move_crush(AM, move_force, dir_to_target))
|
||||
push_anchored = TRUE
|
||||
if((AM.move_resist * MOVE_FORCE_FORCEPUSH_RATIO) <= force) //trigger move_crush and/or force_push regardless of if we can push it normally
|
||||
if(force_push(AM, move_force, t, push_anchored))
|
||||
if(force_push(AM, move_force, dir_to_target, push_anchored))
|
||||
push_anchored = TRUE
|
||||
if((AM.anchored && !push_anchored) || (force < (AM.move_resist * MOVE_FORCE_PUSH_RATIO)))
|
||||
now_pushing = FALSE
|
||||
@@ -235,7 +245,7 @@
|
||||
if (istype(AM, /obj/structure/window))
|
||||
var/obj/structure/window/W = AM
|
||||
if(W.fulltile)
|
||||
for(var/obj/structure/window/win in get_step(W,t))
|
||||
for(var/obj/structure/window/win in get_step(W, dir_to_target))
|
||||
now_pushing = FALSE
|
||||
return
|
||||
if(pulling == AM)
|
||||
@@ -243,8 +253,8 @@
|
||||
var/current_dir
|
||||
if(isliving(AM))
|
||||
current_dir = AM.dir
|
||||
if(AM.Move(get_step(AM.loc, t), t, glide_size))
|
||||
Move(get_step(loc, t), t)
|
||||
if(AM.Move(get_step(AM.loc, dir_to_target), dir_to_target, glide_size))
|
||||
Move(get_step(loc, dir_to_target), dir_to_target)
|
||||
if(current_dir)
|
||||
AM.setDir(current_dir)
|
||||
now_pushing = FALSE
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
circuit = /obj/item/circuitboard/machine/reagentgrinder
|
||||
pass_flags = PASSTABLE
|
||||
resistance_flags = ACID_PROOF
|
||||
anchorables = list(/obj/structure/table)
|
||||
var/operating = FALSE
|
||||
var/obj/item/reagent_containers/beaker = null
|
||||
var/limit = 10
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "pills.dm"
|
||||
#include "plantgrowth_tests.dm"
|
||||
#include "projectiles.dm"
|
||||
#include "rcd.dm"
|
||||
#include "reagent_id_typos.dm"
|
||||
#include "reagent_mod_expose.dm"
|
||||
#include "reagent_mod_procs.dm"
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Simple unit test to ensure there's no regression in behaviour where machine frames should not be stacked.
|
||||
*
|
||||
* We attempt to use the RCD to build multiple stacked machine frames on a turf. If we end up with any number that
|
||||
* is not equal to 1, this means we've either built no machine frames (bad) or built more than one (regression).
|
||||
*
|
||||
* If this is successful, we attempt to spawn in some no-density machines that result in machine frames and we run
|
||||
* the test again on our turf containing our single frame, deconstructing the machines! This should also not spawn
|
||||
* any stacked machine frames.
|
||||
*/
|
||||
/datum/unit_test/frame_stacking/Run()
|
||||
// First test - RCDs stacking frames.
|
||||
var/obj/item/construction/rcd/rcd = allocate(/obj/item/construction/rcd/combat/admin)
|
||||
var/mob/living/carbon/human/engineer = allocate(/mob/living/carbon/human)
|
||||
|
||||
engineer.put_in_hands(rcd, forced = TRUE)
|
||||
|
||||
rcd.mode = RCD_MACHINE
|
||||
|
||||
var/list/adjacent_turfs = get_adjacent_open_turfs(engineer)
|
||||
|
||||
if(!length(adjacent_turfs))
|
||||
Fail("RCD Test failed - Lack of adjacent open turfs. This may be an issue with the unit test.")
|
||||
|
||||
var/turf/adjacent_turf = adjacent_turfs[1]
|
||||
|
||||
for(var/i in 1 to 10)
|
||||
adjacent_turf.rcd_act(engineer, rcd, rcd.mode)
|
||||
|
||||
var/frame_count = 0
|
||||
for(var/obj/structure/frame/machine_frame in adjacent_turf.contents)
|
||||
frame_count++
|
||||
|
||||
TEST_ASSERT_EQUAL(frame_count, 1, "Expected RCD machine frame stacking test to end up with exactly 1 machine frame.")
|
||||
|
||||
// Second test - Deconstructing stacked machines to stack frames. We'll recycle our old turf to accomplish this.
|
||||
for(var/i in 1 to 10)
|
||||
// This should be a type path to a machine with no density, that can be wrenched on a turf with another machine of the same type.
|
||||
var/obj/machinery/new_machine = new /obj/machinery/recharger(adjacent_turf)
|
||||
new_machine.deconstruct(TRUE)
|
||||
|
||||
frame_count = 0
|
||||
for(var/obj/structure/frame/machine_frame in adjacent_turf.contents)
|
||||
frame_count++
|
||||
|
||||
TEST_ASSERT_EQUAL(frame_count, 1, "Expected no density machine deconstruction frame stacking test to end up with exactly 1 machine frame.")
|
||||
Reference in New Issue
Block a user