Skip to content

Commit

Permalink
update ss_icon_update
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustKisik committed Oct 31, 2024
1 parent 15848fe commit 9ee1506
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 64 deletions.
2 changes: 1 addition & 1 deletion baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
#include "code\controllers\subsystems\initialization\culture.dm"
#include "code\controllers\subsystems\initialization\customitems.dm"
#include "code\controllers\subsystems\initialization\fabrication.dm"
#include "code\controllers\subsystems\initialization\icon_updates.dm"
#include "code\controllers\subsystems\initialization\materials.dm"
#include "code\controllers\subsystems\initialization\misc.dm"
#include "code\controllers\subsystems\initialization\misc_early.dm"
Expand All @@ -247,7 +248,6 @@
#include "code\controllers\subsystems\processing\disposals.dm"
#include "code\controllers\subsystems\processing\fast_process.dm"
#include "code\controllers\subsystems\processing\graphs.dm"
#include "code\controllers\subsystems\processing\icon_updates.dm"
#include "code\controllers\subsystems\processing\nano.dm"
#include "code\controllers\subsystems\processing\obj.dm"
#include "code\controllers\subsystems\processing\processing.dm"
Expand Down
3 changes: 2 additions & 1 deletion code/__defines/subsystem-priority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// SS_TICKER
#define SS_PRIORITY_TIMER 30
#define SS_PRIORITY_OVERLAYS 20
#define SS_PRIORITY_ICON_UPDATE 10


// Normal
#define SS_PRIORITY_TICKER 100 // Gameticker.
Expand All @@ -26,6 +26,7 @@
#define SS_PRIORITY_CHAT 40 // Chat
#define SS_PRIORITY_AI 25 // Mob AI
#define SS_PRIORITY_ALARM 20 // Alarm processing.
#define SS_PRIORITY_ICON_UPDATE 20 // Queued icon updates. Mostly used by APCs and tables.
#define SS_PRIORITY_EVENT 20 // Event processing and queue handling.
#define SS_PRIORITY_SHUTTLE 20 // Shuttle movement.
#define SS_PRIORITY_CIRCUIT_COMP 20 // Processing circuit component do_work.
Expand Down
79 changes: 79 additions & 0 deletions code/controllers/subsystems/initialization/icon_updates.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
SUBSYSTEM_DEF(icon_update)
name = "Icon Updates"
wait = 1
priority = SS_PRIORITY_ICON_UPDATE
init_order = SS_INIT_ICON_UPDATE
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT // If you make it not fire in lobby, you also have to remove atoms from queue in Destroy.

// Linked lists, queue_refs[x] should have null or args stored in queue_args[x]
var/list/queue_refs = list() // Atoms
var/list/queue_args = list() // null or args


/datum/controller/subsystem/icon_update/UpdateStat(time)
if (PreventUpdateStat(time))
return ..()
..("queue: [length(queue_refs)]")


/datum/controller/subsystem/icon_update/Initialize(start_uptime)
fire(FALSE, TRUE)


/datum/controller/subsystem/icon_update/fire(resumed = FALSE, no_mc_tick = FALSE)
if(!queue_refs.len)
suspend()
return

while (queue_refs.len)

if(Master.map_loading)
return

// Pops the atom and it's args
var/atom/A = queue_refs[queue_refs.len]
var/myArgs = queue_args[queue_args.len]

queue_refs.len -= 1
queue_args.len -= 1

if(QDELETED(A))
continue

A.icon_update_queued = FALSE

if (islist(myArgs))
A.update_icon(arglist(myArgs))
else
A.update_icon()

if (no_mc_tick)
CHECK_TICK
else if (MC_TICK_CHECK)
return

/atom
var/icon_update_queued = FALSE

/atom/proc/queue_icon_update(...)
// Skips if this is already queued
if(!icon_update_queued)

icon_update_queued = TRUE
SSicon_update.queue_refs.Add(src)

// Makes sure these are in sync, in case runtimes/badmin
var/length = length(SSicon_update.queue_refs)
SSicon_update.queue_args.len = length
SSicon_update.queue_args[length] = args.len ? args : null

// SSicon_update sleeps when it runs out of things in its
// queue, so wake it up.
if(!Master.map_loading) // Don't wake early if we're loading a map, it'll get woken up when the map loads.
SSicon_update.wake()

/datum/controller/subsystem/icon_update/StartLoadingMap()
suspend()

/datum/controller/subsystem/icon_update/StopLoadingMap()
wake()
62 changes: 0 additions & 62 deletions code/controllers/subsystems/processing/icon_updates.dm

This file was deleted.

0 comments on commit 9ee1506

Please sign in to comment.