Files
Bubberstation/code/controllers/subsystem/ping.dm
SkyratBot e3a638f179 [MIRROR] RUNLEVEL_INIT does not exist [MDB IGNORE] (#20857)
* RUNLEVEL_INIT does not exist (#75023)

This define shouldn't have been added (by me when I created runlevels)
people get it confused with RUNLEVEL_LOBBY and misuse it, like in this
verb subsystem I have no knowledge of.

- Removes RUNLEVEL_INIT.
- Fixed SSverb_manager not running during the lobby phase.
- Fixed Master.SetRunLevel having the potential to accept a scuffed
runlevel.
- Other standardizing cleanups to runlevels usage.

* RUNLEVEL_INIT does not exist

---------

Co-authored-by: Jordan Dominion <Cyberboss@users.noreply.github.com>
2023-05-02 15:49:14 -04:00

40 lines
1017 B
Plaintext

/*!
* Copyright (c) 2022 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
SUBSYSTEM_DEF(ping)
name = "Ping"
priority = FIRE_PRIORITY_PING
init_stage = INITSTAGE_EARLY
wait = 4 SECONDS
flags = SS_NO_INIT
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
var/list/currentrun = list()
/datum/controller/subsystem/ping/stat_entry()
..("P:[GLOB.clients.len]")
/datum/controller/subsystem/ping/fire(resumed = FALSE)
// Prepare the new batch of clients
if (!resumed)
src.currentrun = GLOB.clients.Copy()
// De-reference the list for sanic speeds
var/list/currentrun = src.currentrun
while (currentrun.len)
var/client/client = currentrun[currentrun.len]
currentrun.len--
if (client?.tgui_panel?.is_ready())
// Send a soft ping
client.tgui_panel.window.send_message("ping/soft", list(
// Slightly less than the subsystem timer (somewhat arbitrary)
// to prevent incoming pings from resetting the afk state
"afk" = client.is_afk(3.5 SECONDS),
))
if (MC_TICK_CHECK)
return