Skip to content

Some minor runtime fixes #3130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#define LAZYACCESSASSOC(L, I, K) L ? L[I] ? L[I][K] ? L[I][K] : null : null : null
///Qdel every item in the list before setting the list to null
#define QDEL_LAZYLIST(L) for(var/I in L) qdel(I); L = null;
///Qdel every value in an assoc list list before setting the list to null
#define QDEL_LAZYASSOCLIST(L) for(var/I in L) qdel(L[I]); L = null;
//These methods don't null the list
///Use LAZYLISTDUPLICATE instead if you want it to null with no entries
#define LAZYCOPY(L) (L ? L.Copy() : list() )
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ Used by the AI doomsday and the self-destruct nuke.

/datum/controller/subsystem/mapping/proc/determine_fake_sale()
if(length(SSmapping.levels_by_all_traits(list(ZTRAIT_STATION, ZTRAIT_NOPARALLAX))))
GLOB.arcade_prize_pool += /obj/item/stack/tile/fakeice/loaded
GLOB.arcade_prize_pool[/obj/item/stack/tile/fakeice/loaded] = 1 // monkestation edit: fix null weight
else
GLOB.arcade_prize_pool += /obj/item/stack/tile/fakespace/loaded
GLOB.arcade_prize_pool[/obj/item/stack/tile/fakespace/loaded] = 1 // monkestation edit: fix null weight


/datum/controller/subsystem/mapping/Recover()
Expand Down
6 changes: 4 additions & 2 deletions code/datums/actions/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,13 @@
* force - whether an update is forced regardless of existing status
*/
/datum/action/proc/update_button_status(atom/movable/screen/movable/action_button/current_button, force = FALSE)
if(QDELETED(current_button))
return
current_button.update_keybind_maptext(full_key)
if(IsAvailable())
current_button?.color = rgb(255,255,255,255)
current_button.color = rgb(255,255,255,255)
else
current_button?.color = transparent_when_unavailable ? rgb(128,0,0,128) : rgb(128,0,0)
current_button.color = transparent_when_unavailable ? rgb(128,0,0,128) : rgb(128,0,0)

/// Gives our action to the passed viewer.
/// Puts our action in their actions list and shows them the button.
Expand Down
6 changes: 4 additions & 2 deletions code/datums/chatmessage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@
. = ..()
if (!istype(target))
CRASH("Invalid target given for chatmessage")
if(QDELETED(owner) || !istype(owner) || !owner.client)
if(!istype(owner))
stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner")
qdel(src)
else if(QDELING(owner) || QDELETED(owner.client)) // honestly they prolly just disconnected at a funny time or something
qdel(src)
return
INVOKE_ASYNC(src, PROC_REF(generate_image), text, target, owner, language, extra_classes, lifespan)

/datum/chatmessage/Destroy()
remove_from_queue()
if (!QDELING(owned_by))
if (!QDELETED(owned_by))
if(REALTIMEOFDAY < animate_start + animate_lifespan)
stack_trace("Del'd before we finished fading, with [(animate_start + animate_lifespan) - REALTIMEOFDAY] time left")

Expand Down
10 changes: 5 additions & 5 deletions code/datums/elements/ai_held_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/// Returns the item held in a mob's blackboard, if it has one
/datum/element/ai_held_item/proc/get_held_item(mob/living/source)
return source.ai_controller.blackboard[BB_SIMPLE_CARRY_ITEM]
return source.ai_controller?.blackboard[BB_SIMPLE_CARRY_ITEM]

/// Someone's interacting with us by hand, if we have an item and like them we'll hand it over
/datum/element/ai_held_item/proc/on_click(mob/living/source, mob/living/user)
Expand All @@ -29,23 +29,23 @@
if ((user.istate & ISTATE_HARM))
return

if (!(user in source.ai_controller.blackboard[BB_FRIENDS_LIST]))
if (!(user in source.ai_controller?.blackboard[BB_FRIENDS_LIST]))
return // We don't care about this bozo
var/obj/item/carried_item = get_held_item(source)
if (!carried_item)
return

source.visible_message(span_danger("[source] drops [carried_item] at [user]'s feet!"))
carried_item.forceMove(get_turf(user))
source.ai_controller.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)
source.ai_controller?.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)

