mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-07-11 07:02:32 +01:00
297ac38eca
When a post is too long to send, reflect it back to the user in the chatbox so they can copypaste it into separate messages. Also increases the message limit from 1024 to 2048. If a message is longer than 5-messages worth, it is not reflected and a warning is sent instead to avoid easily consuming bandwidth for DDOS purposes with long messages. I'd like to add markers in the message where the posts would have been truncated but that's... complicated.
92 lines
2.6 KiB
Plaintext
92 lines
2.6 KiB
Plaintext
//////////////////////////////////////////////////////
|
|
////////////////////SUBTLE COMMAND////////////////////
|
|
//////////////////////////////////////////////////////
|
|
|
|
/mob/verb/me_verb_subtle(message as text) //This would normally go in say.dm
|
|
set name = "Subtle"
|
|
set category = "IC"
|
|
set desc = "Emote to nearby people (and your pred/prey)"
|
|
|
|
if(say_disabled) //This is here to try to identify lag problems
|
|
usr << "Speech is currently admin-disabled."
|
|
return
|
|
|
|
message = sanitize_or_reflect(message,src) //VOREStation Edit - Reflect too-long messages (within reason)
|
|
if(!message)
|
|
return
|
|
|
|
set_typing_indicator(FALSE)
|
|
if(use_me)
|
|
usr.emote_vr("me",4,message)
|
|
else
|
|
usr.emote_vr(message)
|
|
|
|
/mob/proc/custom_emote_vr(var/m_type=1,var/message = null) //This would normally go in emote.dm
|
|
if(stat || !use_me && usr == src)
|
|
src << "You are unable to emote."
|
|
return
|
|
|
|
var/muzzled = is_muzzled()
|
|
if(m_type == 2 && muzzled) return
|
|
|
|
var/input
|
|
if(!message)
|
|
input = sanitize_or_reflect(input(src,"Choose an emote to display.") as text|null, src)
|
|
else
|
|
input = message
|
|
|
|
if(input)
|
|
log_subtle(message,src)
|
|
message = "<B>[src]</B> <I>[input]</I>"
|
|
else
|
|
return
|
|
|
|
if (message)
|
|
message = say_emphasis(message)
|
|
|
|
var/list/vis = get_mobs_and_objs_in_view_fast(get_turf(src),1,2) //Turf, Range, and type 2 is emote
|
|
var/list/vis_mobs = vis["mobs"]
|
|
var/list/vis_objs = vis["objs"]
|
|
|
|
for(var/vismob in vis_mobs)
|
|
var/mob/M = vismob
|
|
spawn(0)
|
|
M.show_message(message, 2)
|
|
|
|
for(var/visobj in vis_objs)
|
|
var/obj/O = visobj
|
|
spawn(0)
|
|
O.see_emote(src, message, 2)
|
|
|
|
/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
|