Skip to content

Commit

Permalink
Patches up the jankiness of LOOC
Browse files Browse the repository at this point in the history
Fix admins viewing LOOC wrongly
  • Loading branch information
Bobbanz1 committed Sep 18, 2023
1 parent 480a23a commit 26c9a72
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 114 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/bans.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define BAN_OOC "OOC"
206 changes: 93 additions & 113 deletions code/modules/client/verbs/looc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,128 +3,108 @@
//GLOBAL_VAR_INIT(looc_allowed, 1) //commenting this out might break something but w/e, replaced by one in global config by nsv13

/client/verb/looc(msg as text)
set name = "LOOC"
set desc = "Local OOC, seen only by those in view."
set category = "OOC"

if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "<span class='danger'> Speech is currently admin-disabled.</span>")
return

if(!mob) return
if(!mob.ckey) return

msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN)
var/raw_msg = msg

if(!msg)
return

if(!(prefs.chat_toggles & CHAT_LOOC)) //nsv13 - toggles -> chat_toggles, CHAT_OOC -> CHAT_LOOC
to_chat(src, "<span class='danger'>You have LOOC muted.</span>")
return

if(is_banned_from(mob.ckey, "OOC"))
to_chat(src, "<span class='danger'>You have been banned from OOC and LOOC.</span>")
return

if(!holder)
if(!GLOB.looc_allowed) //nsv13 - ooc_allowed -> looc_allowed
to_chat(src, "<span class='danger'>LOOC is globally muted.</span>")
return
if(!GLOB.dooc_allowed && (mob.stat == DEAD))
to_chat(usr, "<span class='danger'>LOOC for dead mobs has been turned off.</span>")
return
if(prefs.muted & MUTE_LOOC) //nsv13 - MUTE_OOC -> MUTE_LOOC
to_chat(src, "<span class='danger'>You cannot use LOOC (muted).</span>")
return
if(handle_spam_prevention(msg,MUTE_LOOC)) //nsv13 - MUTE_OOC -> MUTE_LOOC
return
if(findtext(msg, "byond://"))
to_chat(src, "<B>Advertising other servers is not allowed.</B>")
log_admin("[key_name(src)] has attempted to advertise in LOOC: [msg]")
return
if(mob.stat)
to_chat(src, "<span class='danger'>You cannot salt in LOOC while unconscious or dead.</span>")
return
if(istype(mob, /mob/dead))
to_chat(src, "<span class='danger'>You cannot use LOOC while ghosting.</span>")
return

if(OOC_FILTER_CHECK(raw_msg))
to_chat(src, "<span class='warning'>That message contained a word prohibited in OOC chat! Consider reviewing the server rules.\n<span replaceRegex='show_filtered_ooc_chat'>\"[raw_msg]\"</span></span>")
return

msg = emoji_parse(msg)

mob.log_talk(raw_msg, LOG_OOC, tag="LOOC")

var/list/heard = hearers(7, get_top_level_mob(src.mob))

set name = "LOOC"
set desc = "Local OOC, seen only by those in view."
set category = "OOC"

if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "<span class='danger'> Speech is currently admin-disabled.</span>")
return

if(!mob?.ckey)
return

msg = trim(sanitize(msg), MAX_MESSAGE_LEN)
if(!length(msg))
return

var/raw_msg = msg

if(!(prefs.chat_toggles & CHAT_LOOC)) //nsv13 - toggles -> chat_toggles, CHAT_OOC -> CHAT_LOOC
to_chat(src, "<span class='danger'>You have LOOC muted.</span>")
return

if(is_banned_from(mob.ckey, BAN_OOC))
to_chat(src, "<span class='danger'>You have been banned from OOC and LOOC.</span>")
return

if(!holder)
if(!GLOB.looc_allowed) //nsv13 - ooc_allowed -> looc_allowed
to_chat(src, "<span class='danger'>LOOC is globally muted.</span>")
return
if(!GLOB.dooc_allowed && (mob.stat == DEAD))
to_chat(usr, "<span class='danger'>LOOC for dead mobs has been turned off.</span>")
return
if(prefs.muted & MUTE_LOOC) //nsv13 - MUTE_OOC -> MUTE_LOOC
to_chat(src, "<span class='danger'>You cannot use LOOC (muted).</span>")
return
if(handle_spam_prevention(msg, MUTE_LOOC)) //nsv13 - MUTE_OOC -> MUTE_LOOC
return
if(findtext(msg, "byond://"))
to_chat(src, "<span class='bold danger'>Advertising other servers is not allowed.</span>")
log_admin("[key_name(src)] has attempted to advertise in LOOC: [msg]")
return
if(mob.stat)
to_chat(src, "<span class='danger'>You cannot salt in LOOC while unconscious or dead.</span>")
return
if(isdead(mob))
to_chat(src, "<span class='danger'>You cannot use LOOC while ghosting.</span>")
return

if(OOC_FILTER_CHECK(raw_msg))
to_chat(src, "<span class='warning'>That message contained a word prohibited in OOC chat! Consider reviewing the server rules.\n<span replaceRegex='show_filtered_ooc_chat'>\"[raw_msg]\"</span></span>")
return

msg = emoji_parse(msg)

mob.log_talk(raw_msg, LOG_OOC, tag="LOOC")