/// If our held item is removed from our atom then take it off the blackboard
/datum/element/ai_held_item/proc/atom_exited(mob/living/source, atom/movable/gone)
SIGNAL_HANDLER

var/obj/item/carried_item = get_held_item(source)
if (carried_item == gone)
source.ai_controller.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)
source.ai_controller?.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)

/// Report that we're holding an item.
/datum/element/ai_held_item/proc/on_examined(mob/living/source, mob/user, list/examine_text)
Expand All @@ -66,4 +66,4 @@

ol_yeller.visible_message(span_danger("[ol_yeller] drops [carried_item] as [ol_yeller.p_they()] die[ol_yeller.p_s()]."))
carried_item.forceMove(ol_yeller.drop_location())
ol_yeller.ai_controller.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)
ol_yeller.ai_controller?.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)
7 changes: 0 additions & 7 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,6 @@ GLOBAL_LIST_EMPTY(teleportlocs)
if(ambient_buzz != old_area.ambient_buzz)
L.refresh_looping_ambience()

if(isliving(arrived))
if(SSparticle_weather.running_eclipse_weather || SSparticle_weather.running_weather)
if(SSparticle_weather.running_eclipse_weather && SSmapping.level_has_all_traits(arrived.z, list(ZTRAIT_ECLIPSE)))
SSparticle_weather.running_eclipse_weather.weather_sound_effect(arrived)
if(SSparticle_weather.running_weather && SSmapping.level_has_all_traits(arrived.z, list(ZTRAIT_STATION)))
SSparticle_weather.running_weather.weather_sound_effect(arrived)

///Tries to play looping ambience to the mobs.
/mob/proc/refresh_looping_ambience()
SIGNAL_HANDLER
Expand Down
39 changes: 22 additions & 17 deletions code/game/machinery/embedded_controller/airlock_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
var/processing = FALSE

/obj/machinery/airlock_controller/LateInitialize()
. = ..()

var/obj/machinery/door/interior_door = GLOB.objects_by_id_tag[interior_door_tag]
if (!isnull(interior_door_tag) && !istype(interior_door))
stack_trace("interior_door_tag is set to [interior_door_tag], which is not a door ([interior_door || "null"])")
Expand All @@ -57,6 +55,13 @@
stack_trace("sensor_tag is set to [sensor_tag], which is not a sensor ([sensor || "null"])")
sensor_ref = WEAKREF(sensor)

/obj/machinery/airlock_controller/Destroy()
interior_door_ref = null
exterior_door_ref = null
pump_ref = null
sensor_ref = null
return ..()

/obj/machinery/airlock_controller/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
Expand All @@ -70,7 +75,7 @@
switch(state)
if(AIRLOCK_STATE_INOPEN)
if(target_state != state)
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref.resolve()
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref?.resolve()
if (isnull(interior_airlock))
continue

Expand All @@ -80,7 +85,7 @@
else
interior_airlock.secure_close()
else
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref.resolve()
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref?.resolve()

if(pump?.on)
pump.on = FALSE
Expand All @@ -93,7 +98,7 @@
continue

if(sensor_pressure >= ONE_ATMOSPHERE*0.95)
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref.resolve()
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref?.resolve()
if (isnull(interior_airlock))
continue

Expand All @@ -103,7 +108,7 @@
state = AIRLOCK_STATE_INOPEN
process_again = TRUE
else
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref.resolve()
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref?.resolve()
if (isnull(pump))
continue

Expand All @@ -119,7 +124,7 @@

if(AIRLOCK_STATE_CLOSED)
if(target_state == AIRLOCK_STATE_OUTOPEN)
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref.resolve()
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref?.resolve()
if (isnull(interior_airlock))
continue

Expand All @@ -129,7 +134,7 @@
else
interior_airlock?.secure_close()
else if(target_state == AIRLOCK_STATE_INOPEN)
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref.resolve()
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref?.resolve()
if (isnull(exterior_airlock))
continue

Expand All @@ -139,7 +144,7 @@
else
exterior_airlock?.secure_close()
else
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref.resolve()
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref?.resolve()
if (isnull(pump))
continue

