mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-27 06:54:18 +01:00
SOFTREF macro (#2574)
Adds a SOFTREF macro because it's an actual PITA to write out. Refactors all applicable usecases of it to use it. I've left out some NanoUI stuff because you know my preference at being explicit when needed.
This commit is contained in:
@@ -323,3 +323,7 @@ Will print: "/mob/living/carbon/human/death" (you can optionally embed it in a s
|
||||
#define NL_NOT_DISABLED 0
|
||||
#define NL_TEMPORARY_DISABLE 1
|
||||
#define NL_PERMANENT_DISABLE 2
|
||||
|
||||
// Used for creating soft references to objects. A manner of storing an item reference
|
||||
// as text so you don't necessarily fuck with an object's ability to be garbage collected.
|
||||
#define SOFTREF(A) "\ref[A]"
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
log_debug("SSarrivals: [M] has entered arrival shuttle hotzone.")
|
||||
|
||||
if (istype(M))
|
||||
current_mobs += "\ref[M]"
|
||||
current_mobs += SOFTREF(M)
|
||||
|
||||
wake() // Wake the process.
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
set_launch_countdown(30)
|
||||
|
||||
/datum/controller/subsystem/arrivals/proc/on_hotzone_exit(mob/living/M)
|
||||
current_mobs -= "\ref[M]"
|
||||
current_mobs -= SOFTREF(M)
|
||||
log_debug("SSarrivals: [M] has exited arrival shuttle hotzone.")
|
||||
|
||||
//called when the shuttle has arrived.
|
||||
|
||||
@@ -138,12 +138,12 @@ var/datum/controller/subsystem/garbage_collector/SSgarbage
|
||||
var/time = world.timeofday
|
||||
var/tick = world.tick_usage
|
||||
var/ticktime = world.time
|
||||
|
||||
|
||||
var/type = A.type
|
||||
var/refID = "\ref[A]"
|
||||
|
||||
|
||||
del(A)
|
||||
|
||||
|
||||
tick = (world.tick_usage-tick+((world.time-ticktime)/world.tick_lag*100))
|
||||
if (tick > highest_del_tickusage)
|
||||
highest_del_tickusage = tick
|
||||
|
||||
@@ -52,7 +52,7 @@ var/datum/controller/subsystem/processing/nanoui/SSnanoui
|
||||
* @return /nanoui Returns the found ui, or null if none exists
|
||||
*/
|
||||
/datum/controller/subsystem/processing/nanoui/proc/get_open_ui(mob/user, src_object, ui_key)
|
||||
var/src_object_key = "\ref[src_object]"
|
||||
var/src_object_key = SOFTREF(src_object)
|
||||
if (!LAZYLEN(open_uis[src_object_key]) || !LAZYLEN(open_uis[src_object_key][ui_key]))
|
||||
return null
|
||||
|
||||
@@ -71,7 +71,7 @@ var/datum/controller/subsystem/processing/nanoui/SSnanoui
|
||||
* @return int The number of uis updated
|
||||
*/
|
||||
/datum/controller/subsystem/processing/nanoui/proc/update_uis(src_object)
|
||||
var/src_object_key = "\ref[src_object]"
|
||||
var/src_object_key = SOFTREF(src_object)
|
||||
if (!LAZYLEN(open_uis[src_object_key]))
|
||||
return 0
|
||||
|
||||
@@ -92,7 +92,7 @@ var/datum/controller/subsystem/processing/nanoui/SSnanoui
|
||||
* @return int The number of uis close
|
||||
*/
|
||||
/datum/controller/subsystem/processing/nanoui/proc/close_uis(src_object)
|
||||
var/src_object_key = "\ref[src_object]"
|
||||
var/src_object_key = SOFTREF(src_object)
|
||||
if (!open_uis[src_object_key] || !islist(open_uis[src_object_key]))
|
||||
return 0
|
||||
|
||||
@@ -146,7 +146,7 @@ var/datum/controller/subsystem/processing/nanoui/SSnanoui
|
||||
* @return nothing
|
||||
*/
|
||||
/datum/controller/subsystem/processing/nanoui/proc/ui_opened(datum/nanoui/ui)
|
||||
var/src_object_key = "\ref[ui.src_object]"
|
||||
var/src_object_key = SOFTREF(ui.src_object)
|
||||
LAZYINITLIST(open_uis[src_object_key])
|
||||
|
||||
LAZYADD(ui.user.open_uis, ui)
|
||||
@@ -163,7 +163,7 @@ var/datum/controller/subsystem/processing/nanoui/SSnanoui
|
||||
* @return int 0 if no ui was removed, 1 if removed successfully
|
||||
*/
|
||||
/datum/controller/subsystem/processing/nanoui/proc/ui_closed(datum/nanoui/ui)
|
||||
var/src_object_key = "\ref[ui.src_object]"
|
||||
var/src_object_key = SOFTREF(ui.src_object)
|
||||
var/ui_key = ui.ui_key
|
||||
var/list/obj_uis = open_uis[src_object_key]
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
note_wrapper = new_wrapper
|
||||
note_text = new_text
|
||||
|
||||
note_text = replacetextEx(note_text, ":src_ref", "\ref[src]")
|
||||
note_wrapper[1] = replacetextEx(note_wrapper[1], ":src_ref", "\ref[src]")
|
||||
note_text = replacetextEx(note_text, ":src_ref", SOFTREF(src))
|
||||
note_wrapper[1] = replacetextEx(note_wrapper[1], ":src_ref", SOFTREF(src))
|
||||
|
||||
if (new_persistence)
|
||||
persistent = new_persistence
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
for (var/j = 1, j <= group_size, j++)
|
||||
if(prob(99))
|
||||
var/mob/living/simple_animal/hostile/carp/carp = new(spawn_locations[i])
|
||||
spawned_carp += "\ref[carp]"
|
||||
spawned_carp += SOFTREF(carp)
|
||||
else
|
||||
var/mob/living/simple_animal/hostile/carp/shark/carp = new(spawn_locations[i])
|
||||
spawned_carp += "\ref[carp]"
|
||||
spawned_carp += SOFTREF(carp)
|
||||
i++
|
||||
|
||||
/datum/event/carp_migration/proc/spawn_caverndweller(var/num_groups, var/group_size_min=2, var/group_size_max=3)
|
||||
@@ -63,7 +63,7 @@
|
||||
var/group_size = rand(group_size_min, group_size_max)
|
||||
for (var/j = 1, j <= group_size, j++)
|
||||
var/mob/living/simple_animal/hostile/retaliate/cavern_dweller/dweller = new(spawn_locations[i])
|
||||
spawned_dweller += "\ref[dweller]"
|
||||
spawned_dweller += SOFTREF(dweller)
|
||||
i++
|
||||
|
||||
/datum/event/carp_migration/end()
|
||||
|
||||
@@ -754,9 +754,9 @@
|
||||
H << "<span class='danger'>The APC power currents surge eratically, damaging your chassis!</span>"
|
||||
H.adjustFireLoss(10, 0)
|
||||
if(infected)
|
||||
if("\ref[H]" in hacked_ipcs)
|
||||
if(SOFTREF(H) in hacked_ipcs)
|
||||
return
|
||||
LAZYADD(hacked_ipcs, "\ref[H]")
|
||||
LAZYADD(hacked_ipcs, SOFTREF(H))
|
||||
infected = 0
|
||||
H << "<span class = 'danger'>Fil$ Transfer Complete. Er-@4!#%!. New Master detected: [hacker]! Obey their commands.</span>"
|
||||
hacker << "<span class = 'notice'>Corrupt files transfered to [H]. They are now under your control until they are reparied.</span>"
|
||||
|
||||
Reference in New Issue
Block a user