From 08a1c4bb5c7793cd60828b769d9ee4903ee91c5d Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 20 Aug 2017 20:41:34 -0400 Subject: [PATCH] Add logging of deathgasp last words and suicide stats to the death table (#29953) * Add logging of deathgasp last words * Column size -> 255 * comment * Adds suicide tracking to stats death table * Commas * Merge the changes --- SQL/database_changelog.txt | 18 +++++++++++++++--- SQL/tgstation_schema.sql | 2 ++ SQL/tgstation_schema_prefixed.sql | 2 ++ code/_compile_options.dm | 2 +- code/controllers/subsystem/blackbox.dm | 4 +++- code/modules/mob/living/living_defines.dm | 2 ++ code/modules/mob/living/say.dm | 1 + 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt index b5d027283f6..f1722b4b5b2 100644 --- a/SQL/database_changelog.txt +++ b/SQL/database_changelog.txt @@ -1,10 +1,22 @@ Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255. -The latest database version is 3.1; The query to update the schema revision table is: +The latest database version is 3.2; The query to update the schema revision table is: -INSERT INTO `schema_revision` (`major`, `minor`) VALUES (3, 1); +INSERT INTO `schema_revision` (`major`, `minor`) VALUES (3, 2); or -INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (3, 1); +INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (3, 2); + +---------------------------------------------------- + +18 August 2017, by Cyberboss and nfreader + +Modified table 'death', adding the columns `last_words` and 'suicide'. + +ALTER TABLE `death` +ADD COLUMN `last_words` varchar(255) DEFAULT NULL AFTER `staminaloss`, +ADD COLUMN `suicide` tinyint(0) NOT NULL DEFAULT '0' AFTER `last_words`; + +Remember to add a prefix to the table name if you use them. ---------------------------------------------------- diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql index 9795b906720..04181985711 100644 --- a/SQL/tgstation_schema.sql +++ b/SQL/tgstation_schema.sql @@ -148,6 +148,8 @@ CREATE TABLE `death` ( `toxloss` smallint(5) unsigned NOT NULL, `cloneloss` smallint(5) unsigned NOT NULL, `staminaloss` smallint(5) unsigned NOT NULL, + `last_words` varchar(255) DEFAULT NULL, + `suicide` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql index b810a82ca3e..f1f2525a970 100644 --- a/SQL/tgstation_schema_prefixed.sql +++ b/SQL/tgstation_schema_prefixed.sql @@ -148,6 +148,8 @@ CREATE TABLE `SS13_death` ( `toxloss` smallint(5) unsigned NOT NULL, `cloneloss` smallint(5) unsigned NOT NULL, `staminaloss` smallint(5) unsigned NOT NULL, + `last_words` varchar(255) DEFAULT NULL, + `suicide` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 80309e73ee6..8b0a3c807cd 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -72,4 +72,4 @@ //Update this whenever the db schema changes //make sure you add an update to the schema_version stable in the db changelog #define DB_MAJOR_VERSION 3 -#define DB_MINOR_VERSION 1 +#define DB_MINOR_VERSION 2 diff --git a/code/controllers/subsystem/blackbox.dm b/code/controllers/subsystem/blackbox.dm index 90c6b80cf9c..4ce42c3ffe0 100644 --- a/code/controllers/subsystem/blackbox.dm +++ b/code/controllers/subsystem/blackbox.dm @@ -208,8 +208,10 @@ SUBSYSTEM_DEF(blackbox) var/x_coord = sanitizeSQL(L.x) var/y_coord = sanitizeSQL(L.y) var/z_coord = sanitizeSQL(L.z) + var/last_words = sanitizeSQL(L.last_words) + var/suicide = sanitizeSQL(L.suiciding) var/map = sanitizeSQL(SSmapping.config.map_name) - var/datum/DBQuery/query_report_death = SSdbcore.NewQuery("INSERT INTO [format_table_name("death")] (pod, x_coord, y_coord, z_coord, mapname, server_ip, server_port, round_id, tod, job, special, name, byondkey, laname, lakey, bruteloss, fireloss, brainloss, oxyloss, toxloss, cloneloss, staminaloss) VALUES ('[sqlpod]', '[x_coord]', '[y_coord]', '[z_coord]', '[map]', INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]', [GLOB.round_id], '[SQLtime()]', '[sqljob]', '[sqlspecial]', '[sqlname]', '[sqlkey]', '[laname]', '[lakey]', [sqlbrute], [sqlfire], [sqlbrain], [sqloxy], [sqltox], [sqlclone], [sqlstamina])") + var/datum/DBQuery/query_report_death = SSdbcore.NewQuery("INSERT INTO [format_table_name("death")] (pod, x_coord, y_coord, z_coord, mapname, server_ip, server_port, round_id, tod, job, special, name, byondkey, laname, lakey, bruteloss, fireloss, brainloss, oxyloss, toxloss, cloneloss, staminaloss, last_words) VALUES ('[sqlpod]', '[x_coord]', '[y_coord]', '[z_coord]', '[map]', INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]', [GLOB.round_id], '[SQLtime()]', '[sqljob]', '[sqlspecial]', '[sqlname]', '[sqlkey]', '[laname]', '[lakey]', [sqlbrute], [sqlfire], [sqlbrain], [sqloxy], [sqltox], [sqlclone], [sqlstamina], [last_words], [suicide])") query_report_death.Execute() /datum/controller/subsystem/blackbox/proc/Seal() diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 6cb3a8daa92..f32ca97b09e 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -75,3 +75,5 @@ var/datum/riding/riding_datum var/datum/language/selected_default_language + + var/last_words //used for database logging diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 68e2b150f35..cf1b95b98d7 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -155,6 +155,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list( var/message_len = length(message) message = copytext(message, 1, health_diff) + "[message_len > health_diff ? "-.." : "..."]" message = Ellipsis(message, 10, 1) + last_words = message message_mode = MODE_WHISPER_CRIT succumbed = TRUE else