Files
Bubberstation/code/controllers/subsystem/processing/reagents.dm
T
SyncIt21 56212d2712 Cleans up chemical reaction & reagent look up code (#95281)
## About The Pull Request
- Removed global list `fake_reagent_blacklist` in favour of
`abstract_type`. Saved memory
- Removed proc `get_chemical_reaction()` in favor of
`GLOB.chemical_reaction_list`. No proc overhead and faster access
- Remove unused proc `remove_chemical_reaction()`
- Removed proc `find_reagent()` in favour of
`GLOB.chemical_reagents_list`. No proc overhead and faster access
- Directly access name of reagents via `::` operator from typepaths
instead of looking up the datum in global chemical reagents list for
some operations. Faster variable access
- Removed unit test `reagent_id_typos`. The typepaths will error at
compile time because they aren't strings so there's no need for this
test

## Changelog
🆑
code: cleaned up code pertaining to reagent & reaction lookup
/🆑
2026-03-07 10:39:20 +01:00

41 lines
1.5 KiB
Plaintext

//Used for active reactions in reagents/equilibrium datums
PROCESSING_SUBSYSTEM_DEF(reagents)
name = "Reagents"
priority = FIRE_PRIORITY_REAGENTS
wait = 0.25 SECONDS //You might think that rate_up_lim has to be set to half, but since everything is normalised around seconds_per_tick, it automatically adjusts it to be per second. Magic!
flags = SS_KEEP_TIMING
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
init_stage = INITSTAGE_EARLY
///What time was it when we last ticked
var/previous_world_time = 0
/datum/controller/subsystem/processing/reagents/Initialize()
//So our first step isn't insane
previous_world_time = world.time
//Build GLOB lists - see holder.dm
build_chemical_reactions_lists()
return SS_INIT_SUCCESS
/datum/controller/subsystem/processing/reagents/fire(resumed = FALSE)
if (!resumed)
currentrun = processing.Copy()
//cache for sanic speed (lists are references anyways)
var/list/current_run = currentrun
//Attempt to realtime reactions in a way that doesn't make them overtly dangerous
var/delta_realtime = (world.time - previous_world_time)/10 //normalise to s from ds
previous_world_time = world.time
while(current_run.len)
var/datum/thing = current_run[current_run.len]
current_run.len--
if(QDELETED(thing))
stack_trace("Found qdeleted thing in [type], in the current_run list.")
processing -= thing
else if(thing.process(delta_realtime) == PROCESS_KILL) //we are realtime
// fully stop so that a future START_PROCESSING will work
STOP_PROCESSING(src, thing)
if (MC_TICK_CHECK)
return