diff --git a/code/__defines/is_helpers.dm b/code/__defines/is_helpers.dm index 8689580b04..39cf2aed12 100644 --- a/code/__defines/is_helpers.dm +++ b/code/__defines/is_helpers.dm @@ -1,6 +1,6 @@ #define isdatum(D) istype(D, /datum) -#define isweakref(A) istype(A, /weakref) +#define isweakref(A) istype(A, /datum/weakref) //#define islist(D) istype(D, /list) //Built in diff --git a/code/__defines/vv.dm b/code/__defines/vv.dm index 70ae1ff035..977a282d60 100644 --- a/code/__defines/vv.dm +++ b/code/__defines/vv.dm @@ -55,3 +55,5 @@ // /atom #define VV_HK_ATOM_EXPLODE "turf_explode" #define VV_HK_ATOM_EMP "turf_emp" + +#define VV_HK_WEAKREF_RESOLVE "weakref_resolve" diff --git a/code/_helpers/icons.dm b/code/_helpers/icons.dm index b8c501be26..e51c3572b1 100644 --- a/code/_helpers/icons.dm +++ b/code/_helpers/icons.dm @@ -382,15 +382,15 @@ GLOBAL_LIST_EMPTY(icon_state_lists) GLOBAL_LIST_EMPTY(cached_examine_icons) /proc/set_cached_examine_icon(var/atom/A, var/icon/I, var/expiry = 12000) - GLOB.cached_examine_icons[weakref(A)] = I + GLOB.cached_examine_icons[WEAKREF(A)] = I if(expiry) - addtimer(CALLBACK(GLOBAL_PROC, .proc/uncache_examine_icon, weakref(A)), expiry, TIMER_UNIQUE) + addtimer(CALLBACK(GLOBAL_PROC, .proc/uncache_examine_icon, WEAKREF(A)), expiry, TIMER_UNIQUE) /proc/get_cached_examine_icon(var/atom/A) - var/weakref/WR = weakref(A) + var/datum/weakref/WR = WEAKREF(A) return GLOB.cached_examine_icons[WR] -/proc/uncache_examine_icon(var/weakref/WR) +/proc/uncache_examine_icon(var/datum/weakref/WR) GLOB.cached_examine_icons -= WR /proc/adjust_brightness(var/color, var/value) diff --git a/code/datums/callback.dm b/code/datums/callback.dm index 74d5719ce2..8a904b8b44 100644 --- a/code/datums/callback.dm +++ b/code/datums/callback.dm @@ -44,7 +44,7 @@ var/datum/object = GLOBAL_PROC var/delegate var/list/arguments - var/weakref/user + var/datum/weakref/user /datum/callback/New(thingtocall, proctocall, ...) if (thingtocall) @@ -53,7 +53,7 @@ if (length(args) > 2) arguments = args.Copy(3) if(usr) - user = weakref(usr) + user = WEAKREF(usr) /world/proc/ImmediateInvokeAsync(thingtocall, proctocall, ...) set waitfor = FALSE @@ -70,7 +70,7 @@ /datum/callback/proc/Invoke(...) if(!usr) - var/weakref/W = user + var/datum/weakref/W = user if(W) var/mob/M = W.resolve() if(M) @@ -94,7 +94,7 @@ set waitfor = FALSE if(!usr) - var/weakref/W = user + var/datum/weakref/W = user if(W) var/mob/M = W.resolve() if(M) diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 6f3ed00fbb..4e3fd10a08 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -1,20 +1,48 @@ -// -// datum defines! -// Note: Adding vars to /datum adds a var to EVERYTHING! Don't go overboard. -// - +/** + * The absolute base class for everything + * + * A datum instantiated has no physical world prescence, use an atom if you want something + * that actually lives in the world + * + * Be very mindful about adding variables to this class, they are inherited by every single + * thing in the entire game, and so you can easily cause memory usage to rise a lot with careless + * use of variables at this level + */ /datum - var/gc_destroyed //Time when this object was destroyed. - var/list/active_timers //for SStimer - var/list/datum_components //for /datum/components + /** + * Tick count time when this object was destroyed. + * + * If this is non zero then the object has been garbage collected and is awaiting either + * a hard del by the GC subsystme, or to be autocollected (if it has no references) + */ + var/gc_destroyed + + /// Active timers with this datum as the target + var/list/active_timers + + /** + * Components attached to this datum + * + * Lazy associated list in the structure of `type:component/list of components` + */ + var/list/datum_components + /** + * Any datum registered to receive signals from this datum is in this list + * + * Lazy associated list in the structure of `signal:registree/list of registrees` + */ var/list/comp_lookup var/list/list/signal_procs // List of lists var/signal_enabled = FALSE - var/weakref/weakref // Holder of weakref instance pointing to this datum + + /// Datum level flags var/datum_flags = NONE var/trigger_uid //CHOMPEdit var/status_traits //CHOMPEdit + /// A weak reference to another datum + var/datum/weakref/weak_reference + #ifdef REFERENCE_TRACKING var/tmp/running_find_references var/tmp/last_find_references = 0 @@ -37,7 +65,7 @@ continue qdel(timer) - weakref = null // Clear this reference to ensure it's kept for as brief duration as possible. + weak_reference = null // Clear this reference to ensure it's kept for as brief duration as possible. //BEGIN: ECS SHIT signal_enabled = FALSE diff --git a/code/datums/weakref.dm b/code/datums/weakref.dm deleted file mode 100644 index 6c17c18bca..0000000000 --- a/code/datums/weakref.dm +++ /dev/null @@ -1,26 +0,0 @@ -//obtain a weak reference to a datum -/proc/weakref(datum/D) - if(!istype(D)) - return - if(QDELETED(D)) - return - if(!D.weakref) - D.weakref = new/weakref(D) - return D.weakref - -/weakref - var/ref - -/weakref/New(datum/D) - ref = "\ref[D]" - -/weakref/Destroy() - // A weakref datum should not be manually destroyed as it is a shared resource, - // rather it should be automatically collected by the BYOND GC when all references are gone. - return QDEL_HINT_LETMELIVE - -/weakref/proc/resolve() - var/datum/D = locate(ref) - if(D && D.weakref == src) - return D - return null \ No newline at end of file diff --git a/code/datums/weakrefs.dm b/code/datums/weakrefs.dm new file mode 100644 index 0000000000..27bd5d9433 --- /dev/null +++ b/code/datums/weakrefs.dm @@ -0,0 +1,108 @@ +/// Creates a weakref to the given input. +/// See /datum/weakref's documentation for more information. +/proc/WEAKREF(datum/input) + if(istype(input) && !QDELETED(input)) + if(isweakref(input)) + return input + + if(!input.weak_reference) + input.weak_reference = new /datum/weakref(input) + return input.weak_reference + +/datum/proc/create_weakref() //Forced creation for admin proccalls + return WEAKREF(src) + +/** + * A weakref holds a non-owning reference to a datum. + * The datum can be referenced again using `resolve()`. + * + * To figure out why this is important, you must understand how deletion in + * BYOND works. + * + * Imagine a datum as a TV in a living room. When one person enters to watch + * TV, they turn it on. Others can come into the room and watch the TV. + * When the last person leaves the room, they turn off the TV because it's + * no longer being used. + * + * A datum being deleted tells everyone who's watching the TV to stop. + * If everyone leaves properly (AKA cleaning up their references), then the + * last person will turn off the TV, and everything is well. + * However, if someone is resistant (holds a hard reference after deletion), + * then someone has to walk in, drag them away, and turn off the TV forecefully. + * This process is very slow, and it's known as hard deletion. + * + * This is where weak references come in. Weak references don't count as someone + * watching the TV. Thus, when what it's referencing is destroyed, it will + * hopefully clean up properly, and limit hard deletions. + * + * A common use case for weak references is holding onto what created itself. + * For example, if a machine wanted to know what its last user was, it might + * create a `var/mob/living/last_user`. However, this is a strong reference to + * the mob, and thus will force a hard deletion when that mob is deleted. + * It is often better in this case to instead create a weakref to the user, + * meaning this type definition becomes `var/datum/weakref/last_user`. + * + * A good rule of thumb is that you should hold strong references to things + * that you *own*. For example, a dog holding a chew toy would be the owner + * of that chew toy, and thus a `var/obj/item/chew_toy` reference is fine + * (as long as it is cleaned up properly). + * However, a chew toy does not own its dog, so a `var/mob/living/dog/owner` + * might be inferior to a weakref. + * This is also a good rule of thumb to avoid circular references, such as the + * chew toy example. A circular reference that doesn't clean itself up properly + * will always hard delete. + */ +/datum/weakref + var/reference + +/datum/weakref/New(datum/thing) + reference = REF(thing) + +/datum/weakref/Destroy(force) + var/datum/target = resolve() + qdel(target) + + if(!force) + return QDEL_HINT_LETMELIVE //Let BYOND autoGC thiswhen nothing is using it anymore. + target?.weak_reference = null + return ..() + +/** + * Retrieves the datum that this weakref is referencing. + * + * This will return `null` if the datum was deleted. This MUST be respected. + */ +/datum/weakref/proc/resolve() + var/datum/D = locate(reference) + return (!QDELETED(D) && D.weak_reference == src) ? D : null + +/** + * SERIOUSLY READ THE AUTODOC COMMENT FOR THIS PROC BEFORE EVEN THINKING ABOUT USING IT + * + * Like resolve, but doesn't care if the datum is being qdeleted but hasn't been deleted yet. + * + * The return value of this proc leaves hanging references if the datum is being qdeleted but hasn't been deleted yet. + * + * Do not do anything that would create a lasting reference to the return value, such as giving it a tag, putting it on the map, + * adding it to an atom's contents or vis_contents, giving it a key (if it's a mob), attaching it to an atom (if it's an image), + * or assigning it to a datum or list referenced somewhere other than a temporary value. + * + * Unless you're resolving a weakref to a datum in a COMSIG_PARENT_QDELETING signal handler registered on that very same datum, + * just use resolve instead. + */ +/datum/weakref/proc/hard_resolve() + var/datum/D = locate(reference) + return (D?.weak_reference == src) ? D : null + +/datum/weakref/vv_get_dropdown() + . = ..() + VV_DROPDOWN_OPTION(VV_HK_WEAKREF_RESOLVE, "Go to reference") + +/datum/weakref/vv_do_topic(list/href_list) + . = ..() + if(href_list[VV_HK_WEAKREF_RESOLVE]) + if(!check_rights(NONE)) + return + var/datum/R = resolve() + if(R) + usr.client.debug_variables(R) diff --git a/code/game/gamemodes/technomancer/spells/mark_recall.dm b/code/game/gamemodes/technomancer/spells/mark_recall.dm index 1d7088af4a..ad7eabf8d0 100644 --- a/code/game/gamemodes/technomancer/spells/mark_recall.dm +++ b/code/game/gamemodes/technomancer/spells/mark_recall.dm @@ -9,12 +9,12 @@ category = UTILITY_SPELLS //VOREStation Add - Multiple technomancer support /datum/technomancer_marker - var/weakref/U + var/datum/weakref/U var/image/I var/turf/T /datum/technomancer_marker/New(var/mob/user) - U = weakref(user) + U = WEAKREF(user) T = get_turf(user) I = image('icons/goonstation/featherzone.dmi', T, "spawn-wall") I.plane = TURF_PLANE @@ -46,7 +46,7 @@ GLOBAL_LIST_INIT(mark_spells, list()) return 0 if(pay_energy(1000)) //VOREStation Add - Multiple technomancer support - var/datum/technomancer_marker/marker = GLOB.mark_spells[weakref(user)] + var/datum/technomancer_marker/marker = GLOB.mark_spells[WEAKREF(user)] //They have one in the list if(istype(marker)) qdel(marker) @@ -54,7 +54,7 @@ GLOBAL_LIST_INIT(mark_spells, list()) //They don't have one yet else to_chat(user, "You mark \the [get_turf(user)] under you.") - GLOB.mark_spells[weakref(user)] = new /datum/technomancer_marker(user) + GLOB.mark_spells[WEAKREF(user)] = new /datum/technomancer_marker(user) //VOREStation Add End adjust_instability(5) return 1 @@ -83,7 +83,7 @@ GLOBAL_LIST_INIT(mark_spells, list()) /obj/item/weapon/spell/recall/on_use_cast(var/mob/living/user) if(pay_energy(3000)) - var/datum/technomancer_marker/marker = GLOB.mark_spells[weakref(user)] //VOREStation Add - Multiple technomancer support + var/datum/technomancer_marker/marker = GLOB.mark_spells[WEAKREF(user)] //VOREStation Add - Multiple technomancer support if(!istype(marker)) to_chat(user, "There's no Mark!") return 0 @@ -128,4 +128,3 @@ GLOBAL_LIST_INIT(mark_spells, list()) else to_chat(user, "You can't afford the energy cost!") return 0 - diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 765f6de69b..3af4562f09 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -80,10 +80,10 @@ GLOBAL_LIST_EMPTY(entertainment_screens) network = list(NETWORK_THUNDER) circuit = /obj/item/weapon/circuitboard/security/telescreen/entertainment camera_datum_type = /datum/tgui_module/camera/bigscreen - + var/obj/item/device/radio/radio = null var/obj/effect/overlay/vis/pinboard - var/weakref/showing + var/datum/weakref/showing var/enabled = TRUE // on or off @@ -93,7 +93,7 @@ GLOBAL_LIST_EMPTY(entertainment_screens) var/static/icon/mask = icon('icons/obj/entertainment_monitor.dmi', "mask") add_overlay("glass") - + pinboard = new() pinboard.icon = icon pinboard.icon_state = "pinboard" @@ -147,7 +147,7 @@ GLOBAL_LIST_EMPTY(entertainment_screens) stop_showing() if(stat & NOPOWER) return - showing = weakref(thing) + showing = WEAKREF(thing) pinboard.vis_contents = list(thing) /obj/machinery/computer/security/telescreen/entertainment/proc/stop_showing() @@ -155,7 +155,7 @@ GLOBAL_LIST_EMPTY(entertainment_screens) pinboard.vis_contents = null showing = null -/obj/machinery/computer/security/telescreen/entertainment/proc/maybe_stop_showing(weakref/thingref) +/obj/machinery/computer/security/telescreen/entertainment/proc/maybe_stop_showing(datum/weakref/thingref) if(showing == thingref) stop_showing() diff --git a/code/game/machinery/pointdefense.dm b/code/game/machinery/pointdefense.dm index aee8710c05..e249697272 100644 --- a/code/game/machinery/pointdefense.dm +++ b/code/game/machinery/pointdefense.dm @@ -139,7 +139,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) var/last_shot = 0 var/kill_range = 18 var/rotation_speed = 4.5 SECONDS //How quickly we turn to face threats - var/weakref/engaging = null // The meteor we're shooting at + var/datum/weakref/engaging = null // The meteor we're shooting at var/id_tag = null /obj/machinery/pointdefense/Initialize() @@ -199,7 +199,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) return FALSE return TRUE -/obj/machinery/pointdefense/proc/Shoot(var/weakref/target) +/obj/machinery/pointdefense/proc/Shoot(var/datum/weakref/target) var/obj/effect/meteor/M = target.resolve() if(!istype(M)) engaging = null @@ -213,7 +213,8 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) set_dir(ATAN2(transform.b, transform.a) > 0 ? NORTH : SOUTH) -/obj/machinery/pointdefense/proc/finish_shot(var/weakref/target) +/obj/machinery/pointdefense/proc/finish_shot(var/datum/weakref/target) + var/obj/machinery/pointdefense_control/PC = get_controller() engaging = null PC.targets -= target @@ -255,7 +256,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) // Compile list of known targets var/list/existing_targets = list() - for(var/weakref/WR in PC.targets) + for(var/datum/weakref/WR in PC.targets) var/obj/effect/meteor/M = WR.resolve() existing_targets += M @@ -263,7 +264,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) var/list/potential_targets = GLOB.meteor_list.Copy() - existing_targets for(var/obj/effect/meteor/M in potential_targets) if(targeting_check(M)) - var/weakref/target = weakref(M) + var/datum/weakref/target = WEAKREF(M) PC.targets += target engaging = target Shoot(target) @@ -272,7 +273,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) // Then, focus fire on existing targets for(var/obj/effect/meteor/M in existing_targets) if(targeting_check(M)) - var/weakref/target = weakref(M) + var/datum/weakref/target = WEAKREF(M) engaging = target Shoot(target) return diff --git a/code/game/machinery/telecomms/broadcaster.dm b/code/game/machinery/telecomms/broadcaster.dm index 50e92b99e4..8a3fcc8c23 100644 --- a/code/game/machinery/telecomms/broadcaster.dm +++ b/code/game/machinery/telecomms/broadcaster.dm @@ -37,7 +37,7 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept /obj/machinery/telecomms/broadcaster/proc/link_radio(var/obj/item/device/radio/R) if(!istype(R)) return - linked_radios_weakrefs |= weakref(R) + linked_radios_weakrefs |= WEAKREF(R) /obj/machinery/telecomms/broadcaster/receive_information(datum/signal/signal, obj/machinery/telecomms/machine_from) // Don't broadcast rejected signals @@ -66,7 +66,7 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept signal.data["level"] |= using_map.get_map_levels(listening_level, TRUE, overmap_range) var/list/forced_radios - for(var/weakref/wr in linked_radios_weakrefs) + for(var/datum/weakref/wr in linked_radios_weakrefs) var/obj/item/device/radio/R = wr.resolve() if(istype(R)) LAZYDISTINCTADD(forced_radios, R) @@ -149,7 +149,7 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept /obj/machinery/telecomms/allinone/proc/link_radio(var/obj/item/device/radio/R) if(!istype(R)) return - linked_radios_weakrefs |= weakref(R) + linked_radios_weakrefs |= WEAKREF(R) /obj/machinery/telecomms/allinone/receive_signal(datum/signal/signal) @@ -197,7 +197,7 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept var/datum/radio_frequency/connection = signal.data["connection"] var/list/forced_radios - for(var/weakref/wr in linked_radios_weakrefs) + for(var/datum/weakref/wr in linked_radios_weakrefs) var/obj/item/device/radio/R = wr.resolve() if(istype(R)) LAZYDISTINCTADD(forced_radios, R) @@ -255,7 +255,7 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept var/datum/radio_frequency/connection = signal.data["connection"] var/list/forced_radios - for(var/weakref/wr in linked_radios_weakrefs) + for(var/datum/weakref/wr in linked_radios_weakrefs) var/obj/item/device/radio/R = wr.resolve() if(istype(R)) LAZYDISTINCTADD(forced_radios, R) @@ -761,4 +761,3 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept //to_world_log("Level: [signal.data["level"]] - Done: [signal.data["done"]]") return signal - diff --git a/code/game/machinery/telecomms/broadcaster_ch.dm b/code/game/machinery/telecomms/broadcaster_ch.dm index 6875970519..5d24798c42 100644 --- a/code/game/machinery/telecomms/broadcaster_ch.dm +++ b/code/game/machinery/telecomms/broadcaster_ch.dm @@ -46,7 +46,7 @@ var/datum/radio_frequency/connection = signal.data["connection"] var/list/forced_radios - for(var/weakref/wr in linked_radios_weakrefs) + for(var/datum/weakref/wr in linked_radios_weakrefs) var/obj/item/device/radio/R = wr.resolve() if(istype(R)) LAZYDISTINCTADD(forced_radios, R) @@ -69,4 +69,4 @@ signal.data["verb"], signal.data["language"], forced_radios - ) \ No newline at end of file + ) diff --git a/code/game/machinery/telecomms/broadcaster_vr.dm b/code/game/machinery/telecomms/broadcaster_vr.dm index 4bdccfbc80..3751ffacdf 100644 --- a/code/game/machinery/telecomms/broadcaster_vr.dm +++ b/code/game/machinery/telecomms/broadcaster_vr.dm @@ -31,7 +31,7 @@ var/datum/radio_frequency/connection = signal.data["connection"] var/list/forced_radios - for(var/weakref/wr in linked_radios_weakrefs) + for(var/datum/weakref/wr in linked_radios_weakrefs) var/obj/item/device/radio/R = wr.resolve() if(istype(R)) LAZYDISTINCTADD(forced_radios, R) diff --git a/code/game/machinery/telecomms/telecomunications.dm b/code/game/machinery/telecomms/telecomunications.dm index 784a752bda..e23f7dd8b2 100644 --- a/code/game/machinery/telecomms/telecomunications.dm +++ b/code/game/machinery/telecomms/telecomunications.dm @@ -272,7 +272,7 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list() /obj/machinery/telecomms/receiver/proc/link_radio(var/obj/item/device/radio/R) if(!istype(R)) return - linked_radios_weakrefs |= weakref(R) + linked_radios_weakrefs |= WEAKREF(R) /obj/machinery/telecomms/receiver/receive_signal(datum/signal/signal) if(!on) // has to be on to receive messages @@ -299,7 +299,7 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list() var/obj/item/device/radio/R = signal.data["radio"] //Who're you? - if(!(weakref(R) in linked_radios_weakrefs)) + if(!(WEAKREF(R) in linked_radios_weakrefs)) signal.data["reject"] = 1 return 0 diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 4810ea8375..5ed66e138c 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -56,7 +56,7 @@ var/global/list/default_medbay_channels = list( // Bluespace radios talk directly to telecomms equipment var/bluespace_radio = FALSE - var/weakref/bs_tx_weakref //Maybe misleading, this is the device to TRANSMIT TO + var/datum/weakref/bs_tx_weakref //Maybe misleading, this is the device to TRANSMIT TO // For mappers or subtypes, to start them prelinked to these devices var/bs_tx_preload_id var/bs_rx_preload_id @@ -104,14 +104,14 @@ var/global/list/default_medbay_channels = list( //Try to find a receiver for(var/obj/machinery/telecomms/receiver/RX in telecomms_list) if(RX.id == bs_tx_preload_id) //Again, bs_tx is the thing to TRANSMIT TO, so a receiver. - bs_tx_weakref = weakref(RX) + bs_tx_weakref = WEAKREF(RX) RX.link_radio(src) break //Hmm, howabout an AIO machine if(!bs_tx_weakref) for(var/obj/machinery/telecomms/allinone/AIO in telecomms_list) if(AIO.id == bs_tx_preload_id) - bs_tx_weakref = weakref(AIO) + bs_tx_weakref = WEAKREF(AIO) AIO.link_radio(src) break if(!bs_tx_weakref) diff --git a/code/game/objects/items/devices/tvcamera.dm b/code/game/objects/items/devices/tvcamera.dm index a9e5613a92..bacf8a6b83 100644 --- a/code/game/objects/items/devices/tvcamera.dm +++ b/code/game/objects/items/devices/tvcamera.dm @@ -8,7 +8,7 @@ var/channel = "NCS Northern Star News Feed" var/obj/machinery/camera/network/thunder/camera var/obj/item/device/radio/radio - var/weakref/showing + var/datum/weakref/showing var/showing_name /obj/item/device/tvcamera/New() @@ -95,7 +95,7 @@ if(showing) hide_tvs(showing) - showing = weakref(thing) + showing = WEAKREF(thing) showing_name = "[thing]" for(var/obj/machinery/computer/security/telescreen/entertainment/ES as anything in GLOB.entertainment_screens) ES.show_thing(thing) @@ -221,4 +221,3 @@ return ..() - diff --git a/code/game/objects/items/uav.dm b/code/game/objects/items/uav.dm index f534ff9a42..2dc4cad3ee 100644 --- a/code/game/objects/items/uav.dm +++ b/code/game/objects/items/uav.dm @@ -48,10 +48,10 @@ /obj/item/device/uav/Initialize() . = ..() - + if(!cell && cell_type) cell = new cell_type - + ion_trail = new /datum/effect/effect/system/ion_trail_follow() ion_trail.set_up(src) ion_trail.stop() @@ -69,7 +69,7 @@ . += "It has '[nickname]' scribbled on the side." if(!cell) . += "It appears to be missing a power cell." - + if(health <= (initial(health)/4)) . += "It looks like it might break at any second!" else if(health <= (initial(health)/2)) @@ -86,7 +86,7 @@ "Toggle Power" = radial_power, "Pairing Mode" = radial_pair) var/choice = show_radial_menu(user, src, options, require_near = !issilicon(user)) - + switch(choice) // Can pick up when off or packed if("Pick Up") @@ -113,11 +113,11 @@ /obj/item/device/uav/attackby(var/obj/item/I, var/mob/user) if(istype(I, /obj/item/modular_computer) && state == UAV_PAIRING) var/obj/item/modular_computer/MC = I - LAZYDISTINCTADD(MC.paired_uavs, weakref(src)) + LAZYDISTINCTADD(MC.paired_uavs, WEAKREF(src)) playsound(src, 'sound/machines/buttonbeep.ogg', 50, 1) visible_message("[user] pairs [I] to [nickname]") toggle_pairing() - + else if(I.is_screwdriver() && cell) if(do_after(user, 3 SECONDS, src)) to_chat(user, "You remove [cell] into [nickname].") @@ -125,7 +125,7 @@ power_down() cell.forceMove(get_turf(src)) cell = null - + else if(istype(I, /obj/item/weapon/cell) && !cell) if(do_after(user, 3 SECONDS, src)) to_chat(user, "You insert [I] into [nickname].") @@ -185,7 +185,7 @@ playsound(src, 'sound/items/drop/metalboots.ogg', 75, 1) power_down() health -= initial(health)*0.25 //Lose 25% of your original health - + if(LAZYLEN(masters)) no_masters_time = 0 else if(no_masters_time++ > 50) @@ -251,7 +251,7 @@ /obj/item/device/uav/proc/power_down() if(state != UAV_ON) return - + state = UAV_OFF update_icon() stop_hover() @@ -265,7 +265,7 @@ return cell /obj/item/device/uav/relaymove(var/mob/user, direction, signal = 1) - if(signal && state == UAV_ON && (weakref(user) in masters)) + if(signal && state == UAV_ON && (WEAKREF(user) in masters)) if(next_move <= world.time) next_move = world.time + (1 SECOND/signal) step(src, direction) @@ -276,10 +276,10 @@ return "[nickname] - [get_x(src)],[get_y(src)],[get_z(src)] - I:[health]/[initial(health)] - C:[cell ? "[cell.charge]/[cell.maxcharge]" : "Not Installed"]" /obj/item/device/uav/proc/add_master(var/mob/living/M) - LAZYDISTINCTADD(masters, weakref(M)) + LAZYDISTINCTADD(masters, WEAKREF(M)) /obj/item/device/uav/proc/remove_master(var/mob/living/M) - LAZYREMOVE(masters, weakref(M)) + LAZYREMOVE(masters, WEAKREF(M)) /obj/item/device/uav/check_eye() if(state == UAV_ON) @@ -310,7 +310,7 @@ /obj/item/device/uav/hear_talk(var/mob/M, list/message_pieces, verb) var/name_used = M.GetVoice() for(var/wr_master in masters) - var/weakref/wr = wr_master + var/datum/weakref/wr = wr_master var/mob/master = wr.resolve() var/list/combined = master.combine_message(message_pieces, verb, M) var/message = combined["formatted"] @@ -319,14 +319,14 @@ /obj/item/device/uav/see_emote(var/mob/living/M, text) for(var/wr_master in masters) - var/weakref/wr = wr_master + var/datum/weakref/wr = wr_master var/mob/master = wr.resolve() var/rendered = "UAV received, [text]" master.show_message(rendered, 2) /obj/item/device/uav/show_message(msg, type, alt, alt_type) for(var/wr_master in masters) - var/weakref/wr = wr_master + var/datum/weakref/wr = wr_master var/mob/master = wr.resolve() var/rendered = "UAV received, [msg]" master.show_message(rendered, type) @@ -365,4 +365,4 @@ #undef UAV_OFF #undef UAV_ON -#undef UAV_PACKED \ No newline at end of file +#undef UAV_PACKED diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index b7c462e73d..7283cece2e 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -862,12 +862,12 @@ plane = PLANE_PLAYER_HUD_ITEMS layer = 0.1 alpha = 200 - var/weakref/held_item + var/datum/weakref/held_item /atom/movable/storage_slot/New(newloc, obj/item/held_item) ASSERT(held_item) name += held_item.name - src.held_item = weakref(held_item) + src.held_item = WEAKREF(held_item) /atom/movable/storage_slot/Destroy() held_item = null diff --git a/code/modules/catalogue/cataloguer.dm b/code/modules/catalogue/cataloguer.dm index 358df4c455..31bd557e1e 100644 --- a/code/modules/catalogue/cataloguer.dm +++ b/code/modules/catalogue/cataloguer.dm @@ -32,7 +32,7 @@ GLOBAL_LIST_EMPTY(all_cataloguers) var/datum/category_item/catalogue/displayed_data = null // Used for viewing a piece of data in the UI. var/busy = FALSE // Set to true when scanning, to stop multiple scans. var/debug = FALSE // If true, can view all catalogue data defined, regardless of unlock status. - var/weakref/partial_scanned = null // Weakref of the thing that was last scanned if inturrupted. Used to allow for partial scans to be resumed. + var/datum/weakref/partial_scanned = null // Weakref of the thing that was last scanned if inturrupted. Used to allow for partial scans to be resumed. var/partial_scan_time = 0 // How much to make the next scan shorter. /obj/item/device/cataloguer/advanced @@ -130,7 +130,7 @@ GLOBAL_LIST_EMPTY(all_cataloguers) to_chat(user, span("warning", "You failed to finish scanning \the [target] with \the [src].")) playsound(src, 'sound/machines/buzz-two.ogg', 50) color_box(box_segments, "#FF0000", 3) - partial_scanned = weakref(target) + partial_scanned = WEAKREF(target) partial_scan_time += world.time - scan_start_time // This is added to the existing value so two partial scans will add up correctly. sleep(3) busy = FALSE diff --git a/code/modules/gamemaster/event2/events/engineering/blob.dm b/code/modules/gamemaster/event2/events/engineering/blob.dm index f3b8a16f8d..048c073f39 100644 --- a/code/modules/gamemaster/event2/events/engineering/blob.dm +++ b/code/modules/gamemaster/event2/events/engineering/blob.dm @@ -106,19 +106,19 @@ for(var/i = 1 to number_of_blobs) var/turf/T = pick(open_turfs) var/obj/structure/blob/core/new_blob = new spawn_blob_type(T) - blobs += weakref(new_blob) + blobs += WEAKREF(new_blob) open_turfs -= T // So we can't put two cores on the same tile if doing multiblob. log_debug("Spawned [new_blob.overmind.blob_type.name] blob at [get_area(new_blob)].") /datum/event2/event/blob/should_end() - for(var/weakref/weakref as anything in blobs) + for(var/datum/weakref/weakref as anything in blobs) if(weakref.resolve()) // If the weakref is resolvable, that means the blob hasn't been deleted yet. return FALSE return TRUE // Only end if all blobs die. // Normally this does nothing, but is useful if aborted by an admin. /datum/event2/event/blob/end() - for(var/weakref/weakref as anything in blobs) + for(var/datum/weakref/weakref as anything in blobs) var/obj/structure/blob/core/B = weakref.resolve() if(istype(B)) qdel(B) @@ -128,7 +128,7 @@ var/danger_level = 0 var/list/blob_type_names = list() var/multiblob = FALSE - for(var/weakref/weakref as anything in blobs) + for(var/datum/weakref/weakref as anything in blobs) var/obj/structure/blob/core/B = weakref.resolve() if(!istype(B)) continue diff --git a/code/modules/integrated_electronics/core/assemblies.dm b/code/modules/integrated_electronics/core/assemblies.dm index 1f08f1dec5..20802b90cc 100644 --- a/code/modules/integrated_electronics/core/assemblies.dm +++ b/code/modules/integrated_electronics/core/assemblies.dm @@ -263,7 +263,7 @@ if(proximity) var/scanned = FALSE for(var/obj/item/integrated_circuit/input/sensor/S in contents) -// S.set_pin_data(IC_OUTPUT, 1, weakref(target)) +// S.set_pin_data(IC_OUTPUT, 1, WEAKREF(target)) // S.check_then_do_work() if(S.scan(target)) scanned = TRUE @@ -397,4 +397,4 @@ // Returns TRUE if I is something that could/should have a valid interaction. Used to tell circuitclothes to hit the circuit with something instead of the clothes /obj/item/device/electronic_assembly/proc/is_valid_tool(var/obj/item/I) - return I.is_crowbar() || I.is_screwdriver() || istype(I, /obj/item/integrated_circuit) || istype(I, /obj/item/weapon/cell/device) || istype(I, /obj/item/device/integrated_electronics) \ No newline at end of file + return I.is_crowbar() || I.is_screwdriver() || istype(I, /obj/item/integrated_circuit) || istype(I, /obj/item/weapon/cell/device) || istype(I, /obj/item/device/integrated_electronics) diff --git a/code/modules/integrated_electronics/core/helpers.dm b/code/modules/integrated_electronics/core/helpers.dm index 8af8f11fba..92d011e08c 100644 --- a/code/modules/integrated_electronics/core/helpers.dm +++ b/code/modules/integrated_electronics/core/helpers.dm @@ -21,7 +21,7 @@ /obj/item/integrated_circuit/proc/set_pin_data(var/pin_type, var/pin_number, datum/new_data) if (istype(new_data) && !isweakref(new_data)) - new_data = weakref(new_data) + new_data = WEAKREF(new_data) var/datum/integrated_io/pin = get_pin_ref(pin_type, pin_number) return pin.write_data_to_pin(new_data) @@ -72,4 +72,4 @@ if(pin) debugger.write_data(pin, usr) return 1 - return 0 \ No newline at end of file + return 0 diff --git a/code/modules/integrated_electronics/core/pins.dm b/code/modules/integrated_electronics/core/pins.dm index 1d972fa0d7..cc5cee7672 100644 --- a/code/modules/integrated_electronics/core/pins.dm +++ b/code/modules/integrated_electronics/core/pins.dm @@ -21,7 +21,7 @@ D [1]/ || /datum/integrated_io var/name = "input/output" var/obj/item/integrated_circuit/holder = null - var/weakref/data = null // This is a weakref, to reduce typecasts. Note that oftentimes numbers and text may also occupy this. + var/datum/weakref/data = null // This is a weakref, to reduce typecasts. Note that oftentimes numbers and text may also occupy this. var/list/linked = list() var/io_type = DATA_CHANNEL @@ -47,7 +47,7 @@ D [1]/ || /datum/integrated_io/proc/data_as_type(var/as_type) if(!isweakref(data)) return - var/weakref/w = data + var/datum/weakref/w = data var/output = w.resolve() return istype(output, as_type) ? output : null @@ -82,7 +82,7 @@ list[]( return result if(isweakref(input)) - var/weakref/w = input + var/datum/weakref/w = input var/atom/A = w.resolve() //return A ? "([A.name] \[Ref\])" : "(null)" // For refs, we want just the name displayed. return A ? "(\ref[A] \[Ref\])" : "(null)" diff --git a/code/modules/integrated_electronics/core/tools.dm b/code/modules/integrated_electronics/core/tools.dm index a575818adc..b71158a541 100644 --- a/code/modules/integrated_electronics/core/tools.dm +++ b/code/modules/integrated_electronics/core/tools.dm @@ -143,7 +143,7 @@ /obj/item/device/integrated_electronics/debugger/afterattack(atom/target, mob/living/user, proximity) if(accepting_refs && proximity) - data_to_write = weakref(target) + data_to_write = WEAKREF(target) visible_message("[user] slides \a [src]'s over \the [target].") to_chat(user, "You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \ now off.") @@ -154,7 +154,7 @@ io.write_data_to_pin(data_to_write) var/data_to_show = data_to_write if(isweakref(data_to_write)) - var/weakref/w = data_to_write + var/datum/weakref/w = data_to_write var/atom/A = w.resolve() data_to_show = A.name to_chat(user, "You write '[data_to_write ? data_to_show : "NULL"]' to the '[io]' pin of \the [io.holder].") @@ -244,7 +244,7 @@ /obj/item/device/multitool/afterattack(atom/target, mob/living/user, proximity) if(accepting_refs && toolmode == MULTITOOL_MODE_INTCIRCUITS && proximity) - weakref_wiring = weakref(target) + weakref_wiring = WEAKREF(target) visible_message("[user] slides \a [src]'s over \the [target].") to_chat(user, "You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \ now off.") diff --git a/code/modules/integrated_electronics/passive/power.dm b/code/modules/integrated_electronics/passive/power.dm index 37ef0b647d..1045dc7597 100644 --- a/code/modules/integrated_electronics/passive/power.dm +++ b/code/modules/integrated_electronics/passive/power.dm @@ -149,7 +149,7 @@ create_reagents(volume) /obj/item/integrated_circuit/passive/power/chemical_cell/interact(mob/user) - set_pin_data(IC_OUTPUT, 2, weakref(src)) + set_pin_data(IC_OUTPUT, 2, WEAKREF(src)) push_data() ..() diff --git a/code/modules/integrated_electronics/subtypes/converters.dm b/code/modules/integrated_electronics/subtypes/converters.dm index ada8eadbc6..b9026e54c3 100644 --- a/code/modules/integrated_electronics/subtypes/converters.dm +++ b/code/modules/integrated_electronics/subtypes/converters.dm @@ -97,7 +97,7 @@ /obj/item/integrated_circuit/converter/refdecode/do_work() pull_data() - set_pin_data(IC_OUTPUT, 1, weakref(locate(get_pin_data(IC_INPUT, 1)))) + set_pin_data(IC_OUTPUT, 1, WEAKREF(locate(get_pin_data(IC_INPUT, 1)))) push_data() activate_pin(2) @@ -391,4 +391,4 @@ set_pin_data(IC_OUTPUT, 1, result) push_data() - activate_pin(2) \ No newline at end of file + activate_pin(2) diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index c0ac9817fa..c8bb294830 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -235,7 +235,7 @@ O.data = null if(assembly) if(istype(assembly.loc, /mob/living)) // Now check if someone's holding us. - O.data = weakref(assembly.loc) + O.data = WEAKREF(assembly.loc) O.push_data() @@ -272,7 +272,7 @@ continue valid_things.Add(thing) if(valid_things.len) - O.data = weakref(pick(valid_things)) + O.data = WEAKREF(pick(valid_things)) activate_pin(2) else activate_pin(3) @@ -321,7 +321,7 @@ if(findtext(addtext(thing.name," ",thing.desc), DT, 1, 0) ) valid_things.Add(thing) if(valid_things.len) - O.data = weakref(pick(valid_things)) + O.data = WEAKREF(pick(valid_things)) O.push_data() activate_pin(2) else @@ -552,7 +552,7 @@ // as a translation, when it is not. if(S.speaking && !istype(S.speaking, /datum/language/common)) translated = TRUE - set_pin_data(IC_OUTPUT , 1, weakref(M))//CHOMPADDITION: so we can target the speaker with an action + set_pin_data(IC_OUTPUT , 1, WEAKREF(M))//CHOMPADDITION: so we can target the speaker with an action set_pin_data(IC_OUTPUT, 2, M.GetVoice()) set_pin_data(IC_OUTPUT, 3, msg) @@ -605,7 +605,7 @@ for(var/datum/multilingual_say_piece/S in message_pieces) if(!((S.speaking.flags & NONVERBAL) || (S.speaking.flags & SIGNLANG))||S.speaking.name == LANGUAGE_ECHOSONG) //Ignore verbal languages return - set_pin_data(IC_OUTPUT , 1, weakref(M))//CHOMPADDITION: so we can target the speaker with an action + set_pin_data(IC_OUTPUT , 1, WEAKREF(M))//CHOMPADDITION: so we can target the speaker with an action set_pin_data(IC_OUTPUT, 2, M.GetVoice()) set_pin_data(IC_OUTPUT, 3, msg) @@ -648,7 +648,7 @@ if(istype(A, /obj/item/weapon/storage)) return FALSE - set_pin_data(IC_OUTPUT, 1, weakref(A)) + set_pin_data(IC_OUTPUT, 1, WEAKREF(A)) push_data() activate_pin(1) return TRUE @@ -676,7 +676,7 @@ set_pin_data(IC_OUTPUT, 1, null) set_pin_data(IC_OUTPUT, 2, null) set_pin_data(IC_OUTPUT, 3, null) - set_pin_data(IC_OUTPUT, 4, weakref(assembly)) + set_pin_data(IC_OUTPUT, 4, WEAKREF(assembly)) if(assembly) if(assembly.battery) diff --git a/code/modules/integrated_electronics/subtypes/memory.dm b/code/modules/integrated_electronics/subtypes/memory.dm index 022eeb3da9..ea9e083a65 100644 --- a/code/modules/integrated_electronics/subtypes/memory.dm +++ b/code/modules/integrated_electronics/subtypes/memory.dm @@ -118,8 +118,8 @@ /obj/item/integrated_circuit/memory/constant/afterattack(atom/target, mob/living/user, proximity) if(accepting_refs && proximity) var/datum/integrated_io/O = outputs[1] - O.data = weakref(target) + O.data = WEAKREF(target) visible_message("[user] slides \a [src]'s over \the [target].") to_chat(user, "You set \the [src]'s memory to a reference to [O.display_data(O.data)]. The ref scanner is \ now off.") - accepting_refs = 0 \ No newline at end of file + accepting_refs = 0 diff --git a/code/modules/integrated_electronics/subtypes/reagents.dm b/code/modules/integrated_electronics/subtypes/reagents.dm index b7fc6ae0b6..fb74ae9eb9 100644 --- a/code/modules/integrated_electronics/subtypes/reagents.dm +++ b/code/modules/integrated_electronics/subtypes/reagents.dm @@ -32,7 +32,7 @@ /obj/item/integrated_circuit/reagent/smoke/interact(mob/user) - set_pin_data(IC_OUTPUT, 2, weakref(src)) + set_pin_data(IC_OUTPUT, 2, WEAKREF(src)) push_data() ..() @@ -66,7 +66,7 @@ var/transfer_amount = 10 /obj/item/integrated_circuit/reagent/injector/interact(mob/user) - set_pin_data(IC_OUTPUT, 2, weakref(src)) + set_pin_data(IC_OUTPUT, 2, WEAKREF(src)) push_data() ..() @@ -251,7 +251,7 @@ /obj/item/integrated_circuit/reagent/storage/interact(mob/user) - set_pin_data(IC_OUTPUT, 2, weakref(src)) + set_pin_data(IC_OUTPUT, 2, WEAKREF(src)) push_data() ..() @@ -356,6 +356,3 @@ source.reagents.trans_id_to(target, G.id, transfer_amount) activate_pin(2) push_data() - - - diff --git a/code/modules/mob/_modifiers/modifiers.dm b/code/modules/mob/_modifiers/modifiers.dm index 56422efdf6..d49ff28874 100644 --- a/code/modules/mob/_modifiers/modifiers.dm +++ b/code/modules/mob/_modifiers/modifiers.dm @@ -7,7 +7,7 @@ var/desc = null // Ditto. var/icon_state = null // See above. var/mob/living/holder = null // The mob that this datum is affecting. - var/weakref/origin = null // A weak reference to whatever caused the modifier to appear. THIS NEEDS TO BE A MOB/LIVING. It's a weakref to not interfere with qdel(). + var/datum/weakref/origin = null // A weak reference to whatever caused the modifier to appear. THIS NEEDS TO BE A MOB/LIVING. It's a weakref to not interfere with qdel(). var/expire_at = null // world.time when holder's Life() will remove the datum. If null, it lasts forever or until it gets deleted by something else. var/on_created_text = null // Text to show to holder upon being created. var/on_expired_text = null // Text to show to holder when it expires. @@ -68,9 +68,9 @@ /datum/modifier/New(var/new_holder, var/new_origin) holder = new_holder if(new_origin) - origin = weakref(new_origin) + origin = WEAKREF(new_origin) else // We assume the holder caused the modifier if not told otherwise. - origin = weakref(holder) + origin = WEAKREF(holder) ..() // Checks if the modifier should be allowed to be applied to the mob before attaching it. diff --git a/code/modules/mob/living/bot/cleanbot.dm b/code/modules/mob/living/bot/cleanbot.dm index bd210756d6..410d11baa1 100644 --- a/code/modules/mob/living/bot/cleanbot.dm +++ b/code/modules/mob/living/bot/cleanbot.dm @@ -41,7 +41,7 @@ visible_message("Something flies out of [src]. It seems to be acting oddly.") var/obj/effect/decal/cleanable/blood/gibs/gib = new /obj/effect/decal/cleanable/blood/gibs(loc) // TODO - I have a feeling weakrefs will not work in ignore_list, verify this ~Leshana - var/weakref/g = weakref(gib) + var/datum/weakref/g = WEAKREF(gib) ignore_list += g spawn(600) ignore_list -= g diff --git a/code/modules/mob/living/silicon/robot/subtypes/thinktank/_thinktank.dm b/code/modules/mob/living/silicon/robot/subtypes/thinktank/_thinktank.dm index 4efce708e8..d9d38faae2 100644 --- a/code/modules/mob/living/silicon/robot/subtypes/thinktank/_thinktank.dm +++ b/code/modules/mob/living/silicon/robot/subtypes/thinktank/_thinktank.dm @@ -1,5 +1,5 @@ // Spawner landmarks are used because platforms that are mapped during -// SSatoms init try to Initialize() twice. I have no idea why and I am +// SSatoms init try to Initialize() twice. I have no idea why and I am // not paid enough to spend more time trying to debug it. /obj/effect/landmark/robot_platform name = "recon platform spawner" @@ -40,7 +40,7 @@ var/tmp/recharge_complete = FALSE var/tmp/recharger_charge_amount = 10 KILOWATTS var/tmp/recharger_tick_cost = 80 KILOWATTS - var/weakref/recharging + var/datum/weakref/recharging var/list/stored_atoms var/max_stored_atoms = 1 @@ -82,7 +82,7 @@ components["armour"] = new /datum/robot_component/armour/platform(src) /mob/living/silicon/robot/platform/Destroy() - for(var/weakref/drop_ref in stored_atoms) + for(var/datum/weakref/drop_ref in stored_atoms) var/atom/movable/drop_atom = drop_ref.resolve() if(istype(drop_atom) && !QDELETED(drop_atom) && drop_atom.loc == src) drop_atom.dropInto(loc) @@ -110,7 +110,7 @@ if(length(stored_atoms)) var/list/atom_names = list() - for(var/weakref/stored_ref in stored_atoms) + for(var/datum/weakref/stored_ref in stored_atoms) var/atom/movable/AM = stored_ref.resolve() if(istype(AM)) atom_names += "\a [AM]" diff --git a/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_interactions.dm b/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_interactions.dm index 852c09ff61..cc4ca44253 100644 --- a/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_interactions.dm +++ b/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_interactions.dm @@ -22,7 +22,7 @@ to_chat(user, SPAN_WARNING("\The [src] already has \a [recharging.resolve()] inserted into its recharging port.")) else if(user.unEquip(W)) W.forceMove(src) - recharging = weakref(W) + recharging = WEAKREF(W) recharge_complete = FALSE user.visible_message("\The [user] slots \the [W] into \the [src]'s recharging port.") return TRUE @@ -43,7 +43,7 @@ if(jobban_isbanned(user, "Robot")) to_chat(user, SPAN_WARNING("You are banned from synthetic roles and cannot take control of \the [src].")) - return + return // Boilerplate from drone fabs, unsure if there's a shared proc to use instead. var/deathtime = world.time - user.timeofdeath diff --git a/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_storage.dm b/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_storage.dm index 6ffe75bfe3..27af8c1590 100644 --- a/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_storage.dm +++ b/code/modules/mob/living/silicon/robot/subtypes/thinktank/thinktank_storage.dm @@ -10,7 +10,7 @@ recharging = null if(length(stored_atoms)) - for(var/weakref/stored_ref in stored_atoms) + for(var/datum/weakref/stored_ref in stored_atoms) var/atom/movable/dropping = stored_ref.resolve() if(istype(dropping) && !QDELETED(dropping) && dropping.loc == src) dropping.dropInto(loc) @@ -67,18 +67,18 @@ /mob/living/silicon/robot/platform/proc/store_atom(var/atom/movable/storing, var/mob/user) if(istype(storing)) storing.forceMove(src) - LAZYDISTINCTADD(stored_atoms, weakref(storing)) + LAZYDISTINCTADD(stored_atoms, WEAKREF(storing)) /mob/living/silicon/robot/platform/proc/drop_stored_atom(var/atom/movable/ejecting, var/mob/user) if(!ejecting && length(stored_atoms)) - var/weakref/stored_ref = stored_atoms[1] + var/datum/weakref/stored_ref = stored_atoms[1] if(!istype(stored_ref)) LAZYREMOVE(stored_atoms, stored_ref) else ejecting = stored_ref?.resolve() - LAZYREMOVE(stored_atoms, weakref(ejecting)) + LAZYREMOVE(stored_atoms, WEAKREF(ejecting)) if(istype(ejecting) && !QDELETED(ejecting) && ejecting.loc == src) ejecting.dropInto(loc) if(user == src) @@ -90,11 +90,11 @@ if(isrobot(user) && user.Adjacent(src)) return try_remove_cargo(user) return ..() - + /mob/living/silicon/robot/platform/proc/try_remove_cargo(var/mob/user) if(!length(stored_atoms) || !istype(user)) return FALSE - var/weakref/remove_ref = stored_atoms[length(stored_atoms)] + var/datum/weakref/remove_ref = stored_atoms[length(stored_atoms)] var/atom/movable/removing = remove_ref?.resolve() if(!istype(removing) || QDELETED(removing) || removing.loc != src) LAZYREMOVE(stored_atoms, remove_ref) @@ -136,4 +136,4 @@ return FALSE if(user.incapacitated() || !Adjacent(user) || !dropping.Adjacent(user)) return FALSE - return TRUE \ No newline at end of file + return TRUE diff --git a/code/modules/mob/living/simple_mob/subtypes/vore/pakkun.dm b/code/modules/mob/living/simple_mob/subtypes/vore/pakkun.dm index f622eee483..99720acb24 100644 --- a/code/modules/mob/living/simple_mob/subtypes/vore/pakkun.dm +++ b/code/modules/mob/living/simple_mob/subtypes/vore/pakkun.dm @@ -130,7 +130,7 @@ /mob/living/simple_mob/vore/pakkun/on_throw_vore_special(var/pred, var/mob/living/target) if(pred && !extra_posessive && !(LAZYFIND(prey_excludes, target))) LAZYSET(prey_excludes, target, world.time) - addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, weakref(target)), 5 MINUTES) + addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, WEAKREF(target)), 5 MINUTES) if(ai_holder) ai_holder.remove_target() @@ -155,7 +155,7 @@ for(var/mob/living/L in living_mobs(0)) if(!(LAZYFIND(prey_excludes, L))) LAZYSET(prey_excludes, L, world.time) - addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, weakref(L)), 5 MINUTES) + addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, WEAKREF(L)), 5 MINUTES) else ..() diff --git a/code/modules/overmap/ships/computers/ship.dm b/code/modules/overmap/ships/computers/ship.dm index 46d56e29f7..8f52fdbe0b 100644 --- a/code/modules/overmap/ships/computers/ship.dm +++ b/code/modules/overmap/ships/computers/ship.dm @@ -79,7 +79,7 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov user.set_viewsize(world.view + extra_view) GLOB.moved_event.register(user, src, /obj/machinery/computer/ship/proc/unlook) // TODO GLOB.stat_set_event.register(user, src, /obj/machinery/computer/ship/proc/unlook) - LAZYDISTINCTADD(viewers, weakref(user)) + LAZYDISTINCTADD(viewers, WEAKREF(user)) /obj/machinery/computer/ship/proc/unlook(var/mob/user) user.reset_view() @@ -92,10 +92,10 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov user.set_viewsize() // reset to default GLOB.moved_event.unregister(user, src, /obj/machinery/computer/ship/proc/unlook) // TODO GLOB.stat_set_event.unregister(user, src, /obj/machinery/computer/ship/proc/unlook) - LAZYREMOVE(viewers, weakref(user)) + LAZYREMOVE(viewers, WEAKREF(user)) /obj/machinery/computer/ship/proc/viewing_overmap(mob/user) - return (weakref(user) in viewers) + return (WEAKREF(user) in viewers) /obj/machinery/computer/ship/tgui_status(mob/user) . = ..() @@ -120,7 +120,7 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov /obj/machinery/computer/ship/sensors/Destroy() sensors = null if(LAZYLEN(viewers)) - for(var/weakref/W in viewers) + for(var/datum/weakref/W in viewers) var/M = W.resolve() if(M) unlook(M) diff --git a/code/modules/reagents/reagent_containers/syringes_vr.dm b/code/modules/reagents/reagent_containers/syringes_vr.dm index 89d81d1f18..1e69c63322 100644 --- a/code/modules/reagents/reagent_containers/syringes_vr.dm +++ b/code/modules/reagents/reagent_containers/syringes_vr.dm @@ -63,7 +63,7 @@ /obj/item/weapon/reagent_containers/syringe/proc/infect_limb(var/obj/item/organ/external/eo) src = null - var/weakref/limb_ref = weakref(eo) + var/datum/weakref/limb_ref = WEAKREF(eo) spawn(rand(5 MINUTES,10 MINUTES)) var/obj/item/organ/external/found_limb = limb_ref.resolve() if(istype(found_limb)) diff --git a/code/modules/tgui/modules/ntos-only/uav.dm b/code/modules/tgui/modules/ntos-only/uav.dm index 54dcda1675..252c19d228 100644 --- a/code/modules/tgui/modules/ntos-only/uav.dm +++ b/code/modules/tgui/modules/ntos-only/uav.dm @@ -30,7 +30,7 @@ var/list/paired_map = list() var/obj/item/modular_computer/mc_host = tgui_host() if(istype(mc_host)) - for(var/weakref/wr as anything in mc_host.paired_uavs) + for(var/datum/weakref/wr as anything in mc_host.paired_uavs) var/obj/item/device/uav/U = wr.resolve() paired_map.Add(list(list("name" = "[U ? U.nickname : "!!Missing!!"]", "uavref" = "\ref[U]"))) @@ -40,7 +40,7 @@ /datum/tgui_module/uav/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state) if(..()) return TRUE - + switch(action) if("switch_uav") var/obj/item/device/uav/U = locate(params["switch_uav"]) //This is a \ref to the UAV itself @@ -59,9 +59,9 @@ var/refstring = params["del_uav"] //This is a \ref to the UAV itself var/obj/item/modular_computer/mc_host = tgui_host() //This is so we can really scrape up any weakrefs that can't resolve - for(var/weakref/wr in mc_host.paired_uavs) - if(wr.ref == refstring) - if(current_uav?.weakref == wr) + for(var/datum/weakref/wr in mc_host.paired_uavs) + if(wr.reference == refstring) + if(current_uav?.weak_reference == wr) set_current(null) LAZYREMOVE(mc_host.paired_uavs, wr) return TRUE @@ -82,7 +82,7 @@ else if(current_uav.toggle_power()) //Clean up viewers faster if(LAZYLEN(viewers)) - for(var/weakref/W in viewers) + for(var/datum/weakref/W in viewers) var/M = W.resolve() if(M) unlook(M) @@ -97,7 +97,7 @@ RegisterSignal(U, COMSIG_MOVABLE_Z_CHANGED, .proc/current_uav_changed_z) if(LAZYLEN(viewers)) - for(var/weakref/W in viewers) + for(var/datum/weakref/W in viewers) var/M = W.resolve() if(M) look(M) @@ -111,7 +111,7 @@ current_uav = null if(LAZYLEN(viewers)) - for(var/weakref/W in viewers) + for(var/datum/weakref/W in viewers) var/M = W.resolve() if(M) to_chat(M, "You're disconnected from the UAV's camera!") @@ -172,7 +172,7 @@ /* All handling viewers */ /datum/tgui_module/uav/Destroy() if(LAZYLEN(viewers)) - for(var/weakref/W in viewers) + for(var/datum/weakref/W in viewers) var/M = W.resolve() if(M) unlook(M) @@ -191,7 +191,7 @@ unlook(user) /datum/tgui_module/uav/proc/viewing_uav(mob/user) - return (weakref(user) in viewers) + return (WEAKREF(user) in viewers) /datum/tgui_module/uav/proc/look(mob/user) if(issilicon(user)) //Too complicated for me to want to mess with at the moment @@ -205,14 +205,14 @@ user.set_machine(tgui_host()) user.reset_view(current_uav) current_uav.add_master(user) - LAZYDISTINCTADD(viewers, weakref(user)) + LAZYDISTINCTADD(viewers, WEAKREF(user)) /datum/tgui_module/uav/proc/unlook(mob/user) user.unset_machine() user.reset_view() if(current_uav) current_uav.remove_master(user) - LAZYREMOVE(viewers, weakref(user)) + LAZYREMOVE(viewers, WEAKREF(user)) /datum/tgui_module/uav/check_eye(mob/user) if(get_dist(user, tgui_host()) > 1 || user.blinded || !current_uav) @@ -239,7 +239,7 @@ /datum/tgui_module/uav/apply_visual(mob/M) if(!M.client) return - if(weakref(M) in viewers) + if(WEAKREF(M) in viewers) M.overlay_fullscreen("fishbed",/obj/screen/fullscreen/fishbed) M.overlay_fullscreen("scanlines",/obj/screen/fullscreen/scanline) diff --git a/code/modules/tgui/modules/overmap.dm b/code/modules/tgui/modules/overmap.dm index 13d80d9f93..2bdca28b93 100644 --- a/code/modules/tgui/modules/overmap.dm +++ b/code/modules/tgui/modules/overmap.dm @@ -11,7 +11,7 @@ /datum/tgui_module/ship/Destroy() if(LAZYLEN(viewers)) - for(var/weakref/W in viewers) + for(var/datum/weakref/W in viewers) var/M = W.resolve() if(M) unlook(M) @@ -56,16 +56,16 @@ user.reset_view(linked) user.set_viewsize(world.view + extra_view) GLOB.moved_event.register(user, src, /datum/tgui_module/ship/proc/unlook) - LAZYDISTINCTADD(viewers, weakref(user)) + LAZYDISTINCTADD(viewers, WEAKREF(user)) /datum/tgui_module/ship/proc/unlook(var/mob/user) user.reset_view() user.set_viewsize() // reset to default GLOB.moved_event.unregister(user, src, /datum/tgui_module/ship/proc/unlook) - LAZYREMOVE(viewers, weakref(user)) + LAZYREMOVE(viewers, WEAKREF(user)) /datum/tgui_module/ship/proc/viewing_overmap(mob/user) - return (weakref(user) in viewers) + return (WEAKREF(user) in viewers) /datum/tgui_module/ship/check_eye(var/mob/user) if(!get_dist(user, tgui_host()) > 1 || user.blinded || !linked) @@ -457,4 +457,4 @@ /datum/tgui_module/ship/fullmonty/attempt_hook_up_recursive() return /datum/tgui_module/ship/fullmonty/attempt_hook_up() - return \ No newline at end of file + return diff --git a/code/modules/vore/eating/simple_animal_vr.dm b/code/modules/vore/eating/simple_animal_vr.dm index 8e176bd84b..362298cfe5 100644 --- a/code/modules/vore/eating/simple_animal_vr.dm +++ b/code/modules/vore/eating/simple_animal_vr.dm @@ -109,14 +109,14 @@ for(var/mob/living/L in living_mobs(0)) //add everyone on the tile to the do-not-eat list for a while if(!(LAZYFIND(prey_excludes, L))) // Unless they're already on it, just to avoid fuckery. LAZYSET(prey_excludes, L, world.time) - addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, weakref(L)), 5 MINUTES) + addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, WEAKREF(L)), 5 MINUTES) else if(istype(O, /obj/item/device/healthanalyzer)) var/healthpercent = health/maxHealth*100 to_chat(user, "[src] seems to be [healthpercent]% healthy.") else ..() -/mob/living/simple_mob/proc/removeMobFromPreyExcludes(weakref/target) +/mob/living/simple_mob/proc/removeMobFromPreyExcludes(datum/weakref/target) if(isweakref(target)) var/mob/living/L = target.resolve() LAZYREMOVE(prey_excludes, L) // It's fine to remove a null from the list if we couldn't resolve L diff --git a/code/unit_tests/integrated_circuits/logic.dm b/code/unit_tests/integrated_circuits/logic.dm index a022078c07..786d981778 100644 --- a/code/unit_tests/integrated_circuits/logic.dm +++ b/code/unit_tests/integrated_circuits/logic.dm @@ -37,7 +37,7 @@ /datum/unit_test/integrated_circuits/equals_6/arrange() A = new(get_standard_turf()) - inputs_to_give = list(weakref(A), weakref(A)) + inputs_to_give = list(WEAKREF(A), WEAKREF(A)) ..() /datum/unit_test/integrated_circuits/equals_6/clean_up() @@ -55,7 +55,7 @@ /datum/unit_test/integrated_circuits/equals_7/arrange() A = new(get_standard_turf()) B = new(get_standard_turf()) - inputs_to_give = list(weakref(A), weakref(B)) + inputs_to_give = list(WEAKREF(A), WEAKREF(B)) ..() /datum/unit_test/integrated_circuits/equals_7/clean_up() @@ -209,4 +209,4 @@ name = "Logic Circuits: Not - Invert to True" circuit_type = /obj/item/integrated_circuit/logic/unary/not inputs_to_give = list(0) - expected_outputs = list(1) \ No newline at end of file + expected_outputs = list(1) diff --git a/vorestation.dme b/vorestation.dme index e928fd0f6c..d00b768043 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -362,7 +362,7 @@ #include "code\datums\riding.dm" #include "code\datums\soul_link.dm" #include "code\datums\sun.dm" -#include "code\datums\weakref.dm" +#include "code\datums\weakrefs.dm" #include "code\datums\autolathe\arms.dm" #include "code\datums\autolathe\arms_vr.dm" #include "code\datums\autolathe\arms_yw.dm"