From fc29da4e9c01196ff3121c8796673b1c8aaffb20 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 6 Oct 2021 20:36:27 +0200 Subject: [PATCH] [MIRROR] [s] Cleanup escalation unsafe procs [MDB IGNORE] (#8642) * [s] Cleanup escalation unsafe procs (#61905) Fixes admins spawning in atoms and datums without the DF_VAR_EDITED flag * [s] Cleanup escalation unsafe procs Co-authored-by: Jordan Brown --- code/__DEFINES/callbacks.dm | 1 - code/datums/callback.dm | 3 --- code/game/alternate_appearance.dm | 3 +++ code/modules/admin/verbs/SDQL2/SDQL_2_wrappers.dm | 5 ++++- code/modules/clothing/clothing.dm | 6 ++++-- code/modules/wiremod/components/admin/spawn.dm | 4 +++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/code/__DEFINES/callbacks.dm b/code/__DEFINES/callbacks.dm index 6d23e509054..4b93bc44b04 100644 --- a/code/__DEFINES/callbacks.dm +++ b/code/__DEFINES/callbacks.dm @@ -2,4 +2,3 @@ /// A shorthand for the callback datum, [documented here](datum/callback.html) #define CALLBACK new /datum/callback #define INVOKE_ASYNC world.ImmediateInvokeAsync -#define CALLBACK_NEW(typepath, args) CALLBACK(GLOBAL_PROC, /proc/___callbacknew, typepath, args) diff --git a/code/datums/callback.dm b/code/datums/callback.dm index b5baea28f1f..466f150214a 100644 --- a/code/datums/callback.dm +++ b/code/datums/callback.dm @@ -220,6 +220,3 @@ while(CS.pendingcount) sleep(resolution*world.tick_lag) return CS.finished - -/proc/___callbacknew(typepath, arguments) - new typepath(arglist(arguments)) diff --git a/code/game/alternate_appearance.dm b/code/game/alternate_appearance.dm index 4b3a0114533..b23054f40b5 100644 --- a/code/game/alternate_appearance.dm +++ b/code/game/alternate_appearance.dm @@ -13,6 +13,9 @@ GLOBAL_LIST_EMPTY(active_alternate_appearances) return if(alternate_appearances && alternate_appearances[key]) return + if(!ispath(type, /datum/atom_hud/alternate_appearance)) + CRASH("Invalid type passed in: [type]") + var/list/arguments = args.Copy(2) return new type(arglist(arguments)) diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2_wrappers.dm b/code/modules/admin/verbs/SDQL2/SDQL_2_wrappers.dm index bb5903d79d3..611b80ee8a4 100644 --- a/code/modules/admin/verbs/SDQL2/SDQL_2_wrappers.dm +++ b/code/modules/admin/verbs/SDQL2/SDQL_2_wrappers.dm @@ -85,7 +85,10 @@ return min(arglist(args)) /proc/_new(type, arguments) - return new type (arglist(arguments)) + var/datum/result = new type(arglist(arguments)) + if(istype(result)) + result.datum_flags |= DF_VAR_EDITED + return result /proc/_num2text(N, SigFig = 6) return num2text(N, SigFig) diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index cfb3c06fe6f..662a5785ec6 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -489,11 +489,13 @@ BLIND // can't see anything return 1 return 0 +/obj/item/clothing/proc/_spawn_shreds() + new /obj/effect/decal/cleanable/shreds(get_turf(src), name) + /obj/item/clothing/atom_destruction(damage_flag) if(damage_flag == BOMB) - var/turf/T = get_turf(src) //so the shred survives potential turf change from the explosion. - addtimer(CALLBACK_NEW(/obj/effect/decal/cleanable/shreds, list(T, name)), 1) + addtimer(CALLBACK(src, .proc/_spawn_shreds), 1) deconstruct(FALSE) if(damage_flag == CONSUME) //This allows for moths to fully consume clothing, rather than damaging it like other sources like brute var/turf/current_position = get_turf(src) diff --git a/code/modules/wiremod/components/admin/spawn.dm b/code/modules/wiremod/components/admin/spawn.dm index 73c7325ca77..3a4d07a7201 100644 --- a/code/modules/wiremod/components/admin/spawn.dm +++ b/code/modules/wiremod/components/admin/spawn.dm @@ -40,4 +40,6 @@ params.Insert(1, spawn_at.value) - spawned_atom.set_output(new typepath(arglist(params))) + var/atom/spawned = new typepath(arglist(params)) + spawned.datum_flags |= DF_VAR_EDITED + spawned_atom.set_output(spawned)