mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 18:11:47 +00:00
bitflag list construct added: an associative list of bitflags for cheap and quick element comparison between two lists using the same system.
canSmoothWith list turned into a bitflag list.
smoothing_groups list added to substitute the type path list.
smoothing procs turned into atom procs, refactored and optimized a bit.
smooth directions redefined in order to fit in 8 bits for a future smoothing system
some variable names changed, foreseeing a second smoothing system
SMOOTH_OBJ flag added, for things that need to scan turfs for smoothing. The old locate() optimization has the risk of returning false negatives by finding a child and returning null while there might be one of the wanted type as well, as it doesn't match the type exactly.
SMOOTH_TRUE and SMOOTH_MORE condensed into SMOOTH_CORNERS. The old behavior can be replicated using smoothing groups without loss.
Does very minor code cleanup.
Processing-wise didn't find a noticeable difference. The system loses on init a bit by setting the bitflag_lists, and by scanning whole turf contents for object smoothing (increasing accuracy), and gains by making less checks per target to smooth, through the same bitflag_lists.
Memory-wise there should be a small improvement, given that on the old system we had 63512 canSmoothWith lists (a few typelists, most unique), and on this new system canSmoothWith + smoothing_groups are both bitflag_lists from the same pool, totaling 46 in number.
Could be tested a bit to see if I missed any icons not properly smoothing.
75 lines
1.9 KiB
Plaintext
75 lines
1.9 KiB
Plaintext
SUBSYSTEM_DEF(icon_smooth)
|
|
name = "Icon Smoothing"
|
|
init_order = INIT_ORDER_ICON_SMOOTHING
|
|
wait = 1
|
|
priority = FIRE_PRIOTITY_SMOOTHING
|
|
flags = SS_TICKER
|
|
|
|
///Blueprints assemble an image of what pipes/manifolds/wires look like on initialization, and thus should be taken after everything's been smoothed
|
|
var/list/blueprint_queue = list()
|
|
var/list/smooth_queue = list()
|
|
var/list/deferred = list()
|
|
|
|
/datum/controller/subsystem/icon_smooth/fire()
|
|
var/list/cached = smooth_queue
|
|
while(length(cached))
|
|
var/atom/smoothing_atom = cached[length(cached)]
|
|
cached.len--
|
|
if(QDELETED(smoothing_atom) || !(smoothing_atom.smoothing_flags & SMOOTH_QUEUED))
|
|
continue
|
|
if(smoothing_atom.flags_1 & INITIALIZED_1)
|
|
smoothing_atom.smooth_icon()
|
|
else
|
|
deferred += smoothing_atom
|
|
if (MC_TICK_CHECK)
|
|
return
|
|
|
|
if (!cached.len)
|
|
if (deferred.len)
|
|
smooth_queue = deferred
|
|
deferred = cached
|
|
else
|
|
can_fire = FALSE
|
|
|
|
/datum/controller/subsystem/icon_smooth/Initialize()
|
|
smooth_zlevel(1, TRUE)
|
|
smooth_zlevel(2, TRUE)
|
|
|
|
var/list/queue = smooth_queue
|
|
smooth_queue = list()
|
|
|
|
while(length(queue))
|
|
var/atom/smoothing_atom = queue[length(queue)]
|
|
queue.len--
|
|
if(QDELETED(smoothing_atom) || !(smoothing_atom.smoothing_flags & SMOOTH_QUEUED) || smoothing_atom.z <= 2)
|
|
continue
|
|
smoothing_atom.smooth_icon()
|
|
CHECK_TICK
|
|
|
|
queue = blueprint_queue
|
|
blueprint_queue = list()
|
|
|
|
for(var/item in queue)
|
|
var/atom/movable/movable_item = item
|
|
if(!isturf(movable_item.loc))
|
|
continue
|
|
var/turf/item_loc = movable_item.loc
|
|
item_loc.add_blueprints(movable_item)
|
|
|
|
return ..()
|
|
|
|
|
|
/datum/controller/subsystem/icon_smooth/proc/add_to_queue(atom/thing)
|
|
if(thing.smoothing_flags & SMOOTH_QUEUED)
|
|
return
|
|
thing.smoothing_flags |= SMOOTH_QUEUED
|
|
smooth_queue += thing
|
|
if(!can_fire)
|
|
can_fire = TRUE
|
|
|
|
/datum/controller/subsystem/icon_smooth/proc/remove_from_queues(atom/thing)
|
|
thing.smoothing_flags &= ~SMOOTH_QUEUED
|
|
smooth_queue -= thing
|
|
blueprint_queue -= thing
|
|
deferred -= thing
|