Skip to content

Commit

Permalink
Fixes deconstructing walls causing runtimes (#3398)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

Fixes the while loops so they dont do silly shit and call procs on turfs
they shouldnt.

## Why It's Good For The Game

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

Kill 9 billion runtimes.

## Changelog

:cl:
fix: fixes wall deconstruction causing runtimes
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Gristlebee authored Sep 25, 2024
1 parent 053a7ba commit bad3045
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
7 changes: 5 additions & 2 deletions code/game/mecha/equipment/tools/mining_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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("<span class='notice'>You drill through some of the outer plating...</span>")
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("<span class='notice'>You drill through some of the outer plating...</span>")
playsound(src,'sound/weapons/drill.ogg',60,TRUE)
if(!alter_integrity(-drill.wall_decon_damage))
return TRUE

else
drill.occupant_message("<span class='danger'>[src] is too durable to drill through.</span>")

Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 8 additions & 3 deletions code/game/turfs/closed/_closed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, "<span class='notice'>You begin slicing through the outer plating...</span>")
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, "<span class='notice'>You slice through some of the outer plating...</span>")
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

Expand Down
8 changes: 6 additions & 2 deletions code/game/turfs/closed/minerals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<span class='notice'>You begin breaking through the rock...</span>")
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, "<span class='notice'>You break through some of the stone...</span>")
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

Expand Down
3 changes: 2 additions & 1 deletion code/game/turfs/closed/wall/reinf_walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
to_chat(user, "<span class='notice'>You begin slicing through the [src].</span>")
while(W.use_tool(src,user,30,volume = 100))
to_chat(user, "<span class='notice'>You slice through some of the outer plating...</span>")
alter_integrity(-(W.wall_decon_damage))
if(!alter_integrity(-(W.wall_decon_damage)))
return TRUE
return 1

switch(d_state)
Expand Down
18 changes: 3 additions & 15 deletions code/game/turfs/closed/walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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, "<span class='notice'>You begin slicing through the outer plating...</span>")
while(I.use_tool(src, user, breakdown_duration, volume=50))
if(iswallturf(src))
to_chat(user, "<span class='notice'>You slice through some of the outer plating...</span>")
alter_integrity(-(I.wall_decon_damage),FALSE,TRUE)

return FALSE

/turf/closed/wall/singularity_pull(S, current_size)
..()
wall_singularity_pull(current_size)
Expand Down

0 comments on commit bad3045

Please sign in to comment.