mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 05:57:24 +01:00
Merge pull request #5520 from Crazylemon64/descriptive_tochat_runtimes
The message for to_chat runtimes is more descriptive now
This commit is contained in:
@@ -201,20 +201,42 @@ var/list/chatResources = list(
|
||||
|
||||
return "<img [class] src='data:image/png;base64,[bicon_cache[key]]'>"
|
||||
|
||||
/proc/is_valid_tochat_message(message)
|
||||
return istext(message)
|
||||
|
||||
/proc/is_valid_tochat_target(target)
|
||||
return !istype(target, /savefile) && (ismob(target) || islist(target) || isclient(target) || target == world)
|
||||
|
||||
var/to_chat_filename
|
||||
var/to_chat_line
|
||||
var/to_chat_src
|
||||
// Call using macro: to_chat(target, message)
|
||||
/proc/__to_chat(target, message)
|
||||
if(istype(message, /image) || istype(message, /sound) || istype(target, /savefile) || !(ismob(target) || islist(target) || isclient(target) || target == world))
|
||||
if(!is_valid_tochat_message(message) || !is_valid_tochat_target(target))
|
||||
target << message
|
||||
if(!istext(message))
|
||||
message = "(non-text type)"
|
||||
world.Error(new/exception("DEBUG: to_chat called with invalid message: [message]", to_chat_filename, to_chat_line), e_src = to_chat_src)
|
||||
|
||||
// Info about the "message"
|
||||
if(isnull(message))
|
||||
message = "(null)"
|
||||
else if(istype(target, /datum))
|
||||
var/datum/D = target
|
||||
message = "([D.type]): '[D]'"
|
||||
else if(!is_valid_tochat_message(message))
|
||||
message = "(bad message) : '[message]'"
|
||||
|
||||
// Info about the target
|
||||
var/targetstring = "'[target]'"
|
||||
if(istype(target, /datum))
|
||||
var/datum/D = target
|
||||
targetstring += ", [D.type]"
|
||||
|
||||
// The final output
|
||||
log_runtime(new/exception("DEBUG: to_chat called with invalid message/target.", to_chat_filename, to_chat_line), to_chat_src, list("Message: '[message]'", "Target: [targetstring]"))
|
||||
return
|
||||
|
||||
else if(istext(message))
|
||||
else if(is_valid_tochat_message(message))
|
||||
if(istext(target))
|
||||
log_runtime(EXCEPTION("Somehow, to_chat got a text as a target"))
|
||||
return
|
||||
|
||||
message = replacetext(message, "\n", "<br>")
|
||||
@@ -241,4 +263,4 @@ var/to_chat_src
|
||||
return
|
||||
|
||||
|
||||
target << output(url_encode(message), "browseroutput:output")
|
||||
target << output(url_encode(message), "browseroutput:output")
|
||||
|
||||
Reference in New Issue
Block a user