mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Add lints for "new" override prevention feature (#49672)
* Add lints for "new" override prevention feature * bEsPoKe * i'm an idiot * arg index
This commit is contained in:
@@ -277,6 +277,8 @@
|
||||
#define COMPONENT_BLOCK_SHARPEN_BLOCKED 2
|
||||
#define COMPONENT_BLOCK_SHARPEN_ALREADY 4
|
||||
#define COMPONENT_BLOCK_SHARPEN_MAXED 8
|
||||
#define COMSIG_TOOL_IN_USE "tool_in_use" ///from base of [/obj/item/proc/tool_check_callback]: (mob/living/user)
|
||||
#define COMSIG_TOOL_START_USE "tool_start_use" ///from base of [/obj/item/proc/tool_start_check]: (mob/living/user)
|
||||
|
||||
// /obj/item signals for economy
|
||||
#define COMSIG_ITEM_SOLD "item_sold" //called when an item is sold by the exports subsystem
|
||||
|
||||
@@ -6,10 +6,14 @@
|
||||
#define RETURN_TYPE(X) set SpacemanDMM_return_type = X
|
||||
#define SHOULD_CALL_PARENT(X) set SpacemanDMM_should_call_parent = X
|
||||
#define UNLINT(X) SpacemanDMM_unlint(X)
|
||||
#define SHOULD_NOT_OVERRIDE(X) set SpacemanDMM_should_not_override = X
|
||||
#define VAR_FINAL var/SpacemanDMM_final
|
||||
#else
|
||||
#define RETURN_TYPE(X)
|
||||
#define SHOULD_CALL_PARENT(X)
|
||||
#define UNLINT(X) X
|
||||
#define SHOULD_NOT_OVERRIDE(X)
|
||||
#define VAR_FINAL var
|
||||
#endif
|
||||
|
||||
/world/proc/enable_debugger()
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
//This is used so the mc knows when the subsystem sleeps. do not override.
|
||||
/datum/controller/subsystem/proc/ignite(resumed = 0)
|
||||
SHOULD_NOT_OVERRIDE(TRUE)
|
||||
set waitfor = 0
|
||||
. = SS_SLEEPING
|
||||
fire(resumed)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Tool flash bespoke element
|
||||
*
|
||||
* Flashes the user when using this tool
|
||||
*/
|
||||
/datum/element/tool_flash
|
||||
element_flags = ELEMENT_BESPOKE
|
||||
id_arg_index = 2
|
||||
/// Strength of the flash
|
||||
var/flash_strength
|
||||
|
||||
/datum/element/tool_flash/Attach(datum/target, flash_strength)
|
||||
. = ..()
|
||||
if(!isitem(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
|
||||
src.flash_strength = flash_strength
|
||||
|
||||
RegisterSignal(target, COMSIG_TOOL_IN_USE, .proc/prob_flash)
|
||||
RegisterSignal(target, COMSIG_TOOL_START_USE, .proc/flash)
|
||||
|
||||
/datum/element/tool_flash/Detach(datum/source, force)
|
||||
. = ..()
|
||||
UnregisterSignal(source, list(COMSIG_TOOL_IN_USE, COMSIG_TOOL_START_USE))
|
||||
|
||||
/datum/element/tool_flash/proc/prob_flash(datum/source, mob/living/user)
|
||||
if(prob(90))
|
||||
return
|
||||
flash(source, user)
|
||||
|
||||
/datum/element/tool_flash/proc/flash(datum/source, mob/living/user)
|
||||
if(user && get_dist(get_turf(source), get_turf(user)) <= 1)
|
||||
user.flash_act(min(flash_strength,1))
|
||||
@@ -816,7 +816,9 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
|
||||
// Called before use_tool if there is a delay, or by use_tool if there isn't.
|
||||
// Only ever used by welding tools and stacks, so it's not added on any other use_tool checks.
|
||||
/obj/item/proc/tool_start_check(mob/living/user, amount=0)
|
||||
return tool_use_check(user, amount)
|
||||
. = tool_use_check(user, amount)
|
||||
if(.)
|
||||
SEND_SIGNAL(src, COMSIG_TOOL_START_USE, user)
|
||||
|
||||
// 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)
|
||||
@@ -837,9 +839,12 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
|
||||
|
||||
playsound(target, played_sound, volume, TRUE)
|
||||
|
||||
// Used in a callback that is passed by use_tool into do_after call. Do not override, do not call manually.
|
||||
/// Used in a callback that is passed by use_tool into do_after call. Do not override, do not call manually.
|
||||
/obj/item/proc/tool_check_callback(mob/living/user, amount, datum/callback/extra_checks)
|
||||
return tool_use_check(user, amount) && (!extra_checks || extra_checks.Invoke())
|
||||
SHOULD_NOT_OVERRIDE(TRUE)
|
||||
. = tool_use_check(user, amount) && (!extra_checks || extra_checks.Invoke())
|
||||
if(.)
|
||||
SEND_SIGNAL(src, COMSIG_TOOL_IN_USE, user)
|
||||
|
||||
// Returns a numeric value for sorting items used as parts in machines, so they can be replaced by the rped
|
||||
/obj/item/proc/get_part_rating()
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
var/change_icons = 1
|
||||
var/can_off_process = 0
|
||||
var/light_intensity = 2 //how powerful the emitted light is when used.
|
||||
var/progress_flash_divisor = 10
|
||||
var/burned_fuel_for = 0 //when fuel was last removed
|
||||
heat = 3800
|
||||
tool_behaviour = TOOL_WELDER
|
||||
@@ -45,6 +44,7 @@
|
||||
/obj/item/weldingtool/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/update_icon_updates_onmob)
|
||||
AddElement(/datum/element/tool_flash, light_intensity)
|
||||
|
||||
/obj/item/weldingtool/update_icon_state()
|
||||
if(welding)
|
||||
@@ -245,22 +245,6 @@
|
||||
/obj/item/weldingtool/proc/isOn()
|
||||
return welding
|
||||
|
||||
// When welding is about to start, run a normal tool_use_check, then flash a mob if it succeeds.
|
||||
/obj/item/weldingtool/tool_start_check(mob/living/user, amount=0)
|
||||
. = tool_use_check(user, amount)
|
||||
if(. && user && get_dist(get_turf(src), get_turf(user)) <= 1)
|
||||
user.flash_act(light_intensity)
|
||||
|
||||
// Flash the user during welding progress
|
||||
/obj/item/weldingtool/tool_check_callback(mob/living/user, amount, datum/callback/extra_checks)
|
||||
. = ..()
|
||||
if(. && user && get_dist(get_turf(src), get_turf(user)) <= 1)
|
||||
if (progress_flash_divisor == 0)
|
||||
user.flash_act(min(light_intensity,1))
|
||||
progress_flash_divisor = initial(progress_flash_divisor)
|
||||
else
|
||||
progress_flash_divisor--
|
||||
|
||||
// If welding tool ran out of fuel during a construction task, construction fails.
|
||||
/obj/item/weldingtool/tool_use_check(mob/living/user, amount)
|
||||
if(!isOn() || !check_fuel())
|
||||
|
||||
@@ -166,6 +166,7 @@
|
||||
//Do not override this proc, instead use the appropiate procs.
|
||||
//This proc will handle the calls to the appropiate procs.
|
||||
/datum/round_event/process()
|
||||
SHOULD_NOT_OVERRIDE(TRUE)
|
||||
if(!processing)
|
||||
return
|
||||
|
||||
|
||||
@@ -133,14 +133,13 @@
|
||||
usesound = list('sound/items/welder.ogg', 'sound/items/welder2.ogg')
|
||||
tool_behaviour = TOOL_WELDER
|
||||
toolspeed = 0.7 //plasmacutters can be used as welders, and are faster than standard welders
|
||||
var/progress_flash_divisor = 10 //copypasta is best pasta
|
||||
var/light_intensity = 1
|
||||
var/charge_weld = 25 //amount of charge used up to start action (multiplied by amount) and per progress_flash_divisor ticks of welding
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/ComponentInitialize()
|
||||
. = ..()
|
||||
AddComponent(/datum/component/butchering, 25, 105, 0, 'sound/weapons/plasma_cutter.ogg')
|
||||
AddElement(/datum/element/update_icon_blocker)
|
||||
AddElement(/datum/element/tool_flash, 1)
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/examine(mob/user)
|
||||
. = ..()
|
||||
@@ -163,13 +162,6 @@
|
||||
else
|
||||
..()
|
||||
|
||||
// Tool procs, in case plasma cutter is used as welder
|
||||
// Can we start welding?
|
||||
/obj/item/gun/energy/plasmacutter/tool_start_check(mob/living/user, amount)
|
||||
. = tool_use_check(user, amount)
|
||||
if(. && user)
|
||||
user.flash_act(light_intensity)
|
||||
|
||||
// Can we weld? Plasma cutter does not use charge continuously.
|
||||
// Amount cannot be defaulted to 1: most of the code specifies 0 in the call.
|
||||
/obj/item/gun/energy/plasmacutter/tool_use_check(mob/living/user, amount)
|
||||
@@ -188,17 +180,6 @@
|
||||
/obj/item/gun/energy/plasmacutter/use(amount)
|
||||
return (!QDELETED(cell) && cell.use(amount ? amount * charge_weld : charge_weld))
|
||||
|
||||
// This only gets called by use_tool(delay > 0)
|
||||
// It's also supposed to not get overridden in the first place.
|
||||
/obj/item/gun/energy/plasmacutter/tool_check_callback(mob/living/user, amount, datum/callback/extra_checks)
|
||||
. = ..() //return tool_use_check(user, amount) && (!extra_checks || extra_checks.Invoke())
|
||||
if(. && user)
|
||||
if (progress_flash_divisor == 0)
|
||||
user.flash_act(min(light_intensity,1))
|
||||
progress_flash_divisor = initial(progress_flash_divisor)
|
||||
else
|
||||
progress_flash_divisor--
|
||||
|
||||
/obj/item/gun/energy/plasmacutter/use_tool(atom/target, mob/living/user, delay, amount=1, volume=0, datum/callback/extra_checks)
|
||||
if(amount)
|
||||
. = ..()
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
//Extra settings
|
||||
///Don't ever override this or I will come to your house and stand menacingly behind a bush
|
||||
var/list/extra_settings = list()
|
||||
VAR_FINAL/list/extra_settings = list()
|
||||
|
||||
//Rules
|
||||
//Rules that automatically manage if the program's active without requiring separate sensor programs
|
||||
|
||||
@@ -534,6 +534,7 @@
|
||||
#include "code\datums\elements\selfknockback.dm"
|
||||
#include "code\datums\elements\snail_crawl.dm"
|
||||
#include "code\datums\elements\squish.dm"
|
||||
#include "code\datums\elements\tool_flash.dm"
|
||||
#include "code\datums\elements\update_icon_blocker.dm"
|
||||
#include "code\datums\elements\update_icon_updates_onmob.dm"
|
||||
#include "code\datums\elements\waddling.dm"
|
||||
|
||||
Reference in New Issue
Block a user