From d7e59f4c4b58427e06ef9a8526606f5d19108d13 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 04:31:24 -0400 Subject: [PATCH 01/14] movement info proof of concept --- code/__DEFINES/movement_info.dm | 18 ++++++++++++++++++ code/game/atoms_movable.dm | 15 ++++++++++----- daedalus.dme | 2 ++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 code/__DEFINES/movement_info.dm diff --git a/code/__DEFINES/movement_info.dm b/code/__DEFINES/movement_info.dm new file mode 100644 index 000000000000..c68eae07cdf6 --- /dev/null +++ b/code/__DEFINES/movement_info.dm @@ -0,0 +1,18 @@ +#define ACTIVE_MOVEMENT_OLDLOC 1 +#define ACTIVE_MOVEMENT_DIRECTION 2 +#define ACTIVE_MOVEMENT_FORCED 3 +#define ACTIVE_MOVEMENT_OLDLOCS 4 + +#define SET_active_movement(_old_loc, _direction, _forced, _oldlocs) \ + active_movement = list( \ + ACTIVE_MOVEMENT_OLDLOC = _old_loc, \ + ACTIVE_MOVEMENT_DIRECTION = _direction, \ + ACTIVE_MOVEMENT_FORCED = _forced, \ + ACTIVE_MOVEMENT_OLDLOCS = _oldlocs, \ + ) + +#define RESOLVE_ACTIVE_MOVEMENT \ + if(active_movement) { \ + Moved(arglist(active_movement)); \ + active_movement = null; \ + } diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index df7c6a25129b..09411bfb838f 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -5,6 +5,8 @@ /// The last direction we moved in. var/tmp/last_move = null + var/tmp/list/active_movement + ///Are we moving with inertia? Mostly used as an optimization var/tmp/inertia_moving = FALSE ///The last time we pushed off something @@ -325,6 +327,9 @@ if(!newloc || newloc == loc) return + // A mid-movement... movement... occured, resolve that first. + RESOLVE_ACTIVE_MOVEMENT + if(!direction) direction = get_dir(src, newloc) @@ -369,6 +374,7 @@ var/area/oldarea = get_area(oldloc) var/area/newarea = get_area(newloc) + SET_active_movement(oldloc, direction, FALSE, old_locs) loc = newloc . = TRUE @@ -386,13 +392,11 @@ entered_loc.Entered(src, oldloc, old_locs) else newloc.Entered(src, oldloc, old_locs) + if(oldarea != newarea) newarea.Entered(src, oldarea) - if(loc != newloc) // Something moved us out of where we just moved to, Abort!!! - return - - Moved(oldloc, direction, FALSE, old_locs) + RESOLVE_ACTIVE_MOVEMENT //////////////////////////////////////// @@ -830,6 +834,7 @@ moving_diagonally = 0 + SET_MOVEMENT_INFO(oldloc, NONE, TRUE, null) loc = destination if(!same_loc) @@ -879,7 +884,7 @@ if(old_area) old_area.Exited(src, NONE) - Moved(oldloc, NONE, TRUE) + RESOLVE_ACTIVE_MOVEMENT /** * Called when a movable changes z-levels. diff --git a/daedalus.dme b/daedalus.dme index 20a1ed09c8ea..0d29bae82317 100644 --- a/daedalus.dme +++ b/daedalus.dme @@ -143,6 +143,7 @@ #include "code\__DEFINES\monkeys.dm" #include "code\__DEFINES\move_force.dm" #include "code\__DEFINES\movement.dm" +#include "code\__DEFINES\movement_info.dm" #include "code\__DEFINES\movespeed_modification.dm" #include "code\__DEFINES\mutant_colors.dm" #include "code\__DEFINES\nitrile.dm" @@ -649,6 +650,7 @@ #include "code\datums\mind.dm" #include "code\datums\minigames_menu.dm" #include "code\datums\movement_detector.dm" +#include "code\datums\movement_information.dm" #include "code\datums\mutable_appearance.dm" #include "code\datums\numbered_display.dm" #include "code\datums\outfit.dm" From c3caa91163092210b717f86b3b291d61a22779f7 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 04:32:48 -0400 Subject: [PATCH 02/14] oop --- code/__DEFINES/movement_info.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/movement_info.dm b/code/__DEFINES/movement_info.dm index c68eae07cdf6..ca72b92c58d8 100644 --- a/code/__DEFINES/movement_info.dm +++ b/code/__DEFINES/movement_info.dm @@ -3,7 +3,7 @@ #define ACTIVE_MOVEMENT_FORCED 3 #define ACTIVE_MOVEMENT_OLDLOCS 4 -#define SET_active_movement(_old_loc, _direction, _forced, _oldlocs) \ +#define SET_ACTIVE_MOVEMENT(_old_loc, _direction, _forced, _oldlocs) \ active_movement = list( \ ACTIVE_MOVEMENT_OLDLOC = _old_loc, \ ACTIVE_MOVEMENT_DIRECTION = _direction, \ From 7296153d0f9db7983b1d71e48cb94bae588b91a0 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 04:32:58 -0400 Subject: [PATCH 03/14] oop2 --- code/game/atoms_movable.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 09411bfb838f..ef5c11e12890 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -374,7 +374,7 @@ var/area/oldarea = get_area(oldloc) var/area/newarea = get_area(newloc) - SET_active_movement(oldloc, direction, FALSE, old_locs) + SET_ACTIVE_MOVEMENT(oldloc, direction, FALSE, old_locs) loc = newloc . = TRUE From f089cb76b0ebbf05b9ada91725da0e9bfd199fd2 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:06:12 -0400 Subject: [PATCH 04/14] make compile --- code/__DEFINES/movement_info.dm | 8 ++++---- code/game/atoms_movable.dm | 2 +- daedalus.dme | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/movement_info.dm b/code/__DEFINES/movement_info.dm index ca72b92c58d8..a94cc20b7ec2 100644 --- a/code/__DEFINES/movement_info.dm +++ b/code/__DEFINES/movement_info.dm @@ -5,10 +5,10 @@ #define SET_ACTIVE_MOVEMENT(_old_loc, _direction, _forced, _oldlocs) \ active_movement = list( \ - ACTIVE_MOVEMENT_OLDLOC = _old_loc, \ - ACTIVE_MOVEMENT_DIRECTION = _direction, \ - ACTIVE_MOVEMENT_FORCED = _forced, \ - ACTIVE_MOVEMENT_OLDLOCS = _oldlocs, \ + _old_loc, \ + _direction, \ + _forced, \ + _oldlocs, \ ) #define RESOLVE_ACTIVE_MOVEMENT \ diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index ef5c11e12890..44038887a9f6 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -834,7 +834,7 @@ moving_diagonally = 0 - SET_MOVEMENT_INFO(oldloc, NONE, TRUE, null) + SET_ACTIVE_MOVEMENT(oldloc, NONE, TRUE, null) loc = destination if(!same_loc) diff --git a/daedalus.dme b/daedalus.dme index 0d29bae82317..2050c8304ac3 100644 --- a/daedalus.dme +++ b/daedalus.dme @@ -650,7 +650,6 @@ #include "code\datums\mind.dm" #include "code\datums\minigames_menu.dm" #include "code\datums\movement_detector.dm" -#include "code\datums\movement_information.dm" #include "code\datums\mutable_appearance.dm" #include "code\datums\numbered_display.dm" #include "code\datums\outfit.dm" From a7a39f248b855e3c6ebb45a1bdcddc5c160f1d56 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:08:42 -0400 Subject: [PATCH 05/14] nullspace movement --- code/game/atoms_movable.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 44038887a9f6..30f9ecc59871 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -873,6 +873,7 @@ . = TRUE if (oldloc) + SET_ACTIVE_MOVEMENT(oldloc, NONE, TRUE, null) loc = null var/area/old_area = get_area(oldloc) if(is_multi_tile && isturf(oldloc)) From 2e778b5553463b5f591918859a51dfc03e41ef9f Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:55:43 -0400 Subject: [PATCH 06/14] see if this works --- code/_compile_options.dm | 2 +- code/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/movement_order_sanity.dm | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 code/modules/unit_tests/movement_order_sanity.dm diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 749f4bddd68e..1cd49abe1b39 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -129,7 +129,7 @@ /////////////////////// UNIT TESTING -// #define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between +#define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between /////////////////////// AUTO WIKI diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 33176ef0d66e..00ebd84104b3 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -124,6 +124,7 @@ #include "mob_spawn.dm" #include "modsuit.dm" #include "modular_map_loader.dm" +#include "movement_order_sanity.dm" #include "novaflower_burn.dm" #include "objectives.dm" #include "outfit_sanity.dm" diff --git a/code/modules/unit_tests/movement_order_sanity.dm b/code/modules/unit_tests/movement_order_sanity.dm new file mode 100644 index 000000000000..975524d2731e --- /dev/null +++ b/code/modules/unit_tests/movement_order_sanity.dm @@ -0,0 +1,32 @@ +/datum/unit_test/movement_order_sanity/Run() + var/obj/movement_tester/test_obj = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + var/list/movement_cache = test_obj.movement_order + + TEST_ASSERT(length(movement_cache) == 4, "Movement order was not the expected value of 4, got: [length(movement_cache)].\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[3], "Moving from"),"Movement step 3 was a Move attempt.\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[4], "Moved from"),"Movement step 4 was not a Moved() call.\n[jointext(movement_cache, "\n")]") + +/obj/movement_tester + name = "movement debugger" + var/list/movement_order = list() + +/obj/movement_tester/Move(atom/newloc, direct, glide_size_override, z_movement_flags) + movement_order += "Moving from ([loc.x], [loc.y]) to [newloc ? "([newloc.x], [newloc.y])" : "NULL"]" + return ..() + +/obj/movement_tester/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change) + movement_order += "Moved from ([old_loc.x], [old_loc.y]) to [loc ? "([loc.x], [loc.y])" : "NULL"]" + return ..() + +/obj/movement_interceptor + name = "movement interceptor" + +/obj/movement_interceptor/Initialize(mapload) + . = ..() + AddElement(/datum/element/connect_loc, list(COMSIG_ATOM_ENTERED, PROC_REF(on_crossed))) + +/obj/movement_interceptor/proc/on_crossed(datum/source, atom/movable/arrived) + SIGNAL_HANDLER + qdel(arrived) From c3af8d1b7ae9caab251823443ed44e2f0d886f73 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:57:28 -0400 Subject: [PATCH 07/14] lol whoops --- code/modules/unit_tests/movement_order_sanity.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/modules/unit_tests/movement_order_sanity.dm b/code/modules/unit_tests/movement_order_sanity.dm index 975524d2731e..a3b607b95365 100644 --- a/code/modules/unit_tests/movement_order_sanity.dm +++ b/code/modules/unit_tests/movement_order_sanity.dm @@ -2,6 +2,10 @@ var/obj/movement_tester/test_obj = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) var/list/movement_cache = test_obj.movement_order + var/obj/movement_interceptor = allocate(__IMPLIED_TYPE__, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + + step(test_obj, EAST) + TEST_ASSERT(length(movement_cache) == 4, "Movement order was not the expected value of 4, got: [length(movement_cache)].\n[jointext(movement_cache, "\n")]") TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\n[jointext(movement_cache, "\n")]") TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\n[jointext(movement_cache, "\n")]") From 679791d791e0ada146f68f9975c2471db916cf07 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:57:49 -0400 Subject: [PATCH 08/14] undef unit tests --- code/_compile_options.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 1cd49abe1b39..749f4bddd68e 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -129,7 +129,7 @@ /////////////////////// UNIT TESTING -#define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between +// #define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between /////////////////////// AUTO WIKI From d03619a17920d740e0c376c90e691c515d8876be Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:03:09 -0400 Subject: [PATCH 09/14] fuc --- code/modules/unit_tests/movement_order_sanity.dm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/modules/unit_tests/movement_order_sanity.dm b/code/modules/unit_tests/movement_order_sanity.dm index a3b607b95365..03e4af77a1c7 100644 --- a/code/modules/unit_tests/movement_order_sanity.dm +++ b/code/modules/unit_tests/movement_order_sanity.dm @@ -6,11 +6,11 @@ step(test_obj, EAST) - TEST_ASSERT(length(movement_cache) == 4, "Movement order was not the expected value of 4, got: [length(movement_cache)].\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[3], "Moving from"),"Movement step 3 was a Move attempt.\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[4], "Moved from"),"Movement step 4 was not a Moved() call.\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(length(movement_cache) == 4, "Movement order was not the expected value of 4, got: [length(movement_cache)].\nMovement Log[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\nMovement Log[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\nMovement Log[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[3], "Moving from"),"Movement step 3 was a Move attempt.\nMovement Log[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[4], "Moved from"),"Movement step 4 was not a Moved() call.\nMovement Log[jointext(movement_cache, "\n")]") /obj/movement_tester name = "movement debugger" @@ -29,7 +29,7 @@ /obj/movement_interceptor/Initialize(mapload) . = ..() - AddElement(/datum/element/connect_loc, list(COMSIG_ATOM_ENTERED, PROC_REF(on_crossed))) + AddElement(/datum/element/connect_loc, list(COMSIG_ATOM_ENTERED = PROC_REF(on_crossed))) /obj/movement_interceptor/proc/on_crossed(datum/source, atom/movable/arrived) SIGNAL_HANDLER From 5d90698ad3950c32b9f805c5a46561dabb3919c3 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:38:29 -0400 Subject: [PATCH 10/14] fixes --- code/game/atoms_movable.dm | 3 +-- .../unit_tests/movement_order_sanity.dm | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 30f9ecc59871..0ec05a09175a 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -826,6 +826,7 @@ var/atom/oldloc = loc var/is_multi_tile = bound_width > world.icon_size || bound_height > world.icon_size + SET_ACTIVE_MOVEMENT(oldloc, NONE, TRUE, null) if(destination) var/same_loc = oldloc == destination var/area/old_area = get_area(oldloc) @@ -834,7 +835,6 @@ moving_diagonally = 0 - SET_ACTIVE_MOVEMENT(oldloc, NONE, TRUE, null) loc = destination if(!same_loc) @@ -873,7 +873,6 @@ . = TRUE if (oldloc) - SET_ACTIVE_MOVEMENT(oldloc, NONE, TRUE, null) loc = null var/area/old_area = get_area(oldloc) if(is_multi_tile && isturf(oldloc)) diff --git a/code/modules/unit_tests/movement_order_sanity.dm b/code/modules/unit_tests/movement_order_sanity.dm index 03e4af77a1c7..8ab05782c85c 100644 --- a/code/modules/unit_tests/movement_order_sanity.dm +++ b/code/modules/unit_tests/movement_order_sanity.dm @@ -2,15 +2,19 @@ var/obj/movement_tester/test_obj = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) var/list/movement_cache = test_obj.movement_order - var/obj/movement_interceptor = allocate(__IMPLIED_TYPE__, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + var/obj/movement_interceptor/interceptor = allocate(__IMPLIED_TYPE__) + interceptor.forceMove(locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) - step(test_obj, EAST) + var/did_move = step(test_obj, EAST) - TEST_ASSERT(length(movement_cache) == 4, "Movement order was not the expected value of 4, got: [length(movement_cache)].\nMovement Log[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\nMovement Log[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\nMovement Log[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[3], "Moving from"),"Movement step 3 was a Move attempt.\nMovement Log[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[4], "Moved from"),"Movement step 4 was not a Moved() call.\nMovement Log[jointext(movement_cache, "\n")]") + TEST_ASSERT(did_move, "Object did not move at all.") + TEST_ASSERT(QDELETED(test_obj), "Object was not qdeleted.") + TEST_ASSERT(length(movement_cache) == 4, "Movement order length was not the expected value of 4, got: [length(movement_cache)].\nMovement Log\n[jointext(movement_cache, "\n")]") + + TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\nMovement Log\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[3], "Moving from"),"Movement step 3 was a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[4], "Moved from"),"Movement step 4 was not a Moved() call.\nMovement Log\n[jointext(movement_cache, "\n")]") /obj/movement_tester name = "movement debugger" @@ -20,6 +24,10 @@ movement_order += "Moving from ([loc.x], [loc.y]) to [newloc ? "([newloc.x], [newloc.y])" : "NULL"]" return ..() +/obj/movement_tester/doMove(atom/destination) + movement_order += "Abstractly Moving from ([loc.x], [loc.y]) to [destination ? "([destination.x], [destination.y])" : "NULL"]" + return ..() + /obj/movement_tester/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change) movement_order += "Moved from ([old_loc.x], [old_loc.y]) to [loc ? "([loc.x], [loc.y])" : "NULL"]" return ..() @@ -33,4 +41,7 @@ /obj/movement_interceptor/proc/on_crossed(datum/source, atom/movable/arrived) SIGNAL_HANDLER + if(src == arrived) + return + qdel(arrived) From 47e70213969295776a26fa5d651af4e6830cd589 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:43:37 -0400 Subject: [PATCH 11/14] fix --- code/game/atoms_movable.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 0ec05a09175a..51c7c79a65bd 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -823,6 +823,8 @@ /atom/movable/proc/doMove(atom/destination) . = FALSE + RESOLVE_ACTIVE_MOVEMENT + var/atom/oldloc = loc var/is_multi_tile = bound_width > world.icon_size || bound_height > world.icon_size From ce6bd2665f1d3b5453c9d2bdd5fcee0f701cc036 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:50:02 -0400 Subject: [PATCH 12/14] fix --- code/modules/unit_tests/movement_order_sanity.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/unit_tests/movement_order_sanity.dm b/code/modules/unit_tests/movement_order_sanity.dm index 8ab05782c85c..07904340bcff 100644 --- a/code/modules/unit_tests/movement_order_sanity.dm +++ b/code/modules/unit_tests/movement_order_sanity.dm @@ -11,9 +11,9 @@ TEST_ASSERT(QDELETED(test_obj), "Object was not qdeleted.") TEST_ASSERT(length(movement_cache) == 4, "Movement order length was not the expected value of 4, got: [length(movement_cache)].\nMovement Log\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement did not begin with a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[2], "Moved from"),"Movement step 2 was not a Moved() call.\nMovement Log\n[jointext(movement_cache, "\n")]") - TEST_ASSERT(findtext(movement_cache[3], "Moving from"),"Movement step 3 was a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement step 1 was not a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[2], "Moving from"),"Movement step 2 was not a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") + TEST_ASSERT(findtext(movement_cache[3], "Moved from"),"Movement step 3 was not a Moved() call.\nMovement Log\n[jointext(movement_cache, "\n")]") TEST_ASSERT(findtext(movement_cache[4], "Moved from"),"Movement step 4 was not a Moved() call.\nMovement Log\n[jointext(movement_cache, "\n")]") /obj/movement_tester From f98b0f330e44464bb3071a20221e2d6ddb846966 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:52:22 -0400 Subject: [PATCH 13/14] comments --- code/modules/unit_tests/movement_order_sanity.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/modules/unit_tests/movement_order_sanity.dm b/code/modules/unit_tests/movement_order_sanity.dm index 07904340bcff..a9f677b24980 100644 --- a/code/modules/unit_tests/movement_order_sanity.dm +++ b/code/modules/unit_tests/movement_order_sanity.dm @@ -11,6 +11,8 @@ TEST_ASSERT(QDELETED(test_obj), "Object was not qdeleted.") TEST_ASSERT(length(movement_cache) == 4, "Movement order length was not the expected value of 4, got: [length(movement_cache)].\nMovement Log\n[jointext(movement_cache, "\n")]") + // Due to when the logging takes place, it will always be Move Move > Moved Moved instead of the reality of + // Move > Moved > Move > Moved TEST_ASSERT(findtext(movement_cache[1], "Moving from"),"Movement step 1 was not a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") TEST_ASSERT(findtext(movement_cache[2], "Moving from"),"Movement step 2 was not a Move attempt.\nMovement Log\n[jointext(movement_cache, "\n")]") TEST_ASSERT(findtext(movement_cache[3], "Moved from"),"Movement step 3 was not a Moved() call.\nMovement Log\n[jointext(movement_cache, "\n")]") From f34ace6815831285cd0e14193a1be749a5b68b75 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Sat, 23 Mar 2024 02:49:48 -0400 Subject: [PATCH 14/14] fixes --- code/__DEFINES/movement_info.dm | 4 +++- code/game/atoms_movable.dm | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/movement_info.dm b/code/__DEFINES/movement_info.dm index a94cc20b7ec2..dc17f095c617 100644 --- a/code/__DEFINES/movement_info.dm +++ b/code/__DEFINES/movement_info.dm @@ -11,8 +11,10 @@ _oldlocs, \ ) +/// Finish any active movements #define RESOLVE_ACTIVE_MOVEMENT \ if(active_movement) { \ - Moved(arglist(active_movement)); \ + var/__move_args = active_movement; \ active_movement = null; \ + Moved(arglist(__move_args)); \ } diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 9addad10f88a..ab2c9fb5b33d 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -312,6 +312,8 @@ if(QDELING(src)) CRASH("Illegal abstract_move() on [type]!") + RESOLVE_ACTIVE_MOVEMENT + var/atom/old_loc = loc var/direction = get_dir(old_loc, new_loc) loc = new_loc