mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
* Drastic Lag Mitigation Subsystem: SSlag_switch (#59717) Requested by oranges and inspired by the upcoming event. A new subsyetem, non-processing (for now), aimed at providing some toggle switches that can be flipped as a last ditch effort to save some CPU cycles by sacrificing some non-critical mechanics. Below you can see each individual toggle. Screenshot of the admin panel: image Surely there are more opportunities for toggles I missed, but adding new ones is not very difficult at all. Why It's Good For The Game Better performance during extreme pop, I hope. Changelog cl code: Introduces the Lag Switch subsystem for when a smoother experience is worth trading a few bells and whistles for. Performance enhancement measures can be togged by admins with the Show Lag Switches admin verb or enabled automatically at a pop amount set via config. config: Added a new config var: number/auto_lag_switch_pop * Drastic Lag Mitigation Subsystem: SSlag_switch * mirrored the changes to the modular file Co-authored-by: Wayland-Smithy <64715958+Wayland-Smithy@users.noreply.github.com> Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com>
172 lines
5.7 KiB
Plaintext
172 lines
5.7 KiB
Plaintext
//Speech verbs.
|
|
|
|
///Say verb
|
|
/mob/verb/say_verb(message as text)
|
|
set name = "Say"
|
|
set category = "IC"
|
|
//SKYRAT EDIT ADDITION BEGIN - TYPING_INDICATOR
|
|
if(typing_indicator)
|
|
set_typing_indicator(FALSE)
|
|
//SKYRAT EDIT ADDITION END
|
|
if(GLOB.say_disabled) //This is here to try to identify lag problems
|
|
to_chat(usr, span_danger("Speech is currently admin-disabled."))
|
|
return
|
|
if(message)
|
|
say(message)
|
|
|
|
///Whisper verb
|
|
/mob/verb/whisper_verb(message as text)
|
|
set name = "Whisper"
|
|
set category = "IC"
|
|
if(GLOB.say_disabled) //This is here to try to identify lag problems
|
|
to_chat(usr, span_danger("Speech is currently admin-disabled."))
|
|
return
|
|
whisper(message)
|
|
|
|
///whisper a message
|
|
/mob/proc/whisper(message, datum/language/language=null)
|
|
say(message, language) //only living mobs actually whisper, everything else just talks
|
|
|
|
///The me emote verb
|
|
//SKYRAT EDIT CHANGE BEGIN
|
|
// /mob/verb/me_verb(message as text) - SKYRAT EDIT - ORIGINAL
|
|
/mob/verb/me_verb(message as message)
|
|
//SKYRAT EDIT CHANGE END
|
|
set name = "Me"
|
|
set category = "IC"
|
|
//SKYRAT EDIT ADDITION BEGIN - TYPING_INDICATOR
|
|
if(typing_indicator)
|
|
set_typing_indicator(FALSE)
|
|
//SKYRAT EDIT ADDITION END
|
|
|
|
if(GLOB.say_disabled) //This is here to try to identify lag problems
|
|
to_chat(usr, span_danger("Speech is currently admin-disabled."))
|
|
return
|
|
|
|
message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
|
|
|
|
usr.emote("me",1,message,TRUE)
|
|
|
|
///Speak as a dead person (ghost etc)
|
|
/mob/proc/say_dead(message)
|
|
var/name = real_name
|
|
var/alt_name = ""
|
|
|
|
if(GLOB.say_disabled) //This is here to try to identify lag problems
|
|
to_chat(usr, span_danger("Speech is currently admin-disabled."))
|
|
return
|
|
|
|
//SKYRAT EDIT ADDITION
|
|
if(!GLOB.dchat_allowed && !check_rights(R_ADMIN, FALSE))
|
|
to_chat(src, "<span class='danger'>Dead chat is currently muted.</span>")
|
|
return
|
|
//SKYRAT EDIT END
|
|
|
|
var/jb = is_banned_from(ckey, "Deadchat")
|
|
if(QDELETED(src))
|
|
return
|
|
|
|
if(jb)
|
|
to_chat(src, span_danger("You have been banned from deadchat."))
|
|
return
|
|
|
|
|
|
|
|
if (src.client)
|
|
if(src.client.prefs.muted & MUTE_DEADCHAT)
|
|
to_chat(src, span_danger("You cannot talk in deadchat (muted)."))
|
|
return
|
|
|
|
if(SSlag_switch.measures[SLOWMODE_SAY] && !HAS_TRAIT(src, TRAIT_BYPASS_MEASURES) && src == usr)
|
|
if(!COOLDOWN_FINISHED(client, say_slowmode))
|
|
to_chat(src, span_warning("Message not sent due to slowmode. Please wait [SSlag_switch.slowmode_cooldown/10] seconds between messages.\n\"[message]\""))
|
|
return
|
|
COOLDOWN_START(client, say_slowmode, SSlag_switch.slowmode_cooldown)
|
|
|
|
if(src.client.handle_spam_prevention(message,MUTE_DEADCHAT))
|
|
return
|
|
|
|
var/mob/dead/observer/O = src
|
|
if(isobserver(src) && O.deadchat_name)
|
|
name = "[O.deadchat_name]"
|
|
else
|
|
if(mind?.name)
|
|
name = "[mind.name]"
|
|
else
|
|
name = real_name
|
|
if(name != real_name)
|
|
alt_name = " (died as [real_name])"
|
|
|
|
var/spanned = say_quote(message)
|
|
var/source = "<span class='game'><span class='prefix'>DEAD:</span> <span class='name'>[name]</span>[alt_name]"
|
|
var/rendered = " <span class='message'>[emoji_parse(spanned)]</span></span>"
|
|
log_talk(message, LOG_SAY, tag="DEAD")
|
|
if(SEND_SIGNAL(src, COMSIG_MOB_DEADSAY, message) & MOB_DEADSAY_SIGNAL_INTERCEPT)
|
|
return
|
|
var/displayed_key = key
|
|
if(client?.holder?.fakekey)
|
|
displayed_key = null
|
|
deadchat_broadcast(rendered, source, follow_target = src, speaker_key = displayed_key)
|
|
|
|
///Check if this message is an emote
|
|
/mob/proc/check_emote(message, forced)
|
|
if(message[1] == "*")
|
|
emote(copytext(message, length(message[1]) + 1), intentional = !forced)
|
|
return TRUE
|
|
|
|
///Check if the mob has a hivemind channel
|
|
/mob/proc/hivecheck()
|
|
return FALSE
|
|
|
|
///The amount of items we are looking for in the message
|
|
#define MESSAGE_MODS_LENGTH 6
|
|
/**
|
|
* Extracts and cleans message of any extenstions at the begining of the message
|
|
* Inserts the info into the passed list, returns the cleaned message
|
|
*
|
|
* Result can be
|
|
* * SAY_MODE (Things like aliens, channels that aren't channels)
|
|
* * MODE_WHISPER (Quiet speech)
|
|
* * MODE_SING (Singing)
|
|
* * MODE_HEADSET (Common radio channel)
|
|
* * RADIO_EXTENSION the extension we're using (lots of values here)
|
|
* * RADIO_KEY the radio key we're using, to make some things easier later (lots of values here)
|
|
* * LANGUAGE_EXTENSION the language we're trying to use (lots of values here)
|
|
*/
|
|
/mob/proc/get_message_mods(message, list/mods)
|
|
for(var/I in 1 to MESSAGE_MODS_LENGTH)
|
|
// Prevents "...text" from being read as a radio message
|
|
if (length(message) > 1 && message[2] == message[1])
|
|
continue
|
|
|
|
var/key = message[1]
|
|
var/chop_to = 2 //By default we just take off the first char
|
|
if(key == "#" && !mods[WHISPER_MODE])
|
|
mods[WHISPER_MODE] = MODE_WHISPER
|
|
else if(key == "%" && !mods[MODE_SING])
|
|
mods[MODE_SING] = TRUE
|
|
else if(key == ";" && !mods[MODE_HEADSET])
|
|
if(stat == CONSCIOUS) //necessary indentation so it gets stripped of the semicolon anyway.
|
|
mods[MODE_HEADSET] = TRUE
|
|
else if((key in GLOB.department_radio_prefixes) && length(message) > length(key) + 1 && !mods[RADIO_EXTENSION])
|
|
mods[RADIO_KEY] = lowertext(message[1 + length(key)])
|
|
mods[RADIO_EXTENSION] = GLOB.department_radio_keys[mods[RADIO_KEY]]
|
|
chop_to = length(key) + 2
|
|
else if(key == "," && !mods[LANGUAGE_EXTENSION])
|
|
for(var/ld in GLOB.all_languages)
|
|
var/datum/language/LD = ld
|
|
if(initial(LD.key) == message[1 + length(message[1])])
|
|
// No, you cannot speak in xenocommon just because you know the key
|
|
if(!can_speak_language(LD))
|
|
return message
|
|
mods[LANGUAGE_EXTENSION] = LD
|
|
chop_to = length(key) + length(initial(LD.key)) + 1
|
|
if(!mods[LANGUAGE_EXTENSION])
|
|
return message
|
|
else
|
|
return message
|
|
message = trim_left(copytext_char(message, chop_to))
|
|
if(!message)
|
|
return
|
|
return message
|