You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.2 KiB

  1. SUBSYSTEM_DEF(chat)
  2. name = "Chat"
  3. flags = SS_TICKER
  4. wait = 1
  5. priority = FIRE_PRIORITY_CHAT
  6. init_order = INIT_ORDER_CHAT
  7. var/list/payload = list()
  8. /datum/controller/subsystem/chat/fire()
  9. for(var/i in payload)
  10. var/client/C = i
  11. C << output(payload[C], "browseroutput:output")
  12. payload -= C
  13. if(MC_TICK_CHECK)
  14. return
  15. /datum/controller/subsystem/chat/proc/queue(target, message, handle_whitespace = TRUE, trailing_newline = TRUE, confidential = TRUE)
  16. if(!target || !message)
  17. return
  18. if(!istext(message))
  19. stack_trace("to_chat called with invalid input type")
  20. return
  21. if(target == world)
  22. target = GLOB.clients
  23. //Some macros remain in the string even after parsing and fuck up the eventual output
  24. var/original_message = message
  25. message = replacetext(message, "\improper", "")
  26. message = replacetext(message, "\proper", "")
  27. if(handle_whitespace)
  28. message = replacetext(message, "\n", "<br>")
  29. message = replacetext(message, "\t", "[FOURSPACES][FOURSPACES]")
  30. if (trailing_newline)
  31. message += "<br>"
  32. if(!confidential)
  33. SSdemo.write_chat(target, message)
  34. //url_encode it TWICE, this way any UTF-8 characters are able to be decoded by the Javascript.
  35. //Do the double-encoding here to save nanoseconds
  36. var/twiceEncoded = url_encode(url_encode(message))
  37. if(islist(target))
  38. for(var/I in target)
  39. var/client/C = CLIENT_FROM_VAR(I) //Grab us a client if possible
  40. if(!C)
  41. return
  42. //Send it to the old style output window.
  43. SEND_TEXT(C, original_message)
  44. if(!C?.chatOutput || C.chatOutput.broken) //A player who hasn't updated his skin file.
  45. continue
  46. if(!C.chatOutput.loaded) //Client still loading, put their messages in a queue
  47. C.chatOutput.messageQueue += message
  48. continue
  49. payload[C] += twiceEncoded
  50. else
  51. var/client/C = CLIENT_FROM_VAR(target) //Grab us a client if possible
  52. if(!C)
  53. return
  54. //Send it to the old style output window.
  55. SEND_TEXT(C, original_message)
  56. if(!C?.chatOutput || C.chatOutput.broken) //A player who hasn't updated his skin file.
  57. return
  58. if(!C.chatOutput.loaded) //Client still loading, put their messages in a queue
  59. C.chatOutput.messageQueue += message
  60. return
  61. payload[C] += twiceEncoded