Merge pull request #3709 from VOREStation/aro-sayreflect

Message send failure reflection
This commit is contained in:
Leshana
2018-05-16 20:46:19 -04:00
committed by GitHub
5 changed files with 36 additions and 8 deletions

View File

@@ -104,7 +104,7 @@
#define WAIT_FINISH 4
// Setting this much higher than 1024 could allow spammers to DOS the server easily.
#define MAX_MESSAGE_LEN 1024
#define MAX_MESSAGE_LEN 2048 //VOREStation Edit - I'm not sure about "easily". It can be a little longer.
#define MAX_PAPER_MESSAGE_LEN 6144
#define MAX_BOOK_MESSAGE_LEN 24576
#define MAX_RECORD_LENGTH 24576

View File

@@ -11,7 +11,7 @@
var/input
if(!message)
input = sanitize(input(src,"Choose an emote to display.") as text|null)
input = sanitize_or_reflect(input(src,"Choose an emote to display.") as text|null, src) //VOREStation Edit - Reflect too long messages, within reason
else
input = message
if(input)
@@ -70,7 +70,7 @@
var/input
if(!message)
input = sanitize(input(src, "Choose an emote to display.") as text|null)
input = sanitize_or_reflect(input(src, "Choose an emote to display.") as text|null, src) //VOREStation Edit - Reflect too long messages, within reason
else
input = message

View File

@@ -3,7 +3,7 @@
if(name != GetVoice())
alt_name = "(as [get_id_name("Unknown")])"
message = sanitize(message)
message = sanitize_or_reflect(message,src) //VOREStation Edit - Reflect too-long messages, within reason
..(message, alt_name = alt_name, whispering = whispering)
/mob/living/carbon/human/proc/forcesay(list/append)

View File

@@ -22,7 +22,7 @@
usr << "<font color='red'>Speech is currently admin-disabled.</font>"
return
message = sanitize(message)
message = sanitize_or_reflect(message,src) //VOREStation Edit - Reflect too-long messages (within reason)
set_typing_indicator(FALSE)
if(use_me)

View File

@@ -11,7 +11,7 @@
usr << "Speech is currently admin-disabled."
return
message = sanitize(message)
message = sanitize_or_reflect(message,src) //VOREStation Edit - Reflect too-long messages (within reason)
if(!message)
return
@@ -31,7 +31,7 @@
var/input
if(!message)
input = sanitize(input(src,"Choose an emote to display.") as text|null)
input = sanitize_or_reflect(input(src,"Choose an emote to display.") as text|null, src)
else
input = message
@@ -61,3 +61,31 @@
/mob/proc/emote_vr(var/act, var/type, var/message) //This would normally go in say.dm
if(act == "me")
return custom_emote_vr(type, message)
#define MAX_HUGE_MESSAGE_LEN 8192
#define POST_DELIMITER_STR "\<\>"
/proc/sanitize_or_reflect(message,user)
//Way too long to send
if(length(message) > MAX_HUGE_MESSAGE_LEN)
fail_to_chat(user)
return
message = sanitize(message, max_length = MAX_HUGE_MESSAGE_LEN)
//Came back still too long to send
if(length(message) > MAX_MESSAGE_LEN)
fail_to_chat(user,message)
return null
else
return message
/proc/fail_to_chat(user,message)
if(!message)
to_chat(user,"<span class='danger'>Your message was NOT SENT, either because it was FAR too long, or sanitized to nothing at all.</span>")
return
var/length = length(message)
var/posts = Ceiling(length/MAX_MESSAGE_LEN)
to_chat(user,message)
to_chat(user,"<span class='danger'>^ This message was NOT SENT ^ -- It was [length] characters, and the limit is [MAX_MESSAGE_LEN]. It would fit in [posts] separate messages.</span>")
#undef MAX_HUGE_MESSAGE_LEN