mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
final new NanoUI fixes and tgui port
This commit is contained in:
@@ -66,6 +66,9 @@ world/loop_checks = 0
|
||||
testing("GC: [refID] old enough to test: GCd_at_time: [GCd_at_time] time_to_kill: [time_to_kill] current: [world.time]")
|
||||
#endif
|
||||
if(A && A.gcDestroyed == GCd_at_time) // So if something else coincidently gets the same ref, it's not deleted by mistake
|
||||
#ifdef GC_FINDREF
|
||||
LocateReferences(A)
|
||||
#endif
|
||||
// Something's still referring to the qdel'd object. Kill it.
|
||||
testing("GC: -- \ref[A] | [A.type] was unable to be GC'd and was deleted --")
|
||||
logging["[A.type]"]++
|
||||
@@ -88,29 +91,47 @@ world/loop_checks = 0
|
||||
#undef GC_COLLECTIONS_PER_TICK
|
||||
|
||||
#ifdef GC_FINDREF
|
||||
/datum/controller/process/garbage_collector/proc/LookForRefs(var/datum/D, var/list/targ)
|
||||
|
||||
/datum/controller/process/garbage_collector/proc/LocateReferences(var/atom/A)
|
||||
testing("GC: Attempting to locate references to [A] | [A.type]. This is a potentially long-running operation.")
|
||||
if(istype(A))
|
||||
if(A.loc != null)
|
||||
testing("GC: [A] | [A.type] is located in [A.loc] instead of null")
|
||||
if(A.contents.len)
|
||||
testing("GC: [A] | [A.type] has contents: [jointext(A.contents)]")
|
||||
var/ref_count = 0
|
||||
for(var/atom/atom)
|
||||
ref_count += LookForRefs(atom, A)
|
||||
for(var/datum/datum) // This is strictly /datum, not subtypes.
|
||||
ref_count += LookForRefs(datum, A)
|
||||
for(var/client/client)
|
||||
ref_count += LookForRefs(client, A)
|
||||
var/message = "GC: References found to [A] | [A.type]: [ref_count]."
|
||||
if(!ref_count)
|
||||
message += " Has likely been supplied as an 'in list' argment to a proc."
|
||||
testing(message)
|
||||
|
||||
/datum/controller/process/garbage_collector/proc/LookForRefs(var/datum/D, var/datum/A)
|
||||
. = 0
|
||||
for(var/V in D.vars)
|
||||
if(V == "contents")
|
||||
continue
|
||||
if(istype(D.vars[V], /atom))
|
||||
var/atom/A = D.vars[V]
|
||||
if(A in targ)
|
||||
if(!islist(D.vars[V]))
|
||||
if(D.vars[V] == A)
|
||||
testing("GC: [A] | [A.type] referenced by [D] | [D.type], var [V]")
|
||||
. += 1
|
||||
else if(islist(D.vars[V]))
|
||||
. += LookForListRefs(D.vars[V], targ, D, V)
|
||||
else
|
||||
. += LookForListRefs(D.vars[V], A, D, V)
|
||||
|
||||
/datum/controller/process/garbage_collector/proc/LookForListRefs(var/list/L, var/list/targ, var/datum/D, var/V)
|
||||
/datum/controller/process/garbage_collector/proc/LookForListRefs(var/list/L, var/datum/A, var/datum/D, var/V)
|
||||
. = 0
|
||||
for(var/F in L)
|
||||
if(istype(F, /atom))
|
||||
var/atom/A = F
|
||||
if(A in targ)
|
||||
if(!islist(F))
|
||||
if(F == A || L[F] == A)
|
||||
testing("GC: [A] | [A.type] referenced by [D] | [D.type], list [V]")
|
||||
. += 1
|
||||
if(islist(F))
|
||||
. += LookForListRefs(F, targ, D, "[F] in list [V]")
|
||||
else
|
||||
. += LookForListRefs(F, A, D, "[F] in list [V]")
|
||||
#endif
|
||||
|
||||
/datum/controller/process/garbage_collector/proc/AddTrash(datum/A)
|
||||
|
||||
28
code/controllers/Processes/tgui.dm
Normal file
28
code/controllers/Processes/tgui.dm
Normal file
@@ -0,0 +1,28 @@
|
||||
var/global/datum/controller/process/tgui/tgui_process
|
||||
|
||||
/datum/controller/process/tgui
|
||||
var/list/tg_open_uis = list() // A list of open UIs, grouped by src_object and ui_key.
|
||||
var/list/processing_uis = list() // A list of processing UIs, ungrouped.
|
||||
var/basehtml // The HTML base used for all UIs.
|
||||
|
||||
/datum/controller/process/tgui/setup()
|
||||
name = "tgui"
|
||||
schedule_interval = 10 // every 2 seconds
|
||||
start_delay = 23
|
||||
|
||||
basehtml = file2text('tgui/tgui.html') // Read the HTML from disk.
|
||||
tgui_process = src
|
||||
|
||||
/datum/controller/process/tgui/doWork()
|
||||
for(var/gui in processing_uis)
|
||||
var/datum/tgui/ui = gui
|
||||
if(ui && ui.user && ui.src_object)
|
||||
ui.process()
|
||||
SCHECK
|
||||
continue
|
||||
processing_uis.Remove(ui)
|
||||
SCHECK
|
||||
|
||||
/datum/controller/process/tgui/statProcess()
|
||||
..()
|
||||
stat(null, "[tgui_process.processing_uis.len] UI\s")
|
||||
Reference in New Issue
Block a user