From 7bb71d38fd73465ebf48b1f58800c1f77f49aa02 Mon Sep 17 00:00:00 2001 From: RengaN02 <60517664+RengaN02@users.noreply.github.com> Date: Sat, 10 May 2025 22:17:20 +0300 Subject: [PATCH] Crimes are now logging in db (#90948) ## About The Pull Request Crimes are now logged in db Logging: ![image](https://github.com/user-attachments/assets/6eee470d-863a-4f68-9836-04a0a0079aa2) ## Why It's Good For The Game idk we logging citations but not crimes, and i wanted to log the crimes too ## Changelog :cl: Rengan server: The crimes are now logging in the database. /:cl: --- SQL/database_changelog.md | 12 ++++++++++-- SQL/tgstation_schema.sql | 1 + SQL/tgstation_schema_prefixed.sql | 1 + code/__DEFINES/subsystems.dm | 2 +- code/controllers/subsystem/blackbox.dm | 14 +++++++++++--- code/game/machinery/computer/records/security.dm | 5 ++++- code/game/machinery/computer/warrant.dm | 1 + code/modules/mob/living/carbon/human/human.dm | 3 ++- 8 files changed, 31 insertions(+), 8 deletions(-) diff --git a/SQL/database_changelog.md b/SQL/database_changelog.md index 373d97bdf6c..6d241af2869 100644 --- a/SQL/database_changelog.md +++ b/SQL/database_changelog.md @@ -5,15 +5,23 @@ Make sure to also update `DB_MAJOR_VERSION` and `DB_MINOR_VERSION`, which can be The latest database version is 5.28; The query to update the schema revision table is: ```sql -INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 29); +INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 30); ``` or ```sql -INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 29); +INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 30); ``` In any query remember to add a prefix to the table names if you use one. ----------------------------------------------------- +Version 5.30, 1 May 2025, by Rengan +Adds `crime_desc` field to the `citation` table to save the description of the crime. + +```sql +ALTER TABLE `citation` +ADD COLUMN `crime_desc` TEXT NULL DEFAULT NULL AFTER `crime`; +``` +----------------------------------------------------- Version 5.29, 4 February 2024, by Tiviplus Fixed admin rank table flags being capped at 16 in the DB instead of 24 (byond max) diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql index 96933aa14e1..22f44efd2bf 100644 --- a/SQL/tgstation_schema.sql +++ b/SQL/tgstation_schema.sql @@ -115,6 +115,7 @@ CREATE TABLE IF NOT EXISTS `citation` ( `sender_ic` varchar(64) NOT NULL DEFAULT '' COMMENT 'Longer because this is the character name, not the ckey', `recipient` varchar(64) NOT NULL DEFAULT '' COMMENT 'Longer because this is the character name, not the ckey', `crime` text NOT NULL, + `crime_desc` text NULL DEFAULT NULL, `fine` int(4) DEFAULT NULL, `paid` int(4) DEFAULT 0, `timestamp` datetime NOT NULL, diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql index 7b322d5a652..cd71da42ee4 100644 --- a/SQL/tgstation_schema_prefixed.sql +++ b/SQL/tgstation_schema_prefixed.sql @@ -115,6 +115,7 @@ CREATE TABLE IF NOT EXISTS `SS13_citation` ( `sender_ic` varchar(64) NOT NULL DEFAULT '' COMMENT 'Longer because this is the character name, not the ckey', `recipient` varchar(64) NOT NULL DEFAULT '' COMMENT 'Longer because this is the character name, not the ckey', `crime` text NOT NULL, + `crime_desc` text NULL DEFAULT NULL, `fine` int(4) DEFAULT NULL, `paid` int(4) DEFAULT 0, `timestamp` datetime NOT NULL, diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 1dec12359c0..6ad1357f501 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -20,7 +20,7 @@ * * make sure you add an update to the schema_version stable in the db changelog */ -#define DB_MINOR_VERSION 29 +#define DB_MINOR_VERSION 30 //! ## Timing subsystem diff --git a/code/controllers/subsystem/blackbox.dm b/code/controllers/subsystem/blackbox.dm index 2e29401861c..b6879301a83 100644 --- a/code/controllers/subsystem/blackbox.dm +++ b/code/controllers/subsystem/blackbox.dm @@ -364,7 +364,10 @@ Versioning query_report_death.Execute(async = TRUE) qdel(query_report_death) -/datum/controller/subsystem/blackbox/proc/ReportCitation(citation, sender, sender_ic, recipient, message, fine = 0, paid = 0) +/datum/controller/subsystem/blackbox/proc/ReportCitation(citation, sender, sender_ic, recipient, message, description, fine = 0, paid = 0) + var/action = "Citation Created" + if(!fine) + action = "Crime Created" var/datum/db_query/query_report_citation = SSdbcore.NewQuery({"INSERT INTO [format_table_name("citation")] (server_ip, server_port, @@ -375,6 +378,7 @@ Versioning sender_ic, recipient, crime, + crime_desc, fine, paid, timestamp) VALUES ( @@ -387,20 +391,24 @@ Versioning :sender_ic, :recipient, :message, + :desc, :fine, :paid, NOW() ) ON DUPLICATE KEY UPDATE - paid = paid + VALUES(paid)"}, list( + paid = paid + VALUES(paid), + crime = IF(VALUES(crime) IS NOT NULL, VALUES(crime), crime), + crime_desc = IF(VALUES(crime_desc) IS NOT NULL, VALUES(crime_desc), crime_desc)"}, list( "server_ip" = world.internet_address || "0", "port" = "[world.port]", "round_id" = GLOB.round_id, "citation" = citation, - "action" = "Citation Created", + "action" = action, "sender" = sender, "sender_ic" = sender_ic, "recipient" = recipient, "message" = message, + "desc" = description, "fine" = fine, "paid" = paid, )) diff --git a/code/game/machinery/computer/records/security.dm b/code/game/machinery/computer/records/security.dm index 839bbaf23ee..788f42644ac 100644 --- a/code/game/machinery/computer/records/security.dm +++ b/code/game/machinery/computer/records/security.dm @@ -221,6 +221,7 @@ var/datum/crime/new_crime = new(name = input_name, details = input_details, author = usr) target.crimes += new_crime investigate_log("New Crime: [input_name] | Added to [target.name] by [key_name(user)]. Their previous status was [target.wanted_status]", INVESTIGATE_RECORDS) + SSblackbox.ReportCitation(REF(new_crime), user.ckey, user.real_name, target.name, input_name, input_details) target.wanted_status = WANTED_ARREST update_matching_security_huds(target.name) @@ -232,7 +233,7 @@ target.citations += new_citation new_citation.alert_owner(user, src, target.name, "You have been issued a [params["fine"]]cr citation for [input_name]. Fines are payable at Security.") investigate_log("New Citation: [input_name] Fine: [params["fine"]] | Added to [target.name] by [key_name(user)]", INVESTIGATE_RECORDS) - SSblackbox.ReportCitation(REF(new_citation), user.ckey, user.real_name, target.name, input_name, params["fine"]) + SSblackbox.ReportCitation(REF(new_citation), user.ckey, user.real_name, target.name, input_name, input_details, params["fine"]) return TRUE @@ -250,12 +251,14 @@ var/new_name = strip_html_full(params["name"], MAX_CRIME_NAME_LEN) investigate_log("[user] edited crime: \"[editing_crime.name]\" for target: \"[target.name]\", changing the name to: \"[new_name]\".", INVESTIGATE_RECORDS) editing_crime.name = new_name + SSblackbox.ReportCitation(REF(editing_crime), message = new_name) return TRUE if(params["description"] && length(params["description"]) > 2 && params["name"] != editing_crime.name) var/new_details = strip_html_full(params["description"], MAX_MESSAGE_LEN) investigate_log("[user] edited crime \"[editing_crime.name]\" for target: \"[target.name]\", changing the details to: \"[new_details]\" from: \"[editing_crime.details]\".", INVESTIGATE_RECORDS) editing_crime.details = new_details + SSblackbox.ReportCitation(REF(editing_crime), description = new_details) return TRUE return FALSE diff --git a/code/game/machinery/computer/warrant.dm b/code/game/machinery/computer/warrant.dm index 71455fc5a2e..7e66c748917 100644 --- a/code/game/machinery/computer/warrant.dm +++ b/code/game/machinery/computer/warrant.dm @@ -128,6 +128,7 @@ var/datum/bank_account/sec_account = SSeconomy.get_dep_account(ACCOUNT_SEC) sec_account.adjust_money(amount) + SSblackbox.ReportCitation(REF(warrant), paid = warrant.paid) if(warrant.fine != 0 || target.name == user) return TRUE diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index fd1004485f8..7bc81e7139f 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -340,7 +340,7 @@ target_record.citations += new_citation new_citation.alert_owner(usr, src, target_record.name, "You have been fined [fine] credits for '[citation_name]'. Fines may be paid at security.") investigate_log("New Citation: [citation_name] Fine: [fine] | Added to [target_record.name] by [key_name(human_user)]", INVESTIGATE_RECORDS) - SSblackbox.ReportCitation(REF(new_citation), human_user.ckey, human_user.real_name, target_record.name, citation_name, fine) + SSblackbox.ReportCitation(REF(new_citation), human_user.ckey, human_user.real_name, target_record.name, citation_name, null, fine) return @@ -353,6 +353,7 @@ target_record.crimes += new_crime investigate_log("New Crime: [crime_name] | Added to [target_record.name] by [key_name(human_user)]", INVESTIGATE_RECORDS) + SSblackbox.ReportCitation(REF(new_crime), human_user.ckey, human_user.real_name, target_record.name, crime_name, null) to_chat(human_user, span_notice("Successfully added a crime.")) return