mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-23 05:07:51 +01:00
[MIRROR] reimplements attack and player logs (#12553)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
co-authored by
Kashargul
parent
bb90e792ca
commit
99afe463dc
@@ -29,11 +29,11 @@
|
||||
var/postfix = "[sobject][saddition][hp]"
|
||||
|
||||
var/message = "[what_done] [starget][postfix]"
|
||||
user.log_message(message, LOG_ATTACK, color="red")
|
||||
user.log_message(message, LOG_ATTACK, color="#ff0000")
|
||||
|
||||
if(user != target)
|
||||
var/reverse_message = "was [what_done] by [ssource][postfix]"
|
||||
target.log_message(reverse_message, LOG_VICTIM, color="orange", log_globally=FALSE)
|
||||
target.log_message(reverse_message, LOG_VICTIM, color="#ffb300", log_globally=FALSE)
|
||||
|
||||
/// Log for vore interactions
|
||||
/proc/log_vore(text, list/data)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/proc/db_log_insert(mob/log_target, message, type, color)
|
||||
set waitfor = FALSE
|
||||
if(!ismob(log_target))
|
||||
return
|
||||
if(!SSdbcore.IsConnected())
|
||||
return
|
||||
var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_dialog (mid, time, ckey, mob, area, type, color, message) VALUES (null, NOW(), :sender_ckey, :sender_mob, :message_area, :message_type, :message_color, :message_content)",
|
||||
list("sender_ckey" = log_target.ckey, "sender_mob" = log_target.real_name, "message_area" = "[loc_name(log_target)]", "message_type" = "[type]", "message_color" = color, "message_content" = message))
|
||||
if(!query_insert.Execute())
|
||||
log_sql("Error during logging: "+query_insert.ErrorMsg())
|
||||
qdel(query_insert)
|
||||
return
|
||||
qdel(query_insert)
|
||||
@@ -13,42 +13,30 @@
|
||||
return
|
||||
|
||||
// Cannot use the list as a map if the key is a number, so we stringify it (thank you BYOND)
|
||||
var/smessage_type = num2text(message_type, MAX_BITFLAG_DIGITS)
|
||||
|
||||
if(HAS_CONNECTED_PLAYER(src))
|
||||
if(!islist(persistent_client.logging[smessage_type]))
|
||||
persistent_client.logging[smessage_type] = list()
|
||||
|
||||
if(!islist(logging[smessage_type]))
|
||||
logging[smessage_type] = list()
|
||||
|
||||
var/colored_message = message
|
||||
if(color)
|
||||
if(color[1] == "#")
|
||||
colored_message = "<font color=[color]>[message]</font>"
|
||||
else
|
||||
colored_message = "<font color='[color]'>[message]</font>"
|
||||
var/smessage_type = GLOB.logtype_to_string[message_type]
|
||||
|
||||
//This makes readability a bit better for admins.
|
||||
switch(message_type)
|
||||
if(LOG_WHISPER)
|
||||
colored_message = "(WHISPER) [colored_message]"
|
||||
if(LOG_OOC)
|
||||
colored_message = "(OOC) [colored_message]"
|
||||
if(LOG_LOOC)
|
||||
colored_message = "(LOOC) [colored_message]"
|
||||
if(LOG_ASAY)
|
||||
colored_message = "(ASAY) [colored_message]"
|
||||
if(LOG_EMOTE)
|
||||
colored_message = "(EMOTE) [colored_message]"
|
||||
if(LOG_RADIO_EMOTE)
|
||||
colored_message = "(RADIOEMOTE) [colored_message]"
|
||||
var/list/timestamped_message = list(
|
||||
"time" = world.timeofday,
|
||||
"name" = name,
|
||||
"ckey" = ckey,
|
||||
"loc" = loc_name(src),
|
||||
"event_id" = LAZYLEN(logging[smessage_type]),
|
||||
"message" = message,
|
||||
"color" = color
|
||||
)
|
||||
|
||||
var/list/timestamped_message = list("\[[time_stamp(format = "YYYY-MM-DD hh:mm:ss")]\] [key_name_and_tag(src)] [loc_name(src)] (Event #[LAZYLEN(logging[smessage_type])])" = colored_message)
|
||||
|
||||
logging[smessage_type] += timestamped_message
|
||||
if(!CONFIG_GET(flag/database_logging))
|
||||
if(!islist(logging[smessage_type]))
|
||||
logging[smessage_type] = list()
|
||||
UNTYPED_LIST_ADD(logging[smessage_type], timestamped_message)
|
||||
|
||||
if(HAS_CONNECTED_PLAYER(src))
|
||||
persistent_client.logging[smessage_type] += timestamped_message
|
||||
if(CONFIG_GET(flag/database_logging))
|
||||
db_log_insert(src, message, smessage_type, color)
|
||||
else
|
||||
if(!islist(persistent_client.logging[smessage_type]))
|
||||
persistent_client.logging[smessage_type] = list()
|
||||
UNTYPED_LIST_ADD(persistent_client.logging[smessage_type], timestamped_message)
|
||||
|
||||
..()
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
* * log_globally - boolean checking whether or not we write this log to the log file
|
||||
* * forced_by - source that forced the dialogue if any
|
||||
*/
|
||||
/atom/proc/log_talk(message, message_type, tag = null, log_globally = TRUE, forced_by = null, custom_say_emote = null)
|
||||
/atom/proc/log_talk(message, message_type, tag = null, log_globally = TRUE, forced_by = null, custom_say_emote = null, color)
|
||||
var/prefix = tag ? "([tag]) " : ""
|
||||
var/suffix = forced_by ? " FORCED by [forced_by]" : ""
|
||||
log_message("[prefix][custom_say_emote ? "*[custom_say_emote]*, " : ""]\"[message]\"[suffix]", message_type, log_globally = log_globally)
|
||||
log_message("[prefix][custom_say_emote ? "*[custom_say_emote]*, " : ""]\"[message]\"[suffix]", message_type, color, log_globally)
|
||||
|
||||
/// Logging for generic spoken messages
|
||||
/proc/log_say(text, list/data)
|
||||
|
||||
@@ -151,13 +151,8 @@ Proc for attack log creation, because really why not
|
||||
add_attack_logs(user,M,what_done,admin_notify)
|
||||
return
|
||||
|
||||
var/user_str = key_name(user)
|
||||
var/target_str = key_name(target)
|
||||
|
||||
if(ismob(user))
|
||||
user.attack_log += text("\[[time_stamp()]\] [span_red("Attacked [target_str]: [what_done]")]")
|
||||
if(ismob(target))
|
||||
target.attack_log += text("\[[time_stamp()]\] [span_orange("Attacked by [user_str]: [what_done]")]")
|
||||
log_combat(user, target, what_done)
|
||||
if(admin_notify)
|
||||
msg_admin_attack("[key_name_admin(user)] vs [target_str]: [what_done]")
|
||||
|
||||
Reference in New Issue
Block a user