// Search everything in the view for anything that might be a mob, or contain a mob.
var/list/client/targets = list()
var/list/turf/in_view = list()
//NSV13 - AI QoL - Start
//so the ai can post looc text
if(istype(mob, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = mob
heard = hearers(7, get_top_level_mob(ai.eyeobj))
//so the ai can see looc text
for(var/mob/living/silicon/ai/ai as anything in GLOB.ai_list)
if(ai.client && !(ai in heard) && (ai.eyeobj in heard))
heard += ai
if(istype(mob, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = mob
for(var/turf/viewed_turf in view(get_turf(ai.eyeobj)))
in_view[viewed_turf] = TRUE
else
for(var/turf/viewed_turf in view(get_turf(mob)))
in_view[viewed_turf] = TRUE
//NSV13 - AI QoL - Stop

for(var/mob/M as() in heard)
if(!M.client)
continue
var/client/C = M.client
if (C in GLOB.admins)
continue //they are handled after that

if (isobserver(M))
continue //Also handled later.

if(C.prefs.chat_toggles & CHAT_LOOC) //nsv13 - toggles -> chat_toggles, CHAT_OOC -> CHAT_LOOC
// var/display_name = src.key
// if(holder)
// if(holder.fakekey)
// if(C.holder)
// display_name = "[holder.fakekey]/([src.key])"
// else
// display_name = holder.fakekey
to_chat(C,"<span class='looc'><span class='prefix'>LOOC:</span> <EM>[src.mob.name]:</EM> <span class='message'>[msg]</span></span>")

for(var/client/C in GLOB.admins)
if(C.prefs.chat_toggles & CHAT_LOOC) //nsv13 - toggles -> chat_toggles, CHAT_OOC -> CHAT_LOOC
var/prefix = "(R)LOOC"
if (C.mob in heard)
prefix = "LOOC"
to_chat(C,"<span class='looc'>[ADMIN_FLW(usr)]<span class='prefix'>[prefix]:</span> <EM>[src.key]/[src.mob.name]:</EM> <span class='message'>[msg]</span></span>")
for(var/client/client in GLOB.clients)
if(!client.mob || !(client.prefs.chat_toggles & CHAT_LOOC) || (client in GLOB.admins)) //nsv13 - toggles -> chat_toggles, CHAT_OOC -> CHAT_LOOC
continue
//NSV13 - LOOC AI Stuff - Start
if(istype(client.mob, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = client.mob
if(in_view[get_turf(ai.eyeobj)])
targets |= client
to_chat(client, "<span class='looc'><span class='prefix'>LOOC:</span> <EM><span class='name'>[mob.name]</span>:</EM> <span class='message'>[msg]</span></span>", avoid_highlighting = (client == src))
else if(in_view[get_turf(client.mob)]) //NSV13 - LOOC AI Stuff - Stop
targets |= client
to_chat(client, "<span class='looc'><span class='prefix'>LOOC:</span> <EM><span class='name'>[mob.name]</span>:</EM> <span class='message'>[msg]</span></span>", avoid_highlighting = (client == src))

for(var/client/client in GLOB.admins)
if(!(client.prefs.chat_toggles & CHAT_LOOC)) //nsv13 - toggles -> chat_toggles, CHAT_OOC -> CHAT_LOOC
continue
var/prefix = "[(client in targets) ? "" : "(R)"]LOOC"
to_chat(client, "<span class='looc'><span class='prefix'>[prefix]:</span> <EM>[ADMIN_LOOKUPFLW(mob)]:</EM> <span class='message'>[msg]</span></span>", avoid_highlighting = (client == src))

/proc/toggle_looc(toggle = null) //nsv13 - adds a toggle for looc
if(toggle != null) //if we're specifically en/disabling looc
if(toggle != GLOB.looc_allowed)
GLOB.looc_allowed = toggle
else
return
else //otherwise just toggle it
GLOB.looc_allowed = !GLOB.looc_allowed
if(toggle != null) //if we're specifically en/disabling looc
if(toggle != GLOB.looc_allowed)
GLOB.looc_allowed = toggle
else
return
else //otherwise just toggle it
GLOB.looc_allowed = !GLOB.looc_allowed

/proc/log_looc(text)
if (CONFIG_GET(flag/log_ooc))
WRITE_FILE(GLOB.world_game_log, "\[[time_stamp()]]LOOC: [text]")
if (CONFIG_GET(flag/log_ooc))
WRITE_FILE(GLOB.world_game_log, "\[[time_stamp()]]LOOC: [text]")

////////////////////FLAVOUR TEXT NSV13////////////////////
/mob
var/flavour_text = ""
//NSV13 - flavour text - Don't think this thing actually does anything - END

/mob/proc/get_top_level_mob()
if(istype(src.loc,/mob)&&src.loc!=src)
var/mob/M=src.loc
return M.get_top_level_mob()
return src

/proc/get_top_level_mob(var/mob/S)
if(istype(S.loc,/mob)&&S.loc!=S)
var/mob/M=S.loc
return M.get_top_level_mob()
return S
2 changes: 1 addition & 1 deletion code/modules/client/verbs/ooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
if(prefs.muted & MUTE_OOC)
to_chat(src, "<span class='danger'>You cannot use OOC (muted).</span>")
return
if(is_banned_from(ckey, "OOC"))
if(is_banned_from(ckey, BAN_OOC))
to_chat(src, "<span class='danger'>You have been banned from OOC.</span>")
return
if(QDELETED(src))
Expand Down
1 change: 1 addition & 0 deletions nsv13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "code\__DEFINES\atmospherics.dm"
#include "code\__DEFINES\atom_hud.dm"
#include "code\__DEFINES\balloon_alert.dm"
#include "code\__DEFINES\bans.dm"
#include "code\__DEFINES\bitfields.dm"
#include "code\__DEFINES\bodyparts.dm"
#include "code\__DEFINES\bot_defines.dm"
Expand Down

0 comments on commit 26c9a72

Please sign in to comment.