From 41cd5a43c74c799091db185eeaa4ecca230e204d Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Sat, 3 Dec 2022 21:38:12 -0800 Subject: [PATCH] Fixes random failure in cleanbot pathing (#71660) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About The Pull Request Ok so like, it used to be we would hand back our path immediately after get_path_to What's happening now is the path is completed, and THEN we have to wait a tick before getting it back So between the path finishing and our UNTIL resuming, our mob could be deleted This resolves that issue, wrapping the UNTIL in some qdeleted checks to return a failure response ## Why It's Good For The Game Fixes #71628. Also fixes #71493, ~~quit using = to set the path it's a setter for a reason 🗞️~~ I FUCKED UP JPS SHOULD RETURN AN EMPTY LIST ON FAILURE NOT NULL --- code/__HELPERS/path.dm | 6 +++--- code/modules/mob/living/simple_animal/bot/bot.dm | 2 +- code/modules/mob/living/simple_animal/bot/cleanbot.dm | 1 - code/modules/mob/living/simple_animal/parrot.dm | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/__HELPERS/path.dm b/code/__HELPERS/path.dm index 08280617e97..09c1e882f4e 100644 --- a/code/__HELPERS/path.dm +++ b/code/__HELPERS/path.dm @@ -25,11 +25,11 @@ // We're guarenteed that list will be the first list in pathfinding_finished's argset because of how callback handles the arguments list var/datum/callback/await = CALLBACK(GLOBAL_PROC, /proc/pathfinding_finished, path) if(!SSpathfinder.pathfind(caller, end, max_distance, mintargetdist, id, simulated_only, exclude, skip_first, diagonal_safety, await)) - return null + return list() UNTIL(length(path)) - if(length(path) == 1 && path[1] == null) // It's trash, just hand back null to make it easy - return null + if(length(path) == 1 && path[1] == null || (QDELETED(caller) || QDELETED(end))) // It's trash, just hand back null to make it easy + return list() return path /// Uses funny pass by reference bullshit to take the path created by pathfinding, and insert it into a return list diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index cb18ffe6be6..337af357340 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -1039,7 +1039,7 @@ Pass a positive integer as an argument to override a bot's default speed. var/list/path_images = active_hud_list[DIAG_PATH_HUD] QDEL_LIST(path_images) - if(newpath) + if(length(newpath)) var/mutable_appearance/path_image = new /mutable_appearance() path_image.icon = path_image_icon path_image.icon_state = path_image_icon_state diff --git a/code/modules/mob/living/simple_animal/bot/cleanbot.dm b/code/modules/mob/living/simple_animal/bot/cleanbot.dm index 16320948900..6b7484cbc4c 100644 --- a/code/modules/mob/living/simple_animal/bot/cleanbot.dm +++ b/code/modules/mob/living/simple_animal/bot/cleanbot.dm @@ -298,7 +298,6 @@ if(length(path) == 0) add_to_ignore(target) target = null - path = list() if(path.len > 0 && target) if(!bot_move(path[path.len])) diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index 66462edc785..d0770841ab2 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -654,7 +654,7 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list( item = I break if(item) - if(!get_path_to(src, item)) // WHY DO WE DISREGARD THE PATH AHHHHHH + if(!length(get_path_to(src, item))) // WHY DO WE DISREGARD THE PATH AHHHHHH item = null continue return item