Expand All @@ -158,7 +163,7 @@

if(sensor_pressure <= target_pressure)
if(target_state == AIRLOCK_STATE_OUTOPEN)
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref.resolve()
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref?.resolve()
if (isnull(exterior_airlock))
continue

Expand All @@ -173,7 +178,7 @@
state = AIRLOCK_STATE_CLOSED
process_again = TRUE
else
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref.resolve()
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref?.resolve()
if (isnull(pump))
continue

Expand All @@ -186,7 +191,7 @@

if(AIRLOCK_STATE_OUTOPEN) //state 2
if(target_state != AIRLOCK_STATE_OUTOPEN)
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref.resolve()
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref?.resolve()
if (isnull(exterior_airlock))
continue

Expand All @@ -200,7 +205,7 @@
else
exterior_airlock.secure_close()
else
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref.resolve()
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref?.resolve()
if (isnull(pump))
continue

Expand All @@ -221,19 +226,19 @@
var/sensor_pressure = sensor_pressure()
data["sensorPressure"] = isnull(sensor_pressure) ? "----" : round(sensor_pressure, 0.1)

var/obj/machinery/door/airlock/interior_airlock = interior_door_ref.resolve()
var/obj/machinery/door/airlock/interior_airlock = interior_door_ref?.resolve()
if (isnull(interior_airlock))
data["interiorStatus"] = "----"
else
data["interiorStatus"] = interior_airlock.density ? "closed" : "open"

var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref.resolve()
var/obj/machinery/door/airlock/exterior_airlock = exterior_door_ref?.resolve()
if (isnull(exterior_airlock))
data["exteriorStatus"] = "----"
else
data["exteriorStatus"] = exterior_airlock.density ? "closed" : "open"

var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref.resolve()
var/obj/machinery/atmospherics/components/binary/dp_vent_pump/pump = pump_ref?.resolve()
switch (pump?.pump_direction)
if (null)
data["pumpStatus"] = "----"
Expand Down Expand Up @@ -270,7 +275,7 @@

/// Returns the pressure over the pump, or null if it is deleted
/obj/machinery/airlock_controller/proc/sensor_pressure()
var/obj/machinery/airlock_sensor/sensor = sensor_ref.resolve()
var/obj/machinery/airlock_sensor/sensor = sensor_ref?.resolve()
if (!isnull(sensor) && !sensor.on)
return last_pressure

Expand Down
8 changes: 5 additions & 3 deletions code/game/turfs/closed/minerals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@
var/old_type = type
if(defer_change) // TODO: make the defer change var a var for any changeturf flag
flags = CHANGETURF_DEFER_CHANGE
var/turf/open/mined = ScrapeAway(null, flags)
addtimer(CALLBACK(src, PROC_REF(AfterChange), flags, old_type), 1, TIMER_UNIQUE)
playsound(src, 'sound/effects/break_stone.ogg', 50, TRUE) //beautiful destruction
mined.update_visuals()
var/turf/open/mined = ScrapeAway(null, flags)
if(!QDELETED(src))
addtimer(CALLBACK(src, PROC_REF(AfterChange), flags, old_type), 1, TIMER_UNIQUE)
if(!QDELETED(mined))
mined.update_visuals()

/turf/closed/mineral/attack_alien(mob/living/carbon/alien/user, list/modifiers)
balloon_alert(user, "digging...")
Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/antag_panel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ GLOBAL_VAR(antag_prototypes)
GLOB.antag_prototypes[cat_id] = list(A)
else
GLOB.antag_prototypes[cat_id] += A
GLOB.antagonists -= A // monkestation edit: don't store the prototypes with actual antags
sortTim(GLOB.antag_prototypes, GLOBAL_PROC_REF(cmp_text_asc)) //monkestation edit
sortTim(GLOB.antag_prototypes, GLOBAL_PROC_REF(cmp_text_asc),associative=TRUE)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ GLOBAL_PROTECT(href_token)
owner.remove_admin_verbs()
owner.holder = null
GLOB.mentors -= owner
owner.mentor_datum.owner = null
owner.mentor_datum?.owner = null
owner.mentor_datum = null
owner = null

Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/heretic_antag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
*/
/datum/antagonist/heretic/proc/passive_influence_gain()
knowledge_points++
if(owner.current.stat <= SOFT_CRIT)
if(owner.current?.stat <= SOFT_CRIT)
to_chat(owner.current, "[span_hear("You hear a whisper...")] [span_hypnophrase(pick(strings(HERETIC_INFLUENCE_FILE, "drain_message")))]")
addtimer(CALLBACK(src, PROC_REF(passive_influence_gain)), passive_gain_timer)

