Skip to content

Commit

Permalink
Fixes OB Warheads deletions (#4740)
Browse files Browse the repository at this point in the history
# About the pull request

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

`runtime error: addtimer called with a callback assigned to a qdeleted
object. In the future such timers will not be supported and may refuse
to run or run with a 0 wait`

Makes OB Warheads and especially cluster delete timely (after their
explosion) saving us incertainties for most warheads, and a few hundreds
of runtimes for cluster.

# Explain why it's good for the game
Cleaner logs, i can't see what's going on in there geez

# Testing Photographs and Procedure
Fired a cluster checking runtimes. That's it.


# Changelog

No player facing changes
  • Loading branch information
fira authored Oct 21, 2023
1 parent 7c1c20f commit c61e36b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
7 changes: 1 addition & 6 deletions code/modules/admin/tabs/event_tab.dm
Original file line number Diff line number Diff line change
Expand Up @@ -931,13 +931,8 @@
message_admins("[key_name(usr)] has fired \an [warhead.name] at ([target.x],[target.y],[target.z]).")
warhead.warhead_impact(target)

if(istype(warhead, /obj/structure/ob_ammo/warhead/cluster))
// so the user's screen can shake for the duration of the cluster, otherwise we get a runtime.
QDEL_IN(warhead, OB_CLUSTER_DURATION)
else
QDEL_IN(warhead, OB_CRASHING_DOWN)
else
warhead.loc = target
warhead.forceMove(target)

/client/proc/change_taskbar_icon()
set name = "Set Taskbar Icon"
Expand Down
23 changes: 16 additions & 7 deletions code/modules/cm_marines/orbital_cannon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,16 @@ var/list/ob_type_fuel_requirements
if(user)
tray.warhead.source_mob = user

tray.warhead.warhead_impact(target)
var/obj/structure/ob_ammo/warhead/warhead = tray.warhead
tray.warhead = null
warhead.moveToNullspace()
warhead.warhead_impact(target)

sleep(OB_CRASHING_DOWN)

ob_cannon_busy = FALSE

chambered_tray = FALSE
tray.fuel_amt = 0
QDEL_NULL(tray.warhead)
tray.update_icon()

update_icon()
Expand Down Expand Up @@ -357,6 +358,9 @@ var/list/ob_type_fuel_requirements
var/max_shake_factor
var/max_knockdown_time

// Note that the warhead should be cleared of location by the firing proc,
// then auto-delete at the end of the warhead_impact implementation

/obj/structure/ob_ammo/warhead/proc/warhead_impact(turf/target)
// make damn sure everyone hears it
playsound(target, 'sound/weapons/gun_orbital_travel.ogg', 100, 1, 75)
Expand All @@ -366,7 +370,7 @@ var/list/ob_type_fuel_requirements
message_admins(FONT_SIZE_XL("<A HREF='?_src_=admin_holder;[HrefToken(forceGlobal = TRUE)];admincancelob=1;cancellation=[cancellation_token]'>CLICK TO CANCEL THIS OB</a>"))

var/relative_dir
for(var/mob/M in range(30, target))
for(var/mob/M in urange(30, target))
if(get_turf(M) == target)
relative_dir = 0
else
Expand All @@ -377,7 +381,7 @@ var/list/ob_type_fuel_requirements
)
sleep(OB_TRAVEL_TIMING/3)

for(var/mob/M in range(25, target))
for(var/mob/M in urange(25, target))
if(get_turf(M) == target)
relative_dir = 0
else
Expand All @@ -388,7 +392,7 @@ var/list/ob_type_fuel_requirements
)
sleep(OB_TRAVEL_TIMING/3)

for(var/mob/M in range(15, target))
for(var/mob/M in urange(15, target))
M.show_message( \
SPAN_HIGHDANGER("OH GOD THE SKY WILL EXPLODE!!!"), SHOW_MESSAGE_VISIBLE, \
SPAN_HIGHDANGER("YOU SHOULDN'T BE HERE!"), SHOW_MESSAGE_AUDIBLE \
Expand Down Expand Up @@ -455,6 +459,7 @@ var/list/ob_type_fuel_requirements
handle_ob_shake(target)
sleep(double_explosion_delay)
cell_explosion(target, standard_power, standard_falloff, EXPLOSION_FALLOFF_SHAPE_LINEAR, null, cause_data)
qdel(src)
return

// Checks turf around the target
Expand All @@ -464,8 +469,11 @@ var/list/ob_type_fuel_requirements
handle_ob_shake(target)
sleep(double_explosion_delay)
cell_explosion(target, standard_power, standard_falloff, EXPLOSION_FALLOFF_SHAPE_LINEAR, null, cause_data)
qdel(src)
return

qdel(src)

/obj/structure/ob_ammo/warhead/incendiary
name = "\improper Incendiary orbital warhead"
warhead_kind = "incendiary"
Expand Down Expand Up @@ -497,6 +505,7 @@ var/list/ob_type_fuel_requirements

sleep(clear_delay)
fire_spread(target, cause_data, distance, fire_level, burn_level, fire_color, fire_type, TURF_PROTECTION_OB)
qdel(src)

/obj/structure/ob_ammo/warhead/cluster
name = "\improper Cluster orbital warhead"
Expand Down Expand Up @@ -533,8 +542,8 @@ var/list/ob_type_fuel_requirements
if(protected_by_pylon(TURF_PROTECTION_OB, U)) //If the turf somehow gained OB protection while the cluster was firing
continue
fire_in_a_hole(U)

sleep(delay_between_clusters)
QDEL_IN(src, 5 SECONDS) // Leave time for last handle_ob_shake below

/obj/structure/ob_ammo/warhead/cluster/proc/fire_in_a_hole(turf/loc)
new /obj/effect/overlay/temp/blinking_laser (loc)
Expand Down

0 comments on commit c61e36b

Please sign in to comment.