mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 13:38:41 +01:00
[MIRROR] Adds keyloop to the autoclearing ss, cleans up ssambience a bit (#8330)
* Adds keyloop to the autoclearing ss, cleans up ssambience a bit * Update ambience.dm Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
co-authored by
LemonInTheDark
Gandalf
parent
da3076fa46
commit
e6a5103f0b
@@ -7,28 +7,43 @@ SUBSYSTEM_DEF(ambience)
|
||||
wait = 1 SECONDS
|
||||
///Assoc list of listening client - next ambience time
|
||||
var/list/ambience_listening_clients = list()
|
||||
///Cache for sanic speed :D
|
||||
var/list/currentrun = list()
|
||||
|
||||
/datum/controller/subsystem/ambience/fire(resumed)
|
||||
for(var/client/client_iterator as anything in ambience_listening_clients)
|
||||
if(!resumed)
|
||||
currentrun = ambience_listening_clients.Copy()
|
||||
var/list/cached_clients = currentrun
|
||||
|
||||
if(isnull(client_iterator) || isnewplayer(client_iterator.mob))
|
||||
ambience_listening_clients -= client_iterator
|
||||
continue
|
||||
while(cached_clients.len)
|
||||
var/client/client_iterator = cached_clients[cached_clients.len]
|
||||
cached_clients.len--
|
||||
process_ambience_client(client_iterator)
|
||||
|
||||
if(ambience_listening_clients[client_iterator] > world.time)
|
||||
continue //Not ready for the next sound
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
var/area/current_area = get_area(client_iterator.mob)
|
||||
/datum/controller/subsystem/ambience/proc/process_ambience_client(client/to_process)
|
||||
if(isnull(to_process) || isnewplayer(to_process.mob))
|
||||
ambience_listening_clients -= to_process
|
||||
return
|
||||
|
||||
//SKYRAT EDIT ADDITION BEGIN
|
||||
var/volume_mod = 30
|
||||
if(ambience_listening_clients[to_process] > world.time)
|
||||
return //Not ready for the next sound
|
||||
|
||||
if(current_area.ambience_index == AMBIENCE_GENERIC)
|
||||
volume_mod = 85
|
||||
//SKYRAT EDIT END
|
||||
var/area/current_area = get_area(to_process.mob)
|
||||
|
||||
var/sound = pick(current_area.ambientsounds)
|
||||
if(!current_area) //Something's gone horribly wrong
|
||||
stack_trace("[key_name(to_process)] has somehow ended up in nullspace. WTF did you do")
|
||||
ambience_listening_clients -= to_process
|
||||
return
|
||||
|
||||
SEND_SOUND(client_iterator.mob, sound(sound, repeat = 0, wait = 0, volume = volume_mod, channel = CHANNEL_AMBIENCE)) //SKYRAT EDIT CHANGE - ORIGINAL: SEND_SOUND(client_iterator.mob, sound(sound, repeat = 0, wait = 0, volume = 25, channel = CHANNEL_AMBIENCE))
|
||||
var/sound = pick(current_area.ambientsounds)
|
||||
|
||||
ambience_listening_clients[client_iterator] = world.time + rand(current_area.min_ambience_cooldown, current_area.max_ambience_cooldown)
|
||||
SEND_SOUND(to_process.mob, sound(sound, repeat = 0, wait = 0, volume = 25, channel = CHANNEL_AMBIENCE))
|
||||
|
||||
ambience_listening_clients[to_process] = world.time + rand(current_area.min_ambience_cooldown, current_area.max_ambience_cooldown)
|
||||
|
||||
/datum/controller/subsystem/ambience/proc/remove_ambience_client(client/to_remove)
|
||||
ambience_listening_clients -= to_remove
|
||||
currentrun -= to_remove
|
||||
|
||||
@@ -8,6 +8,10 @@ SUBSYSTEM_DEF(server_maint)
|
||||
init_order = INIT_ORDER_SERVER_MAINT
|
||||
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()
|
||||
@@ -16,6 +20,16 @@ SUBSYSTEM_DEF(server_maint)
|
||||
/datum/controller/subsystem/server_maint/Initialize(timeofday)
|
||||
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,
|
||||
"alive_mob_list" = GLOB.alive_mob_list,
|
||||
"suicided_mob_list" = GLOB.suicided_mob_list,
|
||||
"dead_mob_list" = GLOB.dead_mob_list,
|
||||
"keyloop_list" = GLOB.keyloop_list, //A null here will cause new clients to be unable to move. totally unacceptable
|
||||
)
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/server_maint/fire(resumed = FALSE)
|
||||
@@ -24,31 +38,18 @@ SUBSYSTEM_DEF(server_maint)
|
||||
log_world("Found a null in clients list!")
|
||||
src.currentrun = GLOB.clients.Copy()
|
||||
|
||||
switch (cleanup_ticker) // do only one of these at a time, once per 5 fires
|
||||
if (0)
|
||||
if(listclearnulls(GLOB.player_list))
|
||||
log_world("Found a null in player_list!")
|
||||
cleanup_ticker++
|
||||
if (5)
|
||||
if(listclearnulls(GLOB.mob_list))
|
||||
log_world("Found a null in mob_list!")
|
||||
cleanup_ticker++
|
||||
if (10)
|
||||
if(listclearnulls(GLOB.alive_mob_list))
|
||||
log_world("Found a null in alive_mob_list!")
|
||||
cleanup_ticker++
|
||||
if (15)
|
||||
if(listclearnulls(GLOB.suicided_mob_list))
|
||||
log_world("Found a null in suicided_mob_list!")
|
||||
cleanup_ticker++
|
||||
if (20)
|
||||
if(listclearnulls(GLOB.dead_mob_list))
|
||||
log_world("Found a null in dead_mob_list!")
|
||||
cleanup_ticker++
|
||||
if (25)
|
||||
cleanup_ticker = 0
|
||||
else
|
||||
cleanup_ticker++
|
||||
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(listclearnulls(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()
|
||||
|
||||
@@ -523,7 +523,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
UNSETEMPTY(movingmob.client_mobs_in_contents)
|
||||
movingmob = null
|
||||
active_mousedown_item = null
|
||||
SSambience.ambience_listening_clients -= src
|
||||
SSambience.remove_ambience_client(src)
|
||||
QDEL_NULL(view_size)
|
||||
QDEL_NULL(void)
|
||||
QDEL_NULL(tooltips)
|
||||
@@ -1145,7 +1145,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
return // If already properly set we don't want to reset the timer.
|
||||
SSambience.ambience_listening_clients[src] = world.time + 10 SECONDS //Just wait 10 seconds before the next one aight mate? cheers.
|
||||
else
|
||||
SSambience.ambience_listening_clients -= src
|
||||
SSambience.remove_ambience_client(src)
|
||||
|
||||
/// Checks if this client has met the days requirement passed in, or if
|
||||
/// they are exempt from it.
|
||||
|
||||
Reference in New Issue
Block a user