diff --git a/code/controllers/subsystems/explosives.dm b/code/controllers/subsystems/explosives.dm
index 62f6d0eaf42..25c206fe89a 100644
--- a/code/controllers/subsystems/explosives.dm
+++ b/code/controllers/subsystems/explosives.dm
@@ -33,7 +33,7 @@ var/datum/controller/subsystem/explosives/SSexplosives
powernet_update_pending = SSexplosives.powernet_update_pending
/datum/controller/subsystem/explosives/fire(resumed = FALSE)
- if (!(work_queue.len))
+ if(!length(work_queue))
ticks_without_work++
if (powernet_update_pending && ticks_without_work > 5)
SSmachinery.powernet_update_queued = TRUE
@@ -81,7 +81,8 @@ var/datum/controller/subsystem/explosives/SSexplosives
var/start = world.timeofday
epicenter = get_turf(epicenter)
- if(!epicenter) return
+ if(!epicenter)
+ return
// Handles recursive propagation of explosions.
if(devastation_range > 2 || heavy_impact_range > 2)
@@ -112,23 +113,25 @@ var/datum/controller/subsystem/explosives/SSexplosives
//Whether or not this explosion causes enough vibration to send sound or shockwaves through the station
var/vibration = 1
- if (istype(epicenter,/turf/space))
+ if(istype(epicenter, /turf/space))
vibration = 0
- for (var/turf/T in range(src, max_range))
- if (!istype(T,/turf/space))
+ for(var/thing in RANGE_TURFS(max_range, epicenter))
+ var/turf/T = thing
+ if (!istype(T, /turf/space))
//If there is a nonspace tile within the explosion radius
//Then we can reverberate shockwaves through that, and allow it to be felt in a vacuum
vibration = 1
if (vibration)
- for(var/mob/M in player_list)
+ for(var/thing in player_list)
+ var/mob/M = thing
CHECK_TICK
// Double check for client
var/reception = 2//Whether the person can be shaken or hear sound
//2 = BOTH
//1 = shockwaves only
//0 = no effect
- if(M && M.client)
+ if(M?.client)
var/turf/M_turf = get_turf(M)
if(M_turf && M_turf.z == epicenter.z)
@@ -136,8 +139,9 @@ var/datum/controller/subsystem/explosives/SSexplosives
//If the person is standing in space, they wont hear
//But they may still feel the shaking
reception = 0
- for (var/turf/T in range(M, 1))
- if (!istype(T,/turf/space))
+ for(var/t_thing in RANGE_TURFS(1, M))
+ var/turf/T = t_thing
+ if(!istype(T, /turf/space))
//If theyre touching the hull or on some extruding part of the station
reception = 1//They will get screenshake
break
@@ -200,14 +204,14 @@ var/datum/controller/subsystem/explosives/SSexplosives
if(T)
for(var/atom_movable in T.contents) //bypass type checking since only atom/movable can be contained by turfs anyway
var/atom/movable/AM = atom_movable
- if(AM && AM.simulated)
+ if(!QDELETED(AM) && AM.simulated)
AM.ex_act(dist)
CHECK_TICK
var/took = (world.timeofday-start)/10
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
- if(Debug2) world.log << "## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]: Took [took] seconds."
+ if(Debug2) world.log << "## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [took] seconds."
// All the vars used on the turf should be on unsimulated turfs too, we just don't care about those generally.
#define SEARCH_DIR(dir) \
diff --git a/code/modules/mob/living/carbon/human/death.dm b/code/modules/mob/living/carbon/human/death.dm
index e188fda1760..f991d0aeaef 100644
--- a/code/modules/mob/living/carbon/human/death.dm
+++ b/code/modules/mob/living/carbon/human/death.dm
@@ -3,7 +3,7 @@
for(var/obj/item/organ/I in internal_organs)
I.removed()
- if(istype(loc,/turf))
+ if(isturf(loc))
I.throw_at(get_edge_target_turf(src,pick(alldirs)),rand(1,3),30)
for(var/obj/item/organ/external/E in src.organs)
diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm
index 280d52bcef8..bab9b92b1f7 100644
--- a/code/modules/organs/organ_external.dm
+++ b/code/modules/organs/organ_external.dm
@@ -998,16 +998,17 @@ Note that amputating the affected organ does in fact remove the infection from t
return //ORGAN_BROKEN doesn't have the same meaning for robot limbs
if((status & ORGAN_BROKEN) || !(limb_flags & ORGAN_CAN_BREAK))
return
+ if(QDELETED(owner))
+ return
- if(owner)
- var/message = pick("broke in half", "shattered")
- owner.visible_message(\
- "You hear a loud cracking sound coming from \the [owner]!",\
- "Something feels like it [message] in your [name]!",\
- "You hear a sickening crack!")
- if(owner.species && owner.can_feel_pain())
- owner.emote("scream")
- owner.flash_strong_pain()
+ var/message = pick("broke in half", "shattered")
+ owner.visible_message(\
+ "You hear a loud cracking sound coming from \the [owner]!",\
+ "Something feels like it [message] in your [name]!",\
+ "You hear a sickening crack!")
+ if(owner.species && owner.can_feel_pain())
+ owner.emote("scream")
+ owner.flash_strong_pain()
playsound(src.loc, /decl/sound_category/fracture_sound, 100, 1, -2)
status |= ORGAN_BROKEN
@@ -1020,7 +1021,6 @@ Note that amputating the affected organ does in fact remove the infection from t
// This is mostly for the ninja suit to stop ninja being so crippled by breaks.
check_rigsplints()
- return
/obj/item/organ/external/proc/mend_fracture()
if(status & ORGAN_ROBOT)
@@ -1133,7 +1133,7 @@ Note that amputating the affected organ does in fact remove the infection from t
var/is_robotic = status & ORGAN_ROBOT
var/mob/living/carbon/human/victim = owner
- ..()
+ ..(null, user)
victim.bad_external_organs -= src
diff --git a/html/changelogs/geeves-explosive_optimization.yml b/html/changelogs/geeves-explosive_optimization.yml
new file mode 100644
index 00000000000..69e152f7692
--- /dev/null
+++ b/html/changelogs/geeves-explosive_optimization.yml
@@ -0,0 +1,6 @@
+author: Geeves
+
+delete-after: True
+
+changes:
+ - tweak: "Optimized explosion code a little, it should be a teeny bit faster."
\ No newline at end of file