From 134f266f7870fdfdfdee277c36a319d27fff00b3 Mon Sep 17 00:00:00 2001 From: Rohesie Date: Sun, 27 Jun 2021 13:45:24 -0300 Subject: [PATCH] Document Moved() and forwards old_locs (#59819) - Passes the proper arguments on Moved(), forgot to do this on another PR. - Documents the proc better. - Cleans up code a little. --- code/game/atoms_movable.dm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 02954327742..2d30ad11f06 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -385,7 +385,7 @@ var/list/old_locs if(is_multi_tile_object && isturf(loc)) - old_locs = locs.Copy() + old_locs = locs // locs is a special list, this is effectively the same as .Copy() but with less steps for(var/atom/exiting_loc as anything in old_locs) if(!exiting_loc.Exit(src, direction)) return @@ -440,7 +440,7 @@ if(oldarea != newarea) newarea.Entered(src, direction) - Moved(oldloc, direction) + Moved(oldloc, direction, FALSE, old_locs) //////////////////////////////////////// @@ -542,13 +542,21 @@ if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc, direct, glide_size_override)) //movement failed due to buckled mob(s) return FALSE -//Called after a successful Move(). By this point, we've already moved -/atom/movable/proc/Moved(atom/OldLoc, Dir, Forced = FALSE) + +/** + * Called after a successful Move(). By this point, we've already moved. + * Arguments: + * * old_loc is the location prior to the move. Can be null to indicate nullspace. + * * movement_dir is the direction the movement took place. Can be NONE if it was some sort of teleport. + * * The forced flag indicates whether this was a forced move, which skips many checks of regular movement. + * * The old_locs is an optional argument, in case the moved movable was present in multiple locations before the movement. + **/ +/atom/movable/proc/Moved(atom/old_loc, movement_dir, forced = FALSE, list/old_locs) SHOULD_CALL_PARENT(TRUE) if (!inertia_moving) inertia_next_move = world.time + inertia_move_delay - newtonian_move(Dir) + newtonian_move(movement_dir) if (length(client_mobs_in_contents)) update_parallax_contents() @@ -556,7 +564,7 @@ if(move_stacks > 0) return - SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, OldLoc, Dir, Forced) + SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, old_loc, movement_dir, forced, old_locs) return TRUE