From 0a137d2584e7a93907f42da6d00fa113d4cb56ea Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Tue, 4 Aug 2020 20:52:35 -0700
Subject: [PATCH 1/3] whew
---
code/__HELPERS/text.dm | 18 +++++++++++++++++-
code/modules/mob/living/emote.dm | 2 +-
code/modules/mob/say_vr.dm | 4 ++--
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm
index 9c71cfeb69..41b24b4780 100644
--- a/code/__HELPERS/text.dm
+++ b/code/__HELPERS/text.dm
@@ -113,6 +113,22 @@
else
return trim(html_encode(name), max_length)
+/**
+ * stripped_multiline_input but reflects to the user instead if it's too big and returns null.
+ */
+/proc/stripped_multiline_input_or_reflect(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
+ var/name = input(user, message, title, default) as message|null
+ if(isnull(name)) // Return null if canceled.
+ return null
+ if(length(name) > max_length)
+ to_chat(user, name)
+ to_chat(user, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [max_length*2] bytes. It has NOT been sent! -----^^^")
+ return null
+ if(no_trim)
+ return copytext(html_encode(name), 1, max_length)
+ else
+ return trim(html_encode(name), max_length)
+
#define NO_CHARS_DETECTED 0
#define SPACES_DETECTED 1
#define SYMBOLS_DETECTED 2
@@ -811,4 +827,4 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
corrupted_text += pick(corruption_options)
if(prob(15))
corrupted_text += pick(corruption_options)
- return corrupted_text
\ No newline at end of file
+ return corrupted_text
diff --git a/code/modules/mob/living/emote.dm b/code/modules/mob/living/emote.dm
index a5de3a2fdc..d11ad4474a 100644
--- a/code/modules/mob/living/emote.dm
+++ b/code/modules/mob/living/emote.dm
@@ -441,7 +441,7 @@
to_chat(user, "You cannot send IC messages (muted).")
return FALSE
else if(!params)
- var/custom_emote = stripped_multiline_input(user, "Choose an emote to display.", "Custom Emote", null, MAX_MESSAGE_LEN)
+ var/custom_emote = stripped_multiline_input_or_reflect(user, "Choose an emote to display.", "Custom Emote", null, MAX_MESSAGE_LEN)
if(custom_emote && !check_invalid(user, custom_emote))
var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable")
switch(type)
diff --git a/code/modules/mob/say_vr.dm b/code/modules/mob/say_vr.dm
index 5ed24af726..5db3ccf216 100644
--- a/code/modules/mob/say_vr.dm
+++ b/code/modules/mob/say_vr.dm
@@ -37,7 +37,7 @@ proc/get_top_level_mob(var/mob/S)
to_chat(user, "You cannot send IC messages (muted).")
return FALSE
else if(!params)
- var/subtle_emote = stripped_multiline_input(user, "Choose an emote to display.", "Subtle", null, MAX_MESSAGE_LEN)
+ var/subtle_emote = stripped_multiline_input_or_reflect(user, "Choose an emote to display.", "Subtle", null, MAX_MESSAGE_LEN)
if(subtle_emote && !check_invalid(user, subtle_emote))
var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable")
switch(type)
@@ -98,7 +98,7 @@ proc/get_top_level_mob(var/mob/S)
to_chat(user, "You cannot send IC messages (muted).")
return FALSE
else if(!params)
- var/subtle_emote = stripped_multiline_input(user, "Choose an emote to display.", "Subtler" , null, MAX_MESSAGE_LEN)
+ var/subtle_emote = stripped_multiline_input_or_reflect(user, "Choose an emote to display.", "Subtler" , null, MAX_MESSAGE_LEN)
if(subtle_emote && !check_invalid(user, subtle_emote))
var/type = input("Is this a visible or hearable emote?") as null|anything in list("Visible", "Hearable")
switch(type)
From d79cc5f85dff714e577c6ca1982f477fd2058f77 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Tue, 4 Aug 2020 20:57:37 -0700
Subject: [PATCH 2/3] oof
---
code/modules/mob/say.dm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm
index 3ceafe4a11..c7bf88f63b 100644
--- a/code/modules/mob/say.dm
+++ b/code/modules/mob/say.dm
@@ -43,6 +43,11 @@
if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "Speech is currently admin-disabled.")
return
+
+ if(length(message) > MAX_MESSAGE_LEN)
+ to_chat(user, message)
+ to_chat(user, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [max_length*2] bytes. It has NOT been sent! -----^^^")
+ return
message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
clear_typing_indicator() // clear it immediately!
From c0ac492d07ef8cc40ea0e3aa9ddbf24b549326cb Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Tue, 4 Aug 2020 21:01:06 -0700
Subject: [PATCH 3/3] ok
---
code/__HELPERS/text.dm | 2 +-
code/modules/mob/say.dm | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm
index 41b24b4780..6dfb685331 100644
--- a/code/__HELPERS/text.dm
+++ b/code/__HELPERS/text.dm
@@ -122,7 +122,7 @@
return null
if(length(name) > max_length)
to_chat(user, name)
- to_chat(user, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [max_length*2] bytes. It has NOT been sent! -----^^^")
+ to_chat(user, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [max_length]. It has NOT been sent! -----^^^")
return null
if(no_trim)
return copytext(html_encode(name), 1, max_length)
diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm
index c7bf88f63b..7d97270808 100644
--- a/code/modules/mob/say.dm
+++ b/code/modules/mob/say.dm
@@ -45,8 +45,8 @@
return
if(length(message) > MAX_MESSAGE_LEN)
- to_chat(user, message)
- to_chat(user, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [max_length*2] bytes. It has NOT been sent! -----^^^")
+ to_chat(usr, message)
+ to_chat(usr, "^^^----- The preceeding message has been DISCARDED for being over the maximum length of [MAX_MESSAGE_LEN]. It has NOT been sent! -----^^^")
return
message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))