From dcb4d43e5cf648230ab701846e659734f670c680 Mon Sep 17 00:00:00 2001
From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Date: Wed, 13 Jul 2022 19:22:45 -0400
Subject: [PATCH] Fixes Improper usage of tool_use_check proc (#18362)
* fix
* better implementation
---
code/game/objects/items/tools/tool_behaviour.dm | 2 +-
code/game/objects/items/tools/welder.dm | 8 +++++---
code/modules/mob/living/living.dm | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/code/game/objects/items/tools/tool_behaviour.dm b/code/game/objects/items/tools/tool_behaviour.dm
index 8770c1d6383..61c7cc58aab 100644
--- a/code/game/objects/items/tools/tool_behaviour.dm
+++ b/code/game/objects/items/tools/tool_behaviour.dm
@@ -43,7 +43,7 @@
return tool_use_check(user, amount)
// A check called by tool_start_check once, and by use_tool on every tick of delay.
-/obj/item/proc/tool_use_check(mob/living/user, amount)
+/obj/item/proc/tool_use_check(mob/living/user, amount, silent = FALSE)
return !amount
/obj/item/proc/play_tool_sound(atom/target, volume = tool_volume)
diff --git a/code/game/objects/items/tools/welder.dm b/code/game/objects/items/tools/welder.dm
index 76d72e0769b..aab2826e46d 100644
--- a/code/game/objects/items/tools/welder.dm
+++ b/code/game/objects/items/tools/welder.dm
@@ -107,14 +107,16 @@
M.update_inv_l_hand()
// If welding tool ran out of fuel during a construction task, construction fails.
-/obj/item/weldingtool/tool_use_check(mob/living/user, amount)
+/obj/item/weldingtool/tool_use_check(mob/living/user, amount, silent = FALSE)
if(!tool_enabled)
- to_chat(user, "[src] has to be on to complete this task!")
+ if(!silent)
+ to_chat(user, "[src] has to be on to complete this task!")
return FALSE
if(GET_FUEL >= amount * requires_fuel)
return TRUE
else
- to_chat(user, "You need more welding fuel to complete this task!")
+ if(!silent)
+ to_chat(user, "You need more welding fuel to complete this task!")
return FALSE
// When welding is about to start, run a normal tool_use_check, then flash a mob if it succeeds.
diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm
index 2c6018fa54d..c665305e99b 100644
--- a/code/modules/mob/living/living.dm
+++ b/code/modules/mob/living/living.dm
@@ -291,7 +291,7 @@
return 1
/mob/living/welder_act(mob/user, obj/item/I)
- if(!I.tool_use_check(null, 0)) //Don't need the message, just if it succeeded
+ if(!I.tool_use_check(user, 0, TRUE))
return
if(IgniteMob())
message_admins("[key_name_admin(user)] set [key_name_admin(src)] on fire with [I]")