Files
VOREStation/code/controllers/subsystems/server_maint.dm
T
Cameron Lennox 84dc5535dc var/global/list -> GLOB. conversion (#17928)
* These two are easy

* !!!runlevel_flags

the fact it was global.runlevel_flags.len has me a bit...iffy on this.

* !!!json_cache

Same as above. used global.

* player_list & observer_mob_list

* mechas_list

* this wasn't even used

* surgery_steps

* event_triggers

* landmarks_list

* dead_mob_list

* living_mob_list

* ai_list

* cable_list

* cleanbot_reserved_turfs

* listening_objects

* silicon_mob_list

* human_mob_list

* Update global_lists.dm

* joblist

* mob_list

* Update global_lists.dm

* holomap_markers

* mapping_units

* mapping_beacons

* hair_styles_list

* facial_hair_styles_list

* Update global_lists.dm

* facial_hair_styles_male_list

* facial_hair_styles_female_list

* body_marking_styles_list

* body_marking_nopersist_list

* ear_styles_list

* hair_styles_male_list

* tail_styles_list

* wing_styles_list

* escape_list & rune_list & endgame_exits

these were all really small

* endgame_safespawns

* stool_cache

* emotes_by_key

* random_maps & map_count

* item_tf_spawnpoints

* narsie_list

* active_radio_jammers

* unused

* paikeys

* pai_software_by_key & default_pai_software

* plant_seed_sprites

* magazine_icondata_keys  & magazine_icondata_states

* unused

* ashtray_cache

* light_type_cache

* HOLIDAY!!!

this one was annoying

* faction stuff (red?!)

* Update preferences_factions.dm

* vs edit removal

* backbaglist, pdachoicelist, exclude_jobs

* item_digestion_blacklist, edible_tech, blacklisted_artifact_effect, selectable_footstep, hexNums, syndicate_access

* string_slot_flags and hexdigits->hexNums

* possible_changeling_IDs

* vr_mob_tf_options

* vr_mob_spawner_options

* pipe_colors

* vr_mob_spawner_options

* common_tools

* newscaster_standard_feeds

* Update periodic_news.dm

* changeling_fabricated_clothing

* semirandom_mob_spawner_decisions

* id_card_states

* Update syndicate_ids.dm

* overlay_cache & gear_distributed_to

* more

* radio_channels_by_freq

* Update global_lists.dm

* proper

* default_medbay_channels & default_internal_channels

default_internal_channels is weird as it has a mapbased proc() but that proc is never called...

* valid_ringtones

* move this

* possible_plants

* more

* separate these

moves xeno2chemlist from a hook to a new global list.

* tube_dir_list

* valid_bloodreagents & monitor_states

* Junk

* valid_bloodtypes

* breach_burn_descriptors & burn

* more!!

appliance_available_recipes seems uber cursed, re-look at later

* Appliance code is cursed

* wide_chassis & flying_chassis

* allows_eye_color

* all_tooltip_styles

* direction_table

* gun_choices

* severity_to_string

* old event_viruses

* description_icons

* MOVE_KEY_MAPPINGS

* more more

* pai & robot modules

* Update global_lists.dm

* GEOSAMPLES

Also swaps a .len to LAZYLEN()

* shieldgens

* reagent recipies

* global ammo types

* rad collector

* old file and unused global

* nif_look_messages

* FESH

* nifsoft

* chamelion

* the death of sortAtom

* globulins

* lazylen that

* Update global_lists.dm

* LAZY

* Theese too

* quick fix

---------

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
2025-07-14 20:14:31 +02:00

116 lines
4.4 KiB
Plaintext

#define PING_BUFFER_TIME 25
SUBSYSTEM_DEF(server_maint)
name = "Server Tasks"
wait = 6
flags = SS_POST_FIRE_TIMING
priority = FIRE_PRIORITY_SERVER_MAINT
init_order = INIT_ORDER_SERVER_MAINT
//init_stage = INITSTAGE_EARLY
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
var/list/currentrun
///Associated list of list names to lists to clear of nulls
var/list/lists_to_clear
///Delay between list clearings in ticks
var/delay = 5
var/cleanup_ticker = 0
/*/datum/controller/subsystem/server_maint/PreInit()
world.hub_password = "" *///quickly! before the hubbies see us.
/datum/controller/subsystem/server_maint/Initialize()
if (fexists("tmp/"))
fdel("tmp/")
//if (CONFIG_GET(flag/hub))
//world.update_hub_visibility(TRUE)
//Keep in mind, because of how delay works adding a list here makes each list take wait * delay more time to clear
//Do it for stuff that's properly important, and shouldn't have null checks inside its other uses
lists_to_clear = list(
"player_list" = GLOB.player_list,
"mob_list" = GLOB.mob_list,
"living_mob_list" = GLOB.living_mob_list,
"dead_mob_list" = GLOB.dead_mob_list,
"observer_mob_list" = GLOB.observer_mob_list,
"listening_objects" = GLOB.listening_objects,
"human_mob_list" = GLOB.human_mob_list,
"silicon_mob_list" = GLOB.silicon_mob_list,
"ai_list" = GLOB.ai_list,
//"keyloop_list" = global.keyloop_list, //A null here will cause new clients to be unable to move. totally unacceptable
)
/*var/datum/tgs_version/tgsversion = world.TgsVersion()
if(tgsversion)
SSblackbox.record_feedback("text", "server_tools", 1, tgsversion.raw_parameter)*/
return SS_INIT_SUCCESS
/datum/controller/subsystem/server_maint/fire(resumed = FALSE)
if(!resumed)
if(list_clear_nulls(GLOB.clients))
log_world("Found a null in clients list!")
src.currentrun = GLOB.clients.Copy()
var/position_in_loop = (cleanup_ticker / delay) + 1 //Index at 1, thanks byond
if(!(position_in_loop % 1)) //If it's a whole number
var/listname = lists_to_clear[position_in_loop]
if(list_clear_nulls(lists_to_clear[listname]))
log_world("Found a null in [listname]!")
cleanup_ticker++
var/amount_to_work = length(lists_to_clear)
if(cleanup_ticker >= amount_to_work * delay) //If we've already done a loop, reset
cleanup_ticker = 0
var/list/currentrun = src.currentrun
//var/round_started = SSticker.HasRoundStarted()
//var/kick_inactive = CONFIG_GET(flag/kick_inactive)
//var/afk_period
//if(kick_inactive)
//afk_period = CONFIG_GET(number/afk_period)
for(var/I in currentrun)
var/client/C = I
//handle kicking inactive players
/*if(round_started && kick_inactive && !C.holder && C.is_afk(afk_period))
var/cmob = C.mob
if (!isnewplayer(cmob) || !SSticker.queued_players.Find(cmob))
log_access("AFK: [key_name(C)]")
to_chat(C, span_userdanger("You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.") + "<br>" + span_danger("You may reconnect via the button in the file menu or by " + span_bold(span_underline("<a href='byond://winset?command=.reconnect'>clicking here to reconnect</a>")" + "."))
QDEL_IN(C, 1) //to ensure they get our message before getting disconnected
continue*/
if (!(!C || world.time - C.connection_time < PING_BUFFER_TIME || C.inactivity >= (wait-1)))
winset(C, null, "command=.update_ping+[num2text(world.time+world.tick_lag*TICK_USAGE_REAL/100, 32)]")
if (MC_TICK_CHECK) //one day, when ss13 has 1000 people per server, you guys are gonna be glad I added this tick check
return
/datum/controller/subsystem/server_maint/Shutdown()
if (fexists("tmp/"))
fdel("tmp/")
//kick_clients_in_lobby(span_boldannounce("The round came to an end with you in the lobby."), TRUE) //second parameter ensures only afk clients are kicked
var/server = CONFIG_GET(string/server)
for(var/thing in GLOB.clients)
if(!thing)
continue
var/client/C = thing
C?.tgui_panel?.send_roundrestart()
if(server) //if you set a server location in config.txt, it sends you there instead of trying to reconnect to the same world address. -- NeoFite
C << link("byond://[server]")
/*
/datum/controller/subsystem/server_maint/proc/UpdateHubStatus()
if(!CONFIG_GET(flag/hub) || !CONFIG_GET(number/max_hub_pop))
return FALSE //no point, hub / auto hub controls are disabled
var/max_pop = CONFIG_GET(number/max_hub_pop)
if(GLOB.clients.len > max_pop)
world.update_hub_visibility(FALSE)
else
world.update_hub_visibility(TRUE)
*/
#undef PING_BUFFER_TIME