mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Merge pull request #6304 from CHOMPStation2/upstream-merge-14936
[MIRROR] Little Weakref Refactor
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
108
code/datums/weakrefs.dm
Normal file
108
code/datums/weakrefs.dm
Normal file
@@ -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)
|
||||
@@ -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, "<span class='notice'>You mark \the [get_turf(user)] under you.</span>")
|
||||
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, "<span class='danger'>There's no Mark!</span>")
|
||||
return 0
|
||||
@@ -128,4 +128,3 @@ GLOBAL_LIST_INIT(mark_spells, list())
|
||||
else
|
||||
to_chat(user, "<span class='warning'>You can't afford the energy cost!</span>")
|
||||
return 0
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ GLOBAL_LIST_EMPTY(entertainment_screens)
|
||||
|
||||
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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
..()
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
/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("<span class='notice'>[user] pairs [I] to [nickname]</span>")
|
||||
toggle_pairing()
|
||||
@@ -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 = "<i><span class='game say'>UAV received, <span class='message'>[text]</span></span></i>"
|
||||
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 = "<i><span class='game say'>UAV received, <span class='message'>[msg]</span></span></i>"
|
||||
master.show_message(rendered, type)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)"
|
||||
|
||||
@@ -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("<span class='notice'>[user] slides \a [src]'s over \the [target].</span>")
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \
|
||||
now off.</span>")
|
||||
@@ -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, "<span class='notice'>You write '[data_to_write ? data_to_show : "NULL"]' to the '[io]' pin of \the [io.holder].</span>")
|
||||
@@ -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("<span class='notice'>[user] slides \a [src]'s over \the [target].</span>")
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to a reference to [target.name] \[Ref\]. The ref scanner is \
|
||||
now off.</span>")
|
||||
|
||||
@@ -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()
|
||||
..()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
/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("<span class='notice'>[user] slides \a [src]'s over \the [target].</span>")
|
||||
to_chat(user, "<span class='notice'>You set \the [src]'s memory to a reference to [O.display_data(O.data)]. The ref scanner is \
|
||||
now off.</span>")
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]"
|
||||
|
||||
@@ -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("<b>\The [user]</b> slots \the [W] into \the [src]'s recharging port.")
|
||||
return TRUE
|
||||
|
||||
@@ -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)
|
||||
@@ -94,7 +94,7 @@
|
||||
/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)
|
||||
|
||||
@@ -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
|
||||
..()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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]")))
|
||||
|
||||
@@ -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, "<span class='warning'>You're disconnected from the UAV's camera!</span>")
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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, "<span class='notice'>[src] seems to be [healthpercent]% healthy.</span>")
|
||||
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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user