mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-15 19:46:38 +00:00
MC: No longer tracks a subsystem's cpu usage. This was basically worthless and took up space on the stat panel Can calculate wait down to a tenth of a decisecond to make it fps/world.ticklag agnostic Now allows subsystems to have a dynamic wait, that is based on a ratio of how long that subsystem has been taking to process(cost). (This system allows for upper and lower bounds, and an changeable cost delta for each subsystem) MC can now be told to init a zlevel All Subsystems: Stats panel now allows child subsystems to pass it a message to add to its stats entry. All subsystems have been moved over to this system - This should cut down on subsystems having to copy and paste the stats proc in order to add to it All subsystems now properlly handle being given a zlevel in their init proc Subsystem changes: Air: Added air to the dynamic wait subsystem. upper bound: 50, lower bound: 5, cost delta: 3 times process cost Air now fires 4 times faster when it can do so without lagging things up Pipenet has been merged into air Atmos machinery now processes with process_atmos(), ticked by air, not machinery. Hotspots (the fire object) are now object pooled Pipenet: Deleted, added to air Machinery: Moved all atmos calcualtions in all objects's process() to process_atmos(). Lighting: Added Lighting to the dynamic wait subsystem. upper bound: 20, lower bound: 5, cost delta: 3 times process cost Ticker: Fixed ticker not updating the lobby panel when game start delayed Fixed the game start timer updating rapidly from queued fires when game start delay is removed Garbage/qdel: qdel will now limit its process time to 2ds a fire. qdel can now be given hints as a return to Destroy() as to what should be done with the object. the options are: queue: (default) this is the normal behavior. letmelive: old default to non-null/zero. does nothing with the object iwillgc: functionally the same as above, mainly to let people working with objects know that the object will not be queued for GC checking harddel: this will queue the object to be deleted without storing a soft reference, mainly to save locate() processing time. harddel_now: this will del() the object. To allow for a clean removal of every del() not in qdel All objects have been updated to the new system, harddel and iwillgc was not added to any new objects. Fixed some objects not GCing because they didn't properlly clear references in Destory() Fixed some objects getting qdel'ed preventing other objects from getting GCed because they did not null their reference to that object.
56 lines
2.5 KiB
Plaintext
56 lines
2.5 KiB
Plaintext
#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;}
|
|
|
|
/datum/subsystem
|
|
//things you will want to define
|
|
var/name //name of the subsystem
|
|
var/priority = 0 //priority affects order of initialization. Higher priorities are initialized first, lower priorities later. Can be decimal and negative values.
|
|
var/wait = 20 //time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
|
|
var/dynamic_wait = 0 //changes the wait based on the amount of time it took to process
|
|
var/dwait_upper = 20 //longest wait can be under dynamic_wait
|
|
var/dwait_lower = 5 //shortest wait can be under dynamic_wait
|
|
var/dwait_delta = 3 //How much should processing time effect dwait. or basically: wait = cost*dwait_delta
|
|
|
|
//things you will probably want to leave alone
|
|
var/can_fire = 0 //prevent fire() calls
|
|
var/last_fire = 0 //last world.time we called fire()
|
|
var/next_fire = 0 //scheduled world.time for next fire()
|
|
var/cost = 0 //average time to execute
|
|
var/times_fired = 0 //number of times we have called fire()
|
|
|
|
//used to initialize the subsystem BEFORE the map has loaded
|
|
/datum/subsystem/New()
|
|
|
|
//previously, this would have been named 'process()' but that name is used everywhere for different things!
|
|
//fire() seems more suitable. This is the procedure that gets called every 'wait' deciseconds.
|
|
//fire(), and the procs it calls, SHOULD NOT HAVE ANY SLEEP OPERATIONS in them!
|
|
//YE BE WARNED!
|
|
/datum/subsystem/proc/fire()
|
|
can_fire = 0
|
|
|
|
//used to initialize the subsystem AFTER the map has loaded
|
|
/datum/subsystem/proc/Initialize(start_timeofday, zlevel)
|
|
var/time = (world.timeofday - start_timeofday) / 10
|
|
var/msg = "Initialized [name] SubSystem within [time] seconds"
|
|
if (zlevel)
|
|
testing(msg)
|
|
return
|
|
world << "<span class='boldannounce'>[msg]</span>"
|
|
world.log << msg
|
|
|
|
//hook for printing stats to the "MC" statuspanel for admins to see performance and related stats etc.
|
|
/datum/subsystem/proc/stat_entry(msg)
|
|
var/dwait = ""
|
|
if (dynamic_wait)
|
|
dwait = "DWait:[wait]ds "
|
|
|
|
stat(name, "[round(cost,0.001)]ds\t[dwait][msg]")
|
|
|
|
//could be used to postpone a costly subsystem for one cycle
|
|
//for instance, during cpu intensive operations like explosions
|
|
/datum/subsystem/proc/postpone()
|
|
if(next_fire - world.time < wait)
|
|
next_fire += wait
|
|
|
|
//usually called via datum/subsystem/New() when replacing a subsystem (i.e. due to a recurring crash)
|
|
//should attempt to salvage what it can from the old instance of subsystem
|
|
/datum/subsystem/proc/Recover() |