mirror of
https://github.com/Yawn-Wider/YWPolarisVore.git
synced 2026-08-21 20:18:15 +01:00
Merge branch 'release' of https://github.com/VOREStation/VOREStation into izac
This commit is contained in:
@@ -290,7 +290,7 @@
|
||||
winset(user, "mapwindow", "focus=true")
|
||||
break
|
||||
if (timeout)
|
||||
addtimer(CALLBACK(src, .proc/close), timeout)
|
||||
addtimer(CALLBACK(src, PROC_REF(close)), timeout)
|
||||
|
||||
/datum/browser/modal/proc/wait()
|
||||
while (opentime && selectedbutton <= 0 && (!timeout || opentime+timeout > world.time))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -34,7 +34,7 @@ var/list/runechat_image_cache = list()
|
||||
|
||||
var/image/emote_image = image('icons/UI_Icons/chat/chat_icons.dmi', icon_state = "emote")
|
||||
runechat_image_cache["emote"] = emote_image
|
||||
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/chatmessage
|
||||
@@ -99,10 +99,10 @@ var/list/runechat_image_cache = list()
|
||||
if(!target || !owner)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
|
||||
// Register client who owns this message
|
||||
owned_by = owner.client
|
||||
RegisterSignal(owned_by, COMSIG_PARENT_QDELETING, .proc/qdel_self)
|
||||
RegisterSignal(owned_by, COMSIG_PARENT_QDELETING, PROC_REF(qdel_self))
|
||||
|
||||
var/extra_length = owned_by.is_preference_enabled(/datum/client_preference/runechat_long_messages)
|
||||
var/maxlen = extra_length ? CHAT_MESSAGE_EXT_LENGTH : CHAT_MESSAGE_LENGTH
|
||||
@@ -147,10 +147,10 @@ var/list/runechat_image_cache = list()
|
||||
// Icon on both ends?
|
||||
//var/image/I = runechat_image_cache["emote"]
|
||||
//text = "\icon[I][text]\icon[I]"
|
||||
|
||||
|
||||
// Icon on one end?
|
||||
//LAZYADD(prefixes, "\icon[runechat_image_cache["emote"]]")
|
||||
|
||||
|
||||
// Asterisks instead?
|
||||
text = "* [text] *"
|
||||
|
||||
@@ -168,7 +168,7 @@ var/list/runechat_image_cache = list()
|
||||
|
||||
// Translate any existing messages upwards, apply exponential decay factors to timers
|
||||
message_loc = target.runechat_holder(src)
|
||||
RegisterSignal(message_loc, COMSIG_PARENT_QDELETING, .proc/qdel_self)
|
||||
RegisterSignal(message_loc, COMSIG_PARENT_QDELETING, PROC_REF(qdel_self))
|
||||
if(owned_by.seen_messages)
|
||||
var/idx = 1
|
||||
var/combined_height = approx_lines
|
||||
@@ -255,7 +255,7 @@ var/list/runechat_image_cache = list()
|
||||
if(!message)
|
||||
return
|
||||
*/
|
||||
|
||||
|
||||
var/list/extra_classes = list()
|
||||
extra_classes += existing_extra_classes
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/datum/component/personal_crafting/Initialize()
|
||||
if(ismob(parent))
|
||||
RegisterSignal(parent, COMSIG_MOB_CLIENT_LOGIN, .proc/create_mob_button)
|
||||
RegisterSignal(parent, COMSIG_MOB_CLIENT_LOGIN, PROC_REF(create_mob_button))
|
||||
|
||||
/datum/component/personal_crafting/proc/create_mob_button(mob/user, client/CL)
|
||||
// SIGNAL_HANDLER
|
||||
@@ -12,7 +12,7 @@
|
||||
C.alpha = H.ui_alpha
|
||||
LAZYADD(H.other_important, C)
|
||||
CL.screen += C
|
||||
RegisterSignal(C, COMSIG_CLICK, .proc/component_ui_interact)
|
||||
RegisterSignal(C, COMSIG_CLICK, PROC_REF(component_ui_interact))
|
||||
|
||||
/datum/component/personal_crafting
|
||||
var/busy
|
||||
@@ -279,28 +279,28 @@
|
||||
if(amt <= 0)//since machinery can have 0 aka CRAFTING_MACHINERY_USE - i.e. use it, don't consume it!
|
||||
continue
|
||||
|
||||
// If the path is in R.parts, we want to grab those to stuff into the product
|
||||
// If the path is in R.parts, we want to grab those to stuff into the product
|
||||
var/amt_to_transfer = 0
|
||||
if(is_path_in_list(path_key, R.parts))
|
||||
amt_to_transfer = R.parts[path_key]
|
||||
|
||||
|
||||
|
||||
// Reagent: gotta go sniffing in all the beakers
|
||||
if(ispath(path_key, /datum/reagent))
|
||||
var/datum/reagent/reagent = path_key
|
||||
var/id = initial(reagent.id)
|
||||
|
||||
for(var/obj/item/weapon/reagent_containers/RC in surroundings)
|
||||
for(var/obj/item/weapon/reagent_containers/RC in surroundings)
|
||||
// Found everything we need
|
||||
if(amt <= 0 && amt_to_transfer <= 0)
|
||||
break
|
||||
break
|
||||
|
||||
// If we need to keep any to put in the new object, pull it out
|
||||
if(amt_to_transfer > 0)
|
||||
var/A = RC.reagents.trans_id_to(parts["reagents"], id, amt_to_transfer)
|
||||
amt_to_transfer -= A
|
||||
amt -= A
|
||||
|
||||
|
||||
// If we need to consume some amount of it
|
||||
if(amt > 0)
|
||||
var/datum/reagent/RG = RC.reagents.get_reagent(id)
|
||||
@@ -322,27 +322,27 @@
|
||||
parts["items"] += split
|
||||
amt_to_transfer -= split.get_amount()
|
||||
amt -= split.get_amount()
|
||||
|
||||
|
||||
if(amt > 0)
|
||||
var/A = min(amt, S.get_amount())
|
||||
if(S.use(A))
|
||||
amt -= A
|
||||
|
||||
|
||||
|
||||
else // Just a regular item. Find them all and delete them
|
||||
for(var/atom/movable/I in surroundings)
|
||||
if(amt <= 0 && amt_to_transfer <= 0)
|
||||
break
|
||||
|
||||
|
||||
if(!istype(I, path_key))
|
||||
continue
|
||||
|
||||
|
||||
// Special case: the reagents may be needed for other recipes
|
||||
if(istype(I, /obj/item/weapon/reagent_containers))
|
||||
var/obj/item/weapon/reagent_containers/RC = I
|
||||
if(RC.reagents.total_volume > 0)
|
||||
continue
|
||||
|
||||
|
||||
// We're using it for something
|
||||
amt--
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
parts["items"] += I
|
||||
amt_to_transfer--
|
||||
continue
|
||||
|
||||
|
||||
// Snowflake handling of reagent containers and storage atoms.
|
||||
// If we consumed them in our crafting, we should dump their contents out before qdeling them.
|
||||
if(istype(I, /obj/item/weapon/reagent_containers))
|
||||
@@ -369,7 +369,7 @@
|
||||
// SIGNAL_HANDLER
|
||||
|
||||
if(user == parent)
|
||||
INVOKE_ASYNC(src, .proc/tgui_interact, user)
|
||||
INVOKE_ASYNC(src, PROC_REF(tgui_interact), user)
|
||||
|
||||
/datum/component/personal_crafting/tgui_state(mob/user)
|
||||
return GLOB.tgui_not_incapacitated_turf_state
|
||||
@@ -499,7 +499,7 @@
|
||||
//Also these are typepaths so sadly we can't just do "[a]"
|
||||
L += "[req[req_atom]] [initial(req_atom.name)]"
|
||||
req_text += L.Join(" OR ")
|
||||
|
||||
|
||||
for(var/obj/machinery/content as anything in R.machinery)
|
||||
req_text += "[R.reqs[content]] [initial(content.name)]"
|
||||
if(R.additional_req_text)
|
||||
@@ -530,4 +530,4 @@
|
||||
name = "crafting menu"
|
||||
icon = 'icons/mob/screen/midnight.dmi'
|
||||
icon_state = "craft"
|
||||
screen_loc = ui_smallquad
|
||||
screen_loc = ui_smallquad
|
||||
|
||||
@@ -76,9 +76,9 @@
|
||||
. = ..()
|
||||
|
||||
if(!(mat_container_flags & MATCONTAINER_NO_INSERT))
|
||||
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/on_attackby)
|
||||
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(on_attackby))
|
||||
if(mat_container_flags & MATCONTAINER_EXAMINE)
|
||||
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/on_examine)
|
||||
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
|
||||
|
||||
|
||||
/datum/component/material_container/vv_edit_var(var_name, var_value)
|
||||
@@ -86,12 +86,12 @@
|
||||
. = ..()
|
||||
if(var_name == NAMEOF(src, mat_container_flags) && parent)
|
||||
if(!(old_flags & MATCONTAINER_EXAMINE) && mat_container_flags & MATCONTAINER_EXAMINE)
|
||||
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/on_examine)
|
||||
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
|
||||
else if(old_flags & MATCONTAINER_EXAMINE && !(mat_container_flags & MATCONTAINER_EXAMINE))
|
||||
UnregisterSignal(parent, COMSIG_PARENT_EXAMINE)
|
||||
|
||||
if(old_flags & MATCONTAINER_NO_INSERT && !(mat_container_flags & MATCONTAINER_NO_INSERT))
|
||||
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/on_attackby)
|
||||
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(on_attackby))
|
||||
else if(!(old_flags & MATCONTAINER_NO_INSERT) && mat_container_flags & MATCONTAINER_NO_INSERT)
|
||||
UnregisterSignal(parent, COMSIG_PARENT_ATTACKBY)
|
||||
|
||||
|
||||
@@ -111,15 +111,15 @@
|
||||
/datum/component/overlay_lighting/RegisterWithParent()
|
||||
. = ..()
|
||||
if(directional)
|
||||
RegisterSignal(parent, COMSIG_ATOM_DIR_CHANGE, .proc/on_parent_dir_change)
|
||||
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/on_parent_moved)
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_RANGE, .proc/set_range)
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_POWER, .proc/set_power)
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_COLOR, .proc/set_color)
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_ON, .proc/on_toggle)
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_FLAGS, .proc/on_light_flags_change)
|
||||
RegisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT, .proc/on_parent_crafted)
|
||||
RegisterSignal(parent, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater)
|
||||
RegisterSignal(parent, COMSIG_ATOM_DIR_CHANGE, PROC_REF(on_parent_dir_change))
|
||||
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_parent_moved))
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_RANGE, PROC_REF(set_range))
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_POWER, PROC_REF(set_power))
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_COLOR, PROC_REF(set_color))
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_ON, PROC_REF(on_toggle))
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_LIGHT_FLAGS, PROC_REF(on_light_flags_change))
|
||||
RegisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT, PROC_REF(on_parent_crafted))
|
||||
RegisterSignal(parent, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
var/atom/movable/movable_parent = parent
|
||||
if(movable_parent.light_flags & LIGHT_ATTACHED)
|
||||
overlay_lighting_flags |= LIGHTING_ATTACHED
|
||||
@@ -155,17 +155,17 @@
|
||||
set_parent_attached_to(null)
|
||||
set_holder(null)
|
||||
clean_old_turfs()
|
||||
|
||||
|
||||
qdel(visible_mask, TRUE)
|
||||
visible_mask = null
|
||||
|
||||
|
||||
if(directional)
|
||||
qdel(directional_atom, TRUE)
|
||||
directional_atom = null
|
||||
|
||||
|
||||
qdel(cone, TRUE)
|
||||
cone = null
|
||||
|
||||
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -229,15 +229,15 @@
|
||||
var/atom/movable/old_parent_attached_to = .
|
||||
UnregisterSignal(old_parent_attached_to, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
if(old_parent_attached_to == current_holder)
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_PARENT_QDELETING, .proc/on_holder_qdel)
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved)
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater)
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_PARENT_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_MOVABLE_MOVED, PROC_REF(on_holder_moved))
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
if(parent_attached_to)
|
||||
if(parent_attached_to == current_holder)
|
||||
UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
RegisterSignal(parent_attached_to, COMSIG_PARENT_QDELETING, .proc/on_parent_attached_to_qdel)
|
||||
RegisterSignal(parent_attached_to, COMSIG_MOVABLE_MOVED, .proc/on_parent_attached_to_moved)
|
||||
RegisterSignal(parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater)
|
||||
RegisterSignal(parent_attached_to, COMSIG_PARENT_QDELETING, PROC_REF(on_parent_attached_to_qdel))
|
||||
RegisterSignal(parent_attached_to, COMSIG_MOVABLE_MOVED, PROC_REF(on_parent_attached_to_moved))
|
||||
RegisterSignal(parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
check_holder()
|
||||
|
||||
|
||||
@@ -257,11 +257,11 @@
|
||||
clean_old_turfs()
|
||||
return
|
||||
if(new_holder != parent && new_holder != parent_attached_to)
|
||||
RegisterSignal(new_holder, COMSIG_PARENT_QDELETING, .proc/on_holder_qdel)
|
||||
RegisterSignal(new_holder, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved)
|
||||
RegisterSignal(new_holder, COMSIG_LIGHT_EATER_QUEUE, .proc/on_light_eater)
|
||||
RegisterSignal(new_holder, COMSIG_PARENT_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(new_holder, COMSIG_MOVABLE_MOVED, PROC_REF(on_holder_moved))
|
||||
RegisterSignal(new_holder, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
if(directional)
|
||||
RegisterSignal(new_holder, COMSIG_ATOM_DIR_CHANGE, .proc/on_holder_dir_change)
|
||||
RegisterSignal(new_holder, COMSIG_ATOM_DIR_CHANGE, PROC_REF(on_holder_dir_change))
|
||||
if(overlay_lighting_flags & LIGHTING_ON)
|
||||
make_luminosity_update()
|
||||
add_dynamic_lumi()
|
||||
@@ -444,7 +444,7 @@
|
||||
if(final_distance > SHORT_CAST && !(ALL_CARDINALS & current_direction))
|
||||
final_distance -= 1
|
||||
var/turf/scanning = get_turf(current_holder)
|
||||
|
||||
|
||||
. = 0
|
||||
for(var/i in 1 to final_distance)
|
||||
var/turf/next_turf = get_step(scanning, current_direction)
|
||||
@@ -464,7 +464,7 @@
|
||||
if(final_distance > SHORT_CAST && !(ALL_CARDINALS & get_dir(GET_PARENT, target)))
|
||||
final_distance -= 1
|
||||
var/turf/scanning = get_turf(GET_PARENT)
|
||||
|
||||
|
||||
. = 0
|
||||
for(var/i in 1 to final_distance)
|
||||
var/next_dir = get_dir(scanning, target)
|
||||
@@ -477,9 +477,9 @@
|
||||
directional_atom.forceMove(scanning)
|
||||
var/turf/Ts = get_turf(GET_PARENT)
|
||||
var/turf/To = get_turf(GET_LIGHT_SOURCE)
|
||||
|
||||
|
||||
var/angle = Get_Angle(Ts, To)
|
||||
|
||||
|
||||
directional_atom.face_light(GET_PARENT, angle, .)
|
||||
set_cone_direction(NORTH, angle)
|
||||
|
||||
@@ -510,7 +510,7 @@
|
||||
return
|
||||
current_direction = newdir
|
||||
set_cone_direction(newdir)
|
||||
|
||||
|
||||
if(newdir & NORTH)
|
||||
cone.pixel_y = 16
|
||||
else if(newdir & SOUTH)
|
||||
@@ -522,7 +522,7 @@
|
||||
else
|
||||
cone.pixel_y = 0
|
||||
directional_atom.pixel_y = 0
|
||||
|
||||
|
||||
if(newdir & EAST)
|
||||
cone.pixel_x = 16
|
||||
else if(newdir & WEST)
|
||||
@@ -538,7 +538,7 @@
|
||||
else
|
||||
cone.pixel_x = 0
|
||||
directional_atom.pixel_x = 0
|
||||
|
||||
|
||||
if(!skip_update && (overlay_lighting_flags & LIGHTING_ON))
|
||||
make_luminosity_update()
|
||||
|
||||
@@ -549,7 +549,7 @@
|
||||
return
|
||||
|
||||
UnregisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT)
|
||||
RegisterSignal(new_craft, COMSIG_ATOM_USED_IN_CRAFT, .proc/on_parent_crafted)
|
||||
RegisterSignal(new_craft, COMSIG_ATOM_USED_IN_CRAFT, PROC_REF(on_parent_crafted))
|
||||
set_parent_attached_to(new_craft)
|
||||
|
||||
/// Handles putting the source for overlay lights into the light eater queue since we aren't tracked by [/atom/var/light_sources]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
/datum/component/resize_guard/RegisterWithParent()
|
||||
// When our parent mob enters any atom, we check resize
|
||||
RegisterSignal(parent, COMSIG_ATOM_ENTERING, .proc/check_resize)
|
||||
RegisterSignal(parent, COMSIG_ATOM_ENTERING, PROC_REF(check_resize))
|
||||
|
||||
/datum/component/resize_guard/UnregisterFromParent()
|
||||
UnregisterSignal(parent, COMSIG_ATOM_ENTERING)
|
||||
@@ -16,4 +16,4 @@
|
||||
if(A?.limit_mob_size)
|
||||
var/mob/living/L = parent
|
||||
L.resize(L.size_multiplier)
|
||||
qdel(src)
|
||||
qdel(src)
|
||||
|
||||
+38
-10
@@ -1,18 +1,46 @@
|
||||
//
|
||||
// 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
|
||||
|
||||
/// 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
|
||||
@@ -35,7 +63,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
|
||||
|
||||
@@ -63,11 +63,11 @@
|
||||
if(!check_rights(NONE))
|
||||
return
|
||||
var/list/names = list()
|
||||
var/list/componentsubtypes = sortTim(subtypesof(/datum/component), /proc/cmp_typepaths_asc)
|
||||
var/list/componentsubtypes = sortTim(subtypesof(/datum/component), GLOBAL_PROC_REF(cmp_typepaths_asc))
|
||||
names += "---Components---"
|
||||
names += componentsubtypes
|
||||
names += "---Elements---"
|
||||
names += sortTim(subtypesof(/datum/element), /proc/cmp_typepaths_asc)
|
||||
names += sortTim(subtypesof(/datum/element), GLOBAL_PROC_REF(cmp_typepaths_asc))
|
||||
var/result = tgui_input_list(usr, "Choose a component/element to add:", "Add Component/Element", names)
|
||||
if(!usr || !result || result == "---Components---" || result == "---Elements---")
|
||||
return
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
SEND_SIGNAL(target, COMSIG_ELEMENT_ATTACH, src)
|
||||
if(element_flags & ELEMENT_DETACH)
|
||||
RegisterSignal(target, COMSIG_PARENT_QDELETING, .proc/OnTargetDelete, override = TRUE)
|
||||
RegisterSignal(target, COMSIG_PARENT_QDELETING, PROC_REF(OnTargetDelete), override = TRUE)
|
||||
|
||||
/datum/element/proc/OnTargetDelete(datum/source, force)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
CRASH("Invalid ID in conflict checking element.")
|
||||
if(isnull(src.id))
|
||||
src.id = id
|
||||
RegisterSignal(target, COMSIG_CONFLICT_ELEMENT_CHECK, .proc/check)
|
||||
RegisterSignal(target, COMSIG_CONFLICT_ELEMENT_CHECK, PROC_REF(check))
|
||||
|
||||
/datum/element/conflict_checking/proc/check(datum/source, id_to_check)
|
||||
if(id == id_to_check)
|
||||
@@ -32,4 +32,4 @@
|
||||
for(var/i in GetAllContents())
|
||||
var/atom/movable/AM = i
|
||||
if(SEND_SIGNAL(AM, COMSIG_CONFLICT_ELEMENT_CHECK, id) & ELEMENT_CONFLICT_FOUND)
|
||||
++.
|
||||
++.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
. = ..()
|
||||
if(!ismovable(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_target_move)
|
||||
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_target_move))
|
||||
var/atom/movable/movable_target = target
|
||||
if(isturf(movable_target.loc))
|
||||
var/turf/turf_loc = movable_target.loc
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
our_turf.plane = OPENSPACE_PLANE
|
||||
our_turf.layer = OPENSPACE_LAYER
|
||||
|
||||
RegisterSignal(target, COMSIG_TURF_MULTIZ_DEL, .proc/on_multiz_turf_del, override = TRUE)
|
||||
RegisterSignal(target, COMSIG_TURF_MULTIZ_NEW, .proc/on_multiz_turf_new, override = TRUE)
|
||||
RegisterSignal(target, COMSIG_TURF_MULTIZ_DEL, PROC_REF(on_multiz_turf_del), override = TRUE)
|
||||
RegisterSignal(target, COMSIG_TURF_MULTIZ_NEW, PROC_REF(on_multiz_turf_new), override = TRUE)
|
||||
|
||||
update_multiz(our_turf, TRUE, TRUE)
|
||||
|
||||
@@ -75,12 +75,12 @@
|
||||
if(!ispath(path))
|
||||
warning("Z-level [our_turf] has invalid baseturf '[get_base_turf_by_area(our_turf)]' in area '[get_area(our_turf)]'")
|
||||
path = /turf/space
|
||||
|
||||
|
||||
var/do_plane = ispath(path, /turf/space) ? SPACE_PLANE : null
|
||||
var/do_state = ispath(path, /turf/space) ? "white" : initial(path.icon_state)
|
||||
|
||||
|
||||
var/mutable_appearance/underlay_appearance = mutable_appearance(initial(path.icon), do_state, layer = TURF_LAYER-0.02, plane = do_plane)
|
||||
underlay_appearance.appearance_flags = RESET_ALPHA | RESET_COLOR
|
||||
our_turf.underlays += underlay_appearance
|
||||
|
||||
return TRUE
|
||||
|
||||
return TRUE
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
if(query_sound)
|
||||
SEND_SOUND(C, sound(query_sound))
|
||||
|
||||
tgui_alert_async(D, question, "[role_name] request", list("Yes", "No", "Never for this round"), CALLBACK(src, .proc/get_reply), wait_time SECONDS)
|
||||
tgui_alert_async(D, question, "[role_name] request", list("Yes", "No", "Never for this round"), CALLBACK(src, PROC_REF(get_reply)), wait_time SECONDS)
|
||||
|
||||
/// Process an async alert response
|
||||
/datum/ghost_query/proc/get_reply(response)
|
||||
@@ -87,7 +87,7 @@
|
||||
else if(finished) // Already finished candidate list
|
||||
to_chat(D, "<span class='warning'>Unfortunately, you were not fast enough, and there are no more available roles. Sorry.</span>")
|
||||
else // Prompt a second time
|
||||
tgui_alert_async(D, "Are you sure you want to play as a [role_name]?", "[role_name] request", list("I'm Sure", "Nevermind"), CALLBACK(src, .proc/get_reply), wait_time SECONDS)
|
||||
tgui_alert_async(D, "Are you sure you want to play as a [role_name]?", "[role_name] request", list("I'm Sure", "Nevermind"), CALLBACK(src, PROC_REF(get_reply)), wait_time SECONDS)
|
||||
|
||||
if("I'm Sure")
|
||||
if(!evaluate_candidate(D)) // Failed revalidation
|
||||
@@ -214,4 +214,5 @@
|
||||
and they are attempting to open the cryopod.\n \
|
||||
Would you like to play as the occupant? \n \
|
||||
You MUST NOT use your station character!!!"
|
||||
be_special_flag = BE_SURVIVOR
|
||||
cutoff_number = 1
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
if(!chance || prob(chance))
|
||||
play(get_sound(starttime))
|
||||
if(!timerid)
|
||||
timerid = addtimer(CALLBACK(src, .proc/sound_loop, world.time), mid_length, TIMER_STOPPABLE | TIMER_LOOP)
|
||||
timerid = addtimer(CALLBACK(src, PROC_REF(sound_loop), world.time), mid_length, TIMER_STOPPABLE | TIMER_LOOP)
|
||||
|
||||
/datum/looping_sound/proc/play(soundfile)
|
||||
var/list/atoms_cache = output_atoms
|
||||
@@ -119,7 +119,7 @@
|
||||
if(start_sound)
|
||||
play(start_sound)
|
||||
start_wait = start_length
|
||||
addtimer(CALLBACK(src, .proc/sound_loop), start_wait)
|
||||
addtimer(CALLBACK(src, PROC_REF(sound_loop)), start_wait)
|
||||
|
||||
/datum/looping_sound/proc/on_stop()
|
||||
if(end_sound)
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
/datum/looping_sound/sequence/sound_loop(starttime)
|
||||
iterate_on_sequence()
|
||||
|
||||
timerid = addtimer(CALLBACK(src, .proc/sound_loop, world.time), next_iteration_delay, TIMER_STOPPABLE)
|
||||
timerid = addtimer(CALLBACK(src, PROC_REF(sound_loop), world.time), next_iteration_delay, TIMER_STOPPABLE)
|
||||
|
||||
#define MORSE_DOT "*" // Yes this is an asterisk but its easier to see on a computer compared to a period.
|
||||
#define MORSE_DASH "-"
|
||||
@@ -172,4 +172,4 @@
|
||||
return spaces_between_letters
|
||||
|
||||
#undef MORSE_DOT
|
||||
#undef MORSE_DASH
|
||||
#undef MORSE_DASH
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
to_chat(user, "<span class='warning'>You'll need [key_name] in one of your hands to move \the [ridden].</span>")
|
||||
|
||||
/datum/riding/proc/Unbuckle(atom/movable/M)
|
||||
// addtimer(CALLBACK(ridden, /atom/movable/.proc/unbuckle_mob, M), 0, TIMER_UNIQUE)
|
||||
// addtimer(CALLBACK(ridden, TYPE_PROC_REF(/atom/movable, unbuckle_mob), M), 0, TIMER_UNIQUE)
|
||||
spawn(0)
|
||||
// On /tg/ this uses the fancy CALLBACK system. Not entirely sure why they needed to do so with a duration of 0,
|
||||
// so if there is a reason, this should replicate it close enough. Hopefully.
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user