From bad30456a4bfa0e495d6cdaf1ecb02c2bb1f184d Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:46:02 -0700 Subject: [PATCH] Fixes deconstructing walls causing runtimes (#3398) ## About The Pull Request Fixes the while loops so they dont do silly shit and call procs on turfs they shouldnt. ## Why It's Good For The Game Kill 9 billion runtimes. ## Changelog :cl: fix: fixes wall deconstruction causing runtimes /:cl: --- .../game/mecha/equipment/tools/mining_tools.dm | 7 +++++-- code/game/objects/items.dm | 3 +++ code/game/turfs/closed/_closed.dm | 11 ++++++++--- code/game/turfs/closed/minerals.dm | 8 ++++++-- code/game/turfs/closed/wall/reinf_walls.dm | 3 ++- code/game/turfs/closed/walls.dm | 18 +++--------------- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/code/game/mecha/equipment/tools/mining_tools.dm b/code/game/mecha/equipment/tools/mining_tools.dm index e99d24e3f558..d330865a4be2 100644 --- a/code/game/mecha/equipment/tools/mining_tools.dm +++ b/code/game/mecha/equipment/tools/mining_tools.dm @@ -65,17 +65,20 @@ /turf/closed/wall/drill_act(obj/item/mecha_parts/mecha_equipment/drill/drill) while(drill.do_after_mecha(src, 15 / drill.drill_level)) drill.log_message("Drilled through [src]", LOG_MECHA) - alter_integrity(-drill.wall_decon_damage) drill.occupant_message("You drill through some of the outer plating...") playsound(src,'sound/weapons/drill.ogg',60,TRUE) + if(!alter_integrity(-drill.wall_decon_damage)) + return TRUE /turf/closed/wall/r_wall/drill_act(obj/item/mecha_parts/mecha_equipment/drill/drill) if(drill.drill_level >= DRILL_HARDENED) while(drill.do_after_mecha(src, 20 / drill.drill_level)) drill.log_message("Drilled through [src]", LOG_MECHA) - alter_integrity(-drill.wall_decon_damage) drill.occupant_message("You drill through some of the outer plating...") playsound(src,'sound/weapons/drill.ogg',60,TRUE) + if(!alter_integrity(-drill.wall_decon_damage)) + return TRUE + else drill.occupant_message("[src] is too durable to drill through.") diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 17d6cf96b21a..a1302008cf89 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -957,6 +957,9 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb /// Called when a mob tries to use the item as a tool.Handles most checks. /obj/item/proc/use_tool(atom/target, mob/living/user, delay, amount=0, volume=0, datum/callback/extra_checks) + // we have no target, why are we even doing this? + if(isnull(target)) + return // No delay means there is no start message, and no reason to call tool_start_check before use_tool. // Run the start check here so we wouldn't have to call it manually. if(!delay && !tool_start_check(user, amount)) diff --git a/code/game/turfs/closed/_closed.dm b/code/game/turfs/closed/_closed.dm index dc410d027504..766d7e0e5a24 100644 --- a/code/game/turfs/closed/_closed.dm +++ b/code/game/turfs/closed/_closed.dm @@ -227,6 +227,8 @@ return ..() /turf/closed/proc/attack_override(obj/item/W, mob/user, turf/loc) + if(!isclosedturf(src)) + return //the istype cascade has been spread among various procs for easy overriding or if we want to call something specific if(try_decon(W, user, loc) || try_destroy(W, user, loc)) return @@ -252,15 +254,18 @@ return TRUE /turf/closed/proc/try_decon(obj/item/I, mob/user, turf/T) + var/act_duration = breakdown_duration if(I.tool_behaviour == TOOL_WELDER) if(!I.tool_start_check(user, amount=0)) return FALSE - to_chat(user, "You begin slicing through the outer plating...") - while(I.use_tool(src, user, breakdown_duration, volume=50)) + while(I.use_tool(src, user, act_duration, volume=50)) if(iswallturf(src)) to_chat(user, "You slice through some of the outer plating...") - alter_integrity(-(I.wall_decon_damage),user,FALSE,TRUE) + if(!alter_integrity(-(I.wall_decon_damage),user,FALSE,TRUE)) + return TRUE + else + break return FALSE diff --git a/code/game/turfs/closed/minerals.dm b/code/game/turfs/closed/minerals.dm index 0d9b3205cc27..3970cc403d73 100644 --- a/code/game/turfs/closed/minerals.dm +++ b/code/game/turfs/closed/minerals.dm @@ -79,16 +79,20 @@ return ..() /turf/closed/mineral/try_decon(obj/item/I, mob/user, turf/T) + var/act_duration = breakdown_duration if(I.tool_behaviour == TOOL_MINING) if(!I.tool_start_check(user, amount=0)) return FALSE to_chat(user, "You begin breaking through the rock...") - while(I.use_tool(src, user, breakdown_duration, volume=50)) + while(I.use_tool(src, user, act_duration, volume=50)) if(ismineralturf(src)) to_chat(user, "You break through some of the stone...") SSblackbox.record_feedback("tally", "pick_used_mining", 1, I.type) - alter_integrity(-(I.wall_decon_damage),user,FALSE,TRUE) + if(!alter_integrity(-(I.wall_decon_damage),user,FALSE,TRUE)) + return TRUE + else + break return FALSE diff --git a/code/game/turfs/closed/wall/reinf_walls.dm b/code/game/turfs/closed/wall/reinf_walls.dm index ed2f0141eaff..c0fb9232ad28 100644 --- a/code/game/turfs/closed/wall/reinf_walls.dm +++ b/code/game/turfs/closed/wall/reinf_walls.dm @@ -78,7 +78,8 @@ to_chat(user, "You begin slicing through the [src].") while(W.use_tool(src,user,30,volume = 100)) to_chat(user, "You slice through some of the outer plating...") - alter_integrity(-(W.wall_decon_damage)) + if(!alter_integrity(-(W.wall_decon_damage))) + return TRUE return 1 switch(d_state) diff --git a/code/game/turfs/closed/walls.dm b/code/game/turfs/closed/walls.dm index bed648ff592b..1d8f242e216a 100644 --- a/code/game/turfs/closed/walls.dm +++ b/code/game/turfs/closed/walls.dm @@ -85,9 +85,10 @@ return null /turf/closed/wall/attack_override(obj/item/W, mob/user, turf/loc) - if(try_clean(W, user, loc) || try_wallmount(W, user, loc)) + if(!iswallturf(src)) + return + if(try_clean(W, user, loc) || try_wallmount(W, user, loc) || try_decon(W, user, loc) || try_destroy(W, user, loc)) return - ..() /turf/closed/wall/proc/try_clean(obj/item/W, mob/user, turf/T) if((user.a_intent != INTENT_HELP)) @@ -122,19 +123,6 @@ return FALSE -/turf/closed/wall/try_decon(obj/item/I, mob/user, turf/T) - if(I.tool_behaviour == TOOL_WELDER) - if(!I.tool_start_check(user, amount=0)) - return FALSE - - to_chat(user, "You begin slicing through the outer plating...") - while(I.use_tool(src, user, breakdown_duration, volume=50)) - if(iswallturf(src)) - to_chat(user, "You slice through some of the outer plating...") - alter_integrity(-(I.wall_decon_damage),FALSE,TRUE) - - return FALSE - /turf/closed/wall/singularity_pull(S, current_size) ..() wall_singularity_pull(current_size)