mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-29 08:11:11 +01:00
Little Weakref Refactor
This commit is contained in:
committed by
CHOMPStation2
parent
515d0e49ba
commit
3d53d2bb62
@@ -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
|
||||
@@ -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)
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
return 0
|
||||
|
||||
@@ -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>")
|
||||
@@ -564,4 +564,7 @@
|
||||
for(var/i = 1 to 4)
|
||||
new IC.type(src)
|
||||
make_exact_fit()
|
||||
<<<<<<< HEAD
|
||||
. = ..()
|
||||
=======
|
||||
>>>>>>> b22b9e6e48... Merge pull request #14936 from ItsSelis/selis-weakrefs
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -391,4 +391,4 @@
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
activate_pin(2)
|
||||
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
|
||||
@@ -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,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("<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>")
|
||||
accepting_refs = 0
|
||||
accepting_refs = 0
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]"
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
return TRUE
|
||||
|
||||
@@ -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]")))
|
||||
|
||||
@@ -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, "<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)
|
||||
@@ -457,4 +457,4 @@
|
||||
/datum/tgui_module/ship/fullmonty/attempt_hook_up_recursive()
|
||||
return
|
||||
/datum/tgui_module/ship/fullmonty/attempt_hook_up()
|
||||
return
|
||||
return
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user