mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-13 19:22:20 +00:00
* Adds a Chat Reliability Layer (#79479) ## About The Pull Request Everyone knows that chat will just eat your messages now and then, isn't that annoying? What if SSchat was smart enough to keep track of your messages and notice when you didn't get one? Well, now it can! ## Why It's Good For The Game Chat messages poofing into the aether is bad, really bad. ## Changelog 🆑 add: Chat Reliability Layer code: TGUI chat messages now track their sequence and will be resent if the client notices a discrepenency /🆑 --------- Co-authored-by: Kyle Spier-Swenson <kyleshome@ gmail.com> * Adds a Chat Reliability Layer --------- Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com> Co-authored-by: Kyle Spier-Swenson <kyleshome@ gmail.com>
85 lines
2.1 KiB
Plaintext
85 lines
2.1 KiB
Plaintext
/*!
|
|
* Copyright (c) 2020 Aleksej Komarov
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
/**
|
|
* Circumvents the message queue and sends the message
|
|
* to the recipient (target) as soon as possible.
|
|
*/
|
|
/proc/to_chat_immediate(
|
|
target,
|
|
html,
|
|
type = null,
|
|
text = null,
|
|
avoid_highlighting = FALSE,
|
|
// FIXME: These flags are now pointless and have no effect
|
|
handle_whitespace = TRUE,
|
|
trailing_newline = TRUE,
|
|
confidential = FALSE
|
|
)
|
|
// Useful where the integer 0 is the entire message. Use case is enabling to_chat(target, some_boolean) while preventing to_chat(target, "")
|
|
html = "[html]"
|
|
text = "[text]"
|
|
|
|
if(!target)
|
|
return
|
|
if(!html && !text)
|
|
CRASH("Empty or null string in to_chat proc call.")
|
|
if(target == world)
|
|
target = GLOB.clients
|
|
|
|
// Build a message
|
|
var/message = list()
|
|
if(type) message["type"] = type
|
|
if(text) message["text"] = text
|
|
if(html) message["html"] = html
|
|
if(avoid_highlighting) message["avoidHighlighting"] = avoid_highlighting
|
|
|
|
// send it immediately
|
|
SSchat.send_immediate(target, message)
|
|
|
|
/**
|
|
* Sends the message to the recipient (target).
|
|
*
|
|
* Recommended way to write to_chat calls:
|
|
* ```
|
|
* to_chat(client,
|
|
* type = MESSAGE_TYPE_INFO,
|
|
* html = "You have found <strong>[object]</strong>")
|
|
* ```
|
|
*/
|
|
/proc/to_chat(
|
|
target,
|
|
html,
|
|
type = null,
|
|
text = null,
|
|
avoid_highlighting = FALSE,
|
|
// FIXME: These flags are now pointless and have no effect
|
|
handle_whitespace = TRUE,
|
|
trailing_newline = TRUE,
|
|
confidential = FALSE
|
|
)
|
|
if(isnull(Master) || !SSchat?.initialized || !MC_RUNNING(SSchat.init_stage))
|
|
to_chat_immediate(target, html, type, text, avoid_highlighting)
|
|
return
|
|
|
|
// Useful where the integer 0 is the entire message. Use case is enabling to_chat(target, some_boolean) while preventing to_chat(target, "")
|
|
html = "[html]"
|
|
text = "[text]"
|
|
|
|
if(!target)
|
|
return
|
|
if(!html && !text)
|
|
CRASH("Empty or null string in to_chat proc call.")
|
|
if(target == world)
|
|
target = GLOB.clients
|
|
|
|
// Build a message
|
|
var/message = list()
|
|
if(type) message["type"] = type
|
|
if(text) message["text"] = text
|
|
if(html) message["html"] = html
|
|
if(avoid_highlighting) message["avoidHighlighting"] = avoid_highlighting
|
|
SSchat.queue(target, message)
|