Expand Down
8 changes: 4 additions & 4 deletions code/modules/antagonists/heretic/influences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
return SECONDARY_ATTACK_CALL_NORMAL

if(being_drained)
balloon_alert(user, "already being drained!")
loc.balloon_alert(user, "already being drained!")
else
INVOKE_ASYNC(src, PROC_REF(drain_influence), user, 1)

Expand Down Expand Up @@ -288,15 +288,15 @@
/obj/effect/heretic_influence/proc/drain_influence(mob/living/user, knowledge_to_gain)

being_drained = TRUE
balloon_alert(user, "draining influence...")
loc.balloon_alert(user, "draining influence...")

if(!do_after(user, 10 SECONDS, src))
being_drained = FALSE
balloon_alert(user, "interrupted!")
loc.balloon_alert(user, "interrupted!")
return

// We don't need to set being_drained back since we delete after anyways
balloon_alert(user, "influence drained")
loc.balloon_alert(user, "influence drained")

var/datum/antagonist/heretic/heretic_datum = IS_HERETIC(user)
heretic_datum.knowledge_points += knowledge_to_gain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
/datum/component/traitor_objective_register/proc/on_fail(datum/traitor_objective/source)
SIGNAL_HANDLER
var/datum/traitor_objective/objective = parent
objective.fail_objective(penalty)
objective?.fail_objective(penalty)

/datum/component/traitor_objective_register/proc/on_success()
SIGNAL_HANDLER
var/datum/traitor_objective/objective = parent
objective.succeed_objective()
objective?.succeed_objective()

/datum/component/traitor_objective_register/proc/delete_self()
SIGNAL_HANDLER
Expand Down
14 changes: 12 additions & 2 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ GLOBAL_LIST_EMPTY(preferences_datums)

switch (action)
if ("update_body")
character_preview_view?.update_body()
// monkestation start: janky bugfixing for runtimes
if(!QDELETED(character_preview_view))
character_preview_view.update_body()
else
addtimer(CALLBACK(src, PROC_REF(create_character_preview_view), usr), 0.5 SECONDS, TIMER_DELETE_ME)
// monkestation end
if ("change_slot")
// Save existing character
save_character()
Expand All @@ -224,7 +229,12 @@ GLOBAL_LIST_EMPTY(preferences_datums)
for (var/datum/preference_middleware/preference_middleware as anything in middleware)
preference_middleware.on_new_character(usr)

character_preview_view.update_body()
// monkestation start: janky bugfixing for runtimes
if(!QDELETED(character_preview_view))
character_preview_view.update_body()
else
addtimer(CALLBACK(src, PROC_REF(create_character_preview_view), usr), 0.5 SECONDS, TIMER_DELETE_ME)
// monkestation end

return TRUE
if ("rotate")
Expand Down
2 changes: 2 additions & 0 deletions code/modules/jobs/job_types/prisoner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
else if(crime_name == "Random")
crime_name = pick(assoc_to_keys(GLOB.prisoner_crimes))

/* monkestation removal: doesn't work bc manifest gets injected AFTER [COMSIG_GLOB_CREWMEMBER_JOINED]
var/datum/prisoner_crime/crime = GLOB.prisoner_crimes[crime_name]
var/datum/record/crew/target_record = crewmember.mind?.crewfile || find_record(crewmember.real_name)
var/datum/crime/past_crime = new(crime.name, crime.desc, "Central Command", "Indefinite.")
target_record?.crimes += past_crime
target_record.recreate_manifest_photos(add_height_chart = TRUE)
monkestation end */
to_chat(crewmember, span_warning("You are imprisoned for \"[crime_name]\"."))
crewmember.add_mob_memory(/datum/memory/key/permabrig_crimes, crimes = crime_name)

Expand Down
Loading
Loading