Crimes are now logging in db (#90948)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Crimes are now logged in db

Logging: 

![image](https://github.com/user-attachments/assets/6eee470d-863a-4f68-9836-04a0a0079aa2)

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
idk
we logging citations but not crimes, and i wanted to log the crimes too
<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and its effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑 Rengan
server: The crimes are now logging in the database.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
This commit is contained in:
RengaN02
2025-05-10 22:17:20 +03:00
committed by GitHub
parent 235f9e77ff
commit 7bb71d38fd
8 changed files with 31 additions and 8 deletions

View File

@@ -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)

View File

@@ -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,

View File

@@ -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,

View File

@@ -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

View File

@@ -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,
))

View File

@@ -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: <strong>[input_name]</strong> | 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: <strong>[input_name]</strong> 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

View File

@@ -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

View File

@@ -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: <strong>[citation_name]</strong> 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: <strong>[crime_name]</strong> | 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