mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
* asset cache cdn * Fix cdn rsc (#52886) I was converting this to use length so it didn't have to care if the list existed or not, and forgot to remove the .len. this broke cdn .rsc files because length(num) returns 0. * Add warning about https to the external rsc config (#53367) today in hostchat we discovered that most of the servers who tried to do cdn the .rsc, had unknown issues because they had used https:// urls. Byond can't into https. like 5 servers had failed to get this to work because of that pitfall, so im gonna add a warning to the config. * tchat * tgchat compile * fixes * Merge pull request #53011 from stylemistake/tgui-chat-fix-asay tgchat: Fix asay * chat color * logging * webstorage * compile TGUI * actually like compiles on the DM side * Update chat-dark.scss * Update chat-light.scss * Update resources.txt * Update tgui-panel.bundle.css * Colors * compile * s * s * Ports Gamers TGChat so we can edit it. - NOT LIVE TGCHAT BRANCH (#10226) * asset cache cdn * Fix cdn rsc (#52886) I was converting this to use length so it didn't have to care if the list existed or not, and forgot to remove the .len. this broke cdn .rsc files because length(num) returns 0. * Add warning about https to the external rsc config (#53367) today in hostchat we discovered that most of the servers who tried to do cdn the .rsc, had unknown issues because they had used https:// urls. Byond can't into https. like 5 servers had failed to get this to work because of that pitfall, so im gonna add a warning to the config. * tchat * tgchat compile * fixes * Merge pull request #53011 from stylemistake/tgui-chat-fix-asay tgchat: Fix asay * chat color * logging * webstorage * compile TGUI * actually like compiles on the DM side * Update chat-dark.scss * Update chat-light.scss * Update resources.txt * Update tgui-panel.bundle.css * Colors * compile * s * s Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com> Co-authored-by: Aleksej Komarov <stylemistake@gmail.com> Co-authored-by: TheGamerdk <5618080+TheGamerdk@users.noreply.github.com> Co-authored-by: skoglol <33292112+kriskog@users.noreply.github.com> Co-authored-by: TheSmallBlue <ilanmori@hotmail.com> * Fixes Replay Chat * Update to_chat.dm * Update chat.dm * Update demo.dm * yarn berry * yarn berry compile * Update resources.txt * Update config/resources.txt * Update resources.txt * Attempt at fixing reconnect. * Lets try fix it again * oops * THROW THE SINK AT IT * ree * Makes Travis work again thank you jamie * Fixes snowflake images * Update security.dm * Updates TGChat Test Merge (#10307) * asset cache cdn * Fix cdn rsc (#52886) I was converting this to use length so it didn't have to care if the list existed or not, and forgot to remove the .len. this broke cdn .rsc files because length(num) returns 0. * Add warning about https to the external rsc config (#53367) today in hostchat we discovered that most of the servers who tried to do cdn the .rsc, had unknown issues because they had used https:// urls. Byond can't into https. like 5 servers had failed to get this to work because of that pitfall, so im gonna add a warning to the config. * tchat * tgchat compile * fixes * Merge pull request #53011 from stylemistake/tgui-chat-fix-asay tgchat: Fix asay * chat color * logging * webstorage * compile TGUI * actually like compiles on the DM side * Update chat-dark.scss * Update chat-light.scss * Update resources.txt * Update tgui-panel.bundle.css * Colors * compile * s * s * Ports Gamers TGChat so we can edit it. - NOT LIVE TGCHAT BRANCH (#10226) * asset cache cdn * Fix cdn rsc (#52886) I was converting this to use length so it didn't have to care if the list existed or not, and forgot to remove the .len. this broke cdn .rsc files because length(num) returns 0. * Add warning about https to the external rsc config (#53367) today in hostchat we discovered that most of the servers who tried to do cdn the .rsc, had unknown issues because they had used https:// urls. Byond can't into https. like 5 servers had failed to get this to work because of that pitfall, so im gonna add a warning to the config. * tchat * tgchat compile * fixes * Merge pull request #53011 from stylemistake/tgui-chat-fix-asay tgchat: Fix asay * chat color * logging * webstorage * compile TGUI * actually like compiles on the DM side * Update chat-dark.scss * Update chat-light.scss * Update resources.txt * Update tgui-panel.bundle.css * Colors * compile * s * s Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com> Co-authored-by: Aleksej Komarov <stylemistake@gmail.com> Co-authored-by: TheGamerdk <5618080+TheGamerdk@users.noreply.github.com> Co-authored-by: skoglol <33292112+kriskog@users.noreply.github.com> Co-authored-by: TheSmallBlue <ilanmori@hotmail.com> * Fixes Replay Chat * Update to_chat.dm * Update chat.dm * Update demo.dm * yarn berry * yarn berry compile * Update resources.txt * Update config/resources.txt * Update resources.txt * Attempt at fixing reconnect. * Lets try fix it again * oops * THROW THE SINK AT IT * ree * Makes Travis work again thank you jamie * Fixes snowflake images * Update security.dm Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com> Co-authored-by: Aleksej Komarov <stylemistake@gmail.com> Co-authored-by: TheGamerdk <5618080+TheGamerdk@users.noreply.github.com> Co-authored-by: skoglol <33292112+kriskog@users.noreply.github.com> Co-authored-by: TheSmallBlue <ilanmori@hotmail.com> Co-authored-by: alexkar598 <25136265+alexkar598@users.noreply.github.com> * Fixes * Undo Kitchen Sink * Fucking 7 Hours. * status panel * stat panel fixes * fixes * stat panel stuff * Stat panel finish * Compile, oops * Update server_maint.dm * Update world.dm * Update interface.dm * tgui compile * Update subsystems.dm * fix statpanel deleting whole admin tab (#54211) fix: adminhelping no longer removes entire admin tab fix: end of round no longer removes entire admin tab * Update skin.dmf * verbs? Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com> Co-authored-by: Aleksej Komarov <stylemistake@gmail.com> Co-authored-by: skoglol <33292112+kriskog@users.noreply.github.com> Co-authored-by: TheSmallBlue <ilanmori@hotmail.com> Co-authored-by: Jamie D <993128+JamieD1@users.noreply.github.com> Co-authored-by: alexkar598 <25136265+alexkar598@users.noreply.github.com> Co-authored-by: Couls <coul422@gmail.com> Co-authored-by: Tad Hardesty <tad@platymuus.com> Co-authored-by: Bobbahbrown <bobbahbrown@gmail.com>
218 lines
7.7 KiB
Plaintext
218 lines
7.7 KiB
Plaintext
|
|
/datum/controller/subsystem
|
|
// Metadata; you should define these.
|
|
name = "fire coderbus" //name of the subsystem
|
|
var/init_order = INIT_ORDER_DEFAULT //order of initialization. Higher numbers are initialized first, lower numbers later. Use defines in __DEFINES/subsystems.dm for easy understanding of order.
|
|
var/wait = 20 //time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
|
|
var/priority = FIRE_PRIORITY_DEFAULT //When mutiple subsystems need to run in the same tick, higher priority subsystems will run first and be given a higher share of the tick before MC_TICK_CHECK triggers a sleep
|
|
|
|
var/flags = 0 //see MC.dm in __DEFINES Most flags must be set on world start to take full effect. (You can also restart the mc to force them to process again)
|
|
|
|
var/initialized = FALSE //set to TRUE after it has been initialized, will obviously never be set if the subsystem doesn't initialize
|
|
|
|
//set to 0 to prevent fire() calls, mostly for admin use or subsystems that may be resumed later
|
|
// use the SS_NO_FIRE flag instead for systems that never fire to keep it from even being added to the list
|
|
var/can_fire = TRUE
|
|
|
|
// Bookkeeping variables; probably shouldn't mess with these.
|
|
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/tick_usage = 0 //average tick usage
|
|
var/tick_overrun = 0 //average tick overrun
|
|
var/state = SS_IDLE //tracks the current state of the ss, running, paused, etc.
|
|
var/paused_ticks = 0 //ticks this ss is taking to run right now.
|
|
var/paused_tick_usage //total tick_usage of all of our runs while pausing this run
|
|
var/ticks = 1 //how many ticks does this ss take to run on avg.
|
|
var/times_fired = 0 //number of times we have called fire()
|
|
var/queued_time = 0 //time we entered the queue, (for timing and priority reasons)
|
|
var/queued_priority //we keep a running total to make the math easier, if priority changes mid-fire that would break our running total, so we store it here
|
|
//linked list stuff for the queue
|
|
var/datum/controller/subsystem/queue_next
|
|
var/datum/controller/subsystem/queue_prev
|
|
|
|
var/runlevels = RUNLEVELS_DEFAULT //points of the game at which the SS can fire
|
|
|
|
var/static/list/failure_strikes //How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out!
|
|
|
|
//Do not override
|
|
///datum/controller/subsystem/New()
|
|
|
|
// Used to initialize the subsystem BEFORE the map has loaded
|
|
// Called AFTER Recover if that is called
|
|
// Prefer to use Initialize if possible
|
|
/datum/controller/subsystem/proc/PreInit()
|
|
return
|
|
|
|
//This is used so the mc knows when the subsystem sleeps. do not override.
|
|
/datum/controller/subsystem/proc/ignite(resumed = FALSE)
|
|
SHOULD_NOT_OVERRIDE(TRUE)
|
|
set waitfor = FALSE
|
|
. = SS_SLEEPING
|
|
fire(resumed)
|
|
. = state
|
|
if (state == SS_SLEEPING)
|
|
state = SS_IDLE
|
|
if (state == SS_PAUSING)
|
|
var/QT = queued_time
|
|
enqueue()
|
|
state = SS_PAUSED
|
|
queued_time = QT
|
|
|
|
//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.
|
|
//Sleeping in here prevents future fires until returned.
|
|
/datum/controller/subsystem/proc/fire(resumed = FALSE)
|
|
flags |= SS_NO_FIRE
|
|
CRASH("Subsystem [src]([type]) does not fire() but did not set the SS_NO_FIRE flag. Please add the SS_NO_FIRE flag to any subsystem that doesn't fire so it doesn't get added to the processing list and waste cpu.")
|
|
|
|
/datum/controller/subsystem/Destroy()
|
|
dequeue()
|
|
can_fire = 0
|
|
flags |= SS_NO_FIRE
|
|
Master.subsystems -= src
|
|
return ..()
|
|
|
|
//Queue it to run.
|
|
// (we loop thru a linked list until we get to the end or find the right point)
|
|
// (this lets us sort our run order correctly without having to re-sort the entire already sorted list)
|
|
/datum/controller/subsystem/proc/enqueue()
|
|
var/SS_priority = priority
|
|
var/SS_flags = flags
|
|
var/datum/controller/subsystem/queue_node
|
|
var/queue_node_priority
|
|
var/queue_node_flags
|
|
|
|
for (queue_node = Master.queue_head; queue_node; queue_node = queue_node.queue_next)
|
|
queue_node_priority = queue_node.queued_priority
|
|
queue_node_flags = queue_node.flags
|
|
|
|
if (queue_node_flags & SS_TICKER)
|
|
if (!(SS_flags & SS_TICKER))
|
|
continue
|
|
if (queue_node_priority < SS_priority)
|
|
break
|
|
|
|
else if (queue_node_flags & SS_BACKGROUND)
|
|
if (!(SS_flags & SS_BACKGROUND))
|
|
break
|
|
if (queue_node_priority < SS_priority)
|
|
break
|
|
|
|
else
|
|
if (SS_flags & SS_BACKGROUND)
|
|
continue
|
|
if (SS_flags & SS_TICKER)
|
|
break
|
|
if (queue_node_priority < SS_priority)
|
|
break
|
|
|
|
queued_time = world.time
|
|
queued_priority = SS_priority
|
|
state = SS_QUEUED
|
|
if (SS_flags & SS_BACKGROUND) //update our running total
|
|
Master.queue_priority_count_bg += SS_priority
|
|
else
|
|
Master.queue_priority_count += SS_priority
|
|
|
|
queue_next = queue_node
|
|
if (!queue_node)//we stopped at the end, add to tail
|
|
queue_prev = Master.queue_tail
|
|
if (Master.queue_tail)
|
|
Master.queue_tail.queue_next = src
|
|
else //empty queue, we also need to set the head
|
|
Master.queue_head = src
|
|
Master.queue_tail = src
|
|
|
|
else if (queue_node == Master.queue_head)//insert at start of list
|
|
Master.queue_head.queue_prev = src
|
|
Master.queue_head = src
|
|
queue_prev = null
|
|
else
|
|
queue_node.queue_prev.queue_next = src
|
|
queue_prev = queue_node.queue_prev
|
|
queue_node.queue_prev = src
|
|
|
|
|
|
/datum/controller/subsystem/proc/dequeue()
|
|
if (queue_next)
|
|
queue_next.queue_prev = queue_prev
|
|
if (queue_prev)
|
|
queue_prev.queue_next = queue_next
|
|
if (src == Master.queue_tail)
|
|
Master.queue_tail = queue_prev
|
|
if (src == Master.queue_head)
|
|
Master.queue_head = queue_next
|
|
queued_time = 0
|
|
if (state == SS_QUEUED)
|
|
state = SS_IDLE
|
|
|
|
|
|
/datum/controller/subsystem/proc/pause()
|
|
. = 1
|
|
switch(state)
|
|
if(SS_RUNNING)
|
|
state = SS_PAUSED
|
|
if(SS_SLEEPING)
|
|
state = SS_PAUSING
|
|
|
|
/// Called after the config has been loaded or reloaded.
|
|
/datum/controller/subsystem/proc/OnConfigLoad()
|
|
|
|
//used to initialize the subsystem AFTER the map has loaded
|
|
/datum/controller/subsystem/Initialize(start_timeofday)
|
|
initialized = TRUE
|
|
var/time = (REALTIMEOFDAY - start_timeofday) / 10
|
|
var/msg = "Initialized [name] subsystem within [time] second[time == 1 ? "" : "s"]!"
|
|
to_chat(world, "<span class='boldannounce'>[msg]</span>")
|
|
log_world(msg)
|
|
return time
|
|
|
|
|
|
/datum/controller/subsystem/stat_entry(msg)
|
|
if(can_fire && !(SS_NO_FIRE & flags))
|
|
msg = "[round(cost,1)]ms|[round(tick_usage,1)]%([round(tick_overrun,1)]%)|[round(ticks,0.1)]\t[msg]"
|
|
else
|
|
msg = "OFFLINE\t[msg]"
|
|
return msg
|
|
|
|
/datum/controller/subsystem/stat_entry(msg)
|
|
if(can_fire && !(SS_NO_FIRE & flags))
|
|
msg = "[round(cost,1)]ms|[round(tick_usage,1)]%([round(tick_overrun,1)]%)|[round(ticks,0.1)]\t[msg]"
|
|
else
|
|
msg = "OFFLINE\t[msg]"
|
|
return msg
|
|
|
|
/datum/controller/subsystem/proc/state_letter()
|
|
switch (state)
|
|
if (SS_RUNNING)
|
|
. = "R"
|
|
if (SS_QUEUED)
|
|
. = "Q"
|
|
if (SS_PAUSED, SS_PAUSING)
|
|
. = "P"
|
|
if (SS_SLEEPING)
|
|
. = "S"
|
|
if (SS_IDLE)
|
|
. = " "
|
|
|
|
//could be used to postpone a costly subsystem for (default one) var/cycles, cycles
|
|
//for instance, during cpu intensive operations like explosions
|
|
/datum/controller/subsystem/proc/postpone(cycles = 1)
|
|
if(next_fire - world.time < wait)
|
|
next_fire += (wait*cycles)
|
|
|
|
//usually called via datum/controller/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/controller/subsystem/Recover()
|
|
|
|
/datum/controller/subsystem/vv_edit_var(var_name, var_value)
|
|
switch (var_name)
|
|
if ("can_fire")
|
|
//this is so the subsystem doesn't rapid fire to make up missed ticks causing more lag
|
|
if (var_value)
|
|
next_fire = world.time + wait
|
|
if ("queued_priority") //editing this breaks things.
|
|
return 0
|
|
. = ..()
|