From ca02dc622be701528e0f8fb010241a5b1779ba4e Mon Sep 17 00:00:00 2001 From: Kylerace Date: Sat, 10 Jul 2021 17:40:53 -0700 Subject: [PATCH] fixes a connect_loc runtime related to abstract_move (#59969) --- code/game/atoms_movable.dm | 8 +++++-- code/modules/mob/dead/observer/observer.dm | 25 ++++++++++++---------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index dccba1b5b56..0eb631579bd 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -3,7 +3,7 @@ glide_size = 8 appearance_flags = TILE_BOUND|PIXEL_SCALE - ///how many times a this movable was moved since Moved() was last called + ///how many times a this movable had movement procs called on it since Moved() was last called var/move_stacks = 0 var/last_move = null var/last_move_time = 0 @@ -368,6 +368,7 @@ */ /atom/movable/proc/abstract_move(atom/new_loc) var/atom/old_loc = loc + move_stacks++ loc = new_loc Moved(old_loc) @@ -566,8 +567,11 @@ update_parallax_contents() move_stacks-- - if(move_stacks > 0) + if(move_stacks > 0) //we want only the first Moved() call in the stack to send this signal, all the other ones have an incorrect old_loc return + if(move_stacks < 0) + stack_trace("move_stacks is negative in Moved()!") + move_stacks = 0 //setting it to 0 so that we dont get every movable with negative move_stacks runtiming on every movement SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, old_loc, movement_dir, forced, old_locs) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index e6e850c754c..eb76d763b8d 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -329,7 +329,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp /mob/dead/observer/Move(NewLoc, direct, glide_size_override = 32) if(updatedir) setDir(direct)//only update dir if we actually need it, so overlays won't spin on base sprites that don't have directions of their own - var/oldloc = loc if(glide_size_override) set_glide_size(glide_size_override) @@ -337,17 +336,21 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp abstract_move(NewLoc) update_parallax_contents() else - abstract_move(get_turf(src)) //Get out of closets and such as a ghost - if((direct & NORTH) && y < world.maxy) - y++ - else if((direct & SOUTH) && y > 1) - y-- - if((direct & EAST) && x < world.maxx) - x++ - else if((direct & WEST) && x > 1) - x-- + var/turf/destination = get_turf(src) - Moved(oldloc, direct) + if((direct & NORTH) && y < world.maxy) + destination = get_step(destination, NORTH) + + else if((direct & SOUTH) && y > 1) + destination = get_step(destination, SOUTH) + + if((direct & EAST) && x < world.maxx) + destination = get_step(destination, EAST) + + else if((direct & WEST) && x > 1) + destination = get_step(destination, WEST) + + abstract_move(destination)//Get out of closets and such as a ghost /mob/dead/observer/forceMove(atom/destination) abstract_move(destination) // move like the wind