From fbe612c483833a25098ae851bfcc5f2d3082ab6a Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 28 Jul 2023 08:12:02 +0100 Subject: [PATCH 1/2] notes have round ids --- code/datums/entities/player.dm | 1 + code/datums/entities/player_note.dm | 24 ++++++++++++++---------- code/game/verbs/records.dm | 4 ++-- code/modules/admin/admin.dm | 4 ++-- code/modules/admin/tabs/admin_tab.dm | 4 ++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/code/datums/entities/player.dm b/code/datums/entities/player.dm index 9b8f95938de6..ed97c4eafaae 100644 --- a/code/datums/entities/player.dm +++ b/code/datums/entities/player.dm @@ -105,6 +105,7 @@ BSQL_PROTECT_DATUM(/datum/entity/player) note.player_id = id note.text = note_text note.date = "[time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")]" + note.round_id = GLOB.round_id note.is_confidential = is_confidential note.note_category = note_category note.is_ban = is_ban diff --git a/code/datums/entities/player_note.dm b/code/datums/entities/player_note.dm index f6662a153113..9ee7cf7a34ba 100644 --- a/code/datums/entities/player_note.dm +++ b/code/datums/entities/player_note.dm @@ -3,6 +3,7 @@ var/admin_id var/text var/date + var/round_id = "N/A" var/is_ban = FALSE var/ban_time var/is_confidential = FALSE @@ -19,15 +20,16 @@ BSQL_PROTECT_DATUM(/datum/entity/player_note) entity_type = /datum/entity/player_note table_name = "player_notes" field_types = list( - "player_id"=DB_FIELDTYPE_BIGINT, - "admin_id"=DB_FIELDTYPE_BIGINT, - "text"=DB_FIELDTYPE_STRING_MAX, - "date"=DB_FIELDTYPE_STRING_LARGE, - "is_ban"=DB_FIELDTYPE_INT, - "ban_time"=DB_FIELDTYPE_BIGINT, - "is_confidential"=DB_FIELDTYPE_INT, - "admin_rank"=DB_FIELDTYPE_STRING_MEDIUM, - "note_category" =DB_FIELDTYPE_INT, + "player_id" = DB_FIELDTYPE_BIGINT, + "admin_id" = DB_FIELDTYPE_BIGINT, + "text" = DB_FIELDTYPE_STRING_MAX, + "date" = DB_FIELDTYPE_STRING_LARGE, + "round_id" = DB_FIELDTYPE_BIGINT, + "is_ban" = DB_FIELDTYPE_INT, + "ban_time" = DB_FIELDTYPE_BIGINT, + "is_confidential" = DB_FIELDTYPE_INT, + "admin_rank" = DB_FIELDTYPE_STRING_MEDIUM, + "note_category" = DB_FIELDTYPE_INT, ) /datum/entity_meta/player_note/on_read(datum/entity/player_note/note) @@ -64,6 +66,7 @@ BSQL_PROTECT_DATUM(/datum/entity/player_note) var/is_ban var/admin_ckey var/date + var/round_id var/ban_time var/is_confidential var/admin_rank @@ -79,6 +82,7 @@ BSQL_PROTECT_DATUM(/datum/entity/player_note) "is_ban", "admin_ckey" = "admin.ckey", "date", + "round_id", "ban_time", "is_confidential", "admin_rank", @@ -88,4 +92,4 @@ BSQL_PROTECT_DATUM(/datum/entity/player_note) /// Returns all notes associated with a CKEY, structured as a list of strings. /proc/get_all_notes(player_ckey) for(var/datum/view_record/note_view/note in DB_VIEW(/datum/view_record/note_view, DB_COMP("player_ckey", DB_EQUALS, player_ckey))) - LAZYADDASSOC(., "[note.note_category]", "\"[note.text]\", by [note.admin_ckey] ([note.admin_rank]) on [note.date]") + LAZYADDASSOC(., "[note.note_category]", "\"[note.text]\", by [note.admin_ckey] ([note.admin_rank]) on [note.date] ([note.round_id])") diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index 56a440e3558c..d783039f4fb1 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -53,7 +53,7 @@ if(NOTE_YAUTJA) color = "#114e11" - dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] " + dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] (ID: [N.round_id]) " dat += "

" dat += "
" @@ -168,7 +168,7 @@ continue var/admin_ckey = N.admin_ckey - dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] " + dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] (ID: [N.round_id]) " ///Can remove notes from anyone other than yourself, unless you're the host. So long as you have deletion access anyway. if((can_del && target != get_player_from_key(key)) || ishost(usr)) dat += "Remove" diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 5f24f71c8a50..32c2dffcd0f9 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -89,7 +89,7 @@ if(N.is_ban) var/time_d = N.ban_time ? "Banned for [N.ban_time] minutes | " : "" color = "#880000" //Removed confidential check because we can't make confidential bans - dat += "[time_d][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] " + dat += "[time_d][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " else if(N.is_confidential) color = "#AA0055" @@ -102,7 +102,7 @@ else if(N.note_category == NOTE_YAUTJA) color = "#114e11" - dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] " + dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " if(admin_ckey == usr.ckey || admin_ckey == "Adminbot" || ishost(usr)) dat += "Remove" diff --git a/code/modules/admin/tabs/admin_tab.dm b/code/modules/admin/tabs/admin_tab.dm index 5a98faa6ddaa..904088d4ec78 100644 --- a/code/modules/admin/tabs/admin_tab.dm +++ b/code/modules/admin/tabs/admin_tab.dm @@ -169,12 +169,12 @@ if(N.is_ban) var/ban_text = N.ban_time ? "Banned for [N.ban_time] | " : "" color = "#880000" - dat += "[ban_text][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] " + dat += "[ban_text][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " else if(N.is_confidential) color = "#AA0055" - dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] " + dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " dat += "

" dat += "
" From 284aca4d841e6a47e4da5d1c4fc8fc09c4c889d4 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 28 Jul 2023 08:21:41 +0100 Subject: [PATCH 2/2] handle no round id --- code/datums/entities/player_note.dm | 4 +++- code/game/verbs/records.dm | 4 ++-- code/modules/admin/admin.dm | 4 ++-- code/modules/admin/tabs/admin_tab.dm | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/code/datums/entities/player_note.dm b/code/datums/entities/player_note.dm index 9ee7cf7a34ba..420bb5f0a470 100644 --- a/code/datums/entities/player_note.dm +++ b/code/datums/entities/player_note.dm @@ -1,9 +1,11 @@ +#define NOTE_ROUND_ID(note_entity) note_entity.round_id ? "(ID: [note_entity.round_id])" : "" + /datum/entity/player_note var/player_id var/admin_id var/text var/date - var/round_id = "N/A" + var/round_id var/is_ban = FALSE var/ban_time var/is_confidential = FALSE diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index d783039f4fb1..f09de72da2e6 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -53,7 +53,7 @@ if(NOTE_YAUTJA) color = "#114e11" - dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] (ID: [N.round_id]) " + dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] [NOTE_ROUND_ID(N)] " dat += "

" dat += "
" @@ -168,7 +168,7 @@ continue var/admin_ckey = N.admin_ckey - dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] (ID: [N.round_id]) " + dat += "[N.text] by [admin_ckey] ([N.admin_rank]) on [N.date] [NOTE_ROUND_ID(N)] " ///Can remove notes from anyone other than yourself, unless you're the host. So long as you have deletion access anyway. if((can_del && target != get_player_from_key(key)) || ishost(usr)) dat += "Remove" diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 32c2dffcd0f9..2c749df71bb7 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -89,7 +89,7 @@ if(N.is_ban) var/time_d = N.ban_time ? "Banned for [N.ban_time] minutes | " : "" color = "#880000" //Removed confidential check because we can't make confidential bans - dat += "[time_d][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " + dat += "[time_d][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] [NOTE_ROUND_ID(N)] " else if(N.is_confidential) color = "#AA0055" @@ -102,7 +102,7 @@ else if(N.note_category == NOTE_YAUTJA) color = "#114e11" - dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " + dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] [NOTE_ROUND_ID(N)] " if(admin_ckey == usr.ckey || admin_ckey == "Adminbot" || ishost(usr)) dat += "Remove" diff --git a/code/modules/admin/tabs/admin_tab.dm b/code/modules/admin/tabs/admin_tab.dm index 904088d4ec78..a2f3bd42df5f 100644 --- a/code/modules/admin/tabs/admin_tab.dm +++ b/code/modules/admin/tabs/admin_tab.dm @@ -169,12 +169,12 @@ if(N.is_ban) var/ban_text = N.ban_time ? "Banned for [N.ban_time] | " : "" color = "#880000" - dat += "[ban_text][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " + dat += "[ban_text][N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] [NOTE_ROUND_ID(N)] " else if(N.is_confidential) color = "#AA0055" - dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] (ID: [N.round_id]) " + dat += "[N.text] by [admin_ckey] ([N.admin_rank])[confidential_text] on [N.date] [NOTE_ROUND_ID(N)] " dat += "

" dat += "
"