Death Stats Fix (#18100)

* Death Stats Fix

Changes how the coordinates for the death stats are stored.
-> One column for x,y,z instead of all mashed into one column

* Add missing GLOB

* convert indentation

* Rebase to latest master

* Adds the attackers char id aswell.

* Slight reformatting and add constraint

* Fix indentation

* Adds another check

---------

Co-authored-by: Werner <Arrow768@users.noreply.github.com>
This commit is contained in:
Werner
2024-01-06 15:16:25 +00:00
committed by GitHub
co-authored by Werner
parent 7c00488b35
commit 9c18c99c37
3 changed files with 79 additions and 24 deletions
@@ -0,0 +1,9 @@
--
-- Adds a column for single coordinate instead of mashing them into one column
--
ALTER TABLE `ss13_death`
ADD COLUMN `loc_x` INT NULL AFTER `oxyloss`,
ADD COLUMN `loc_y` INT NULL AFTER `loc_x`,
ADD COLUMN `loc_z` INT NULL AFTER `loc_y`,
ADD COLUMN `lachar_id` INT NULL DEFAULT NULL AFTER `lackey`,
ADD CONSTRAINT `FK_ss13_death_ss13_characters_lachar_id` FOREIGN KEY (`lachar_id`) REFERENCES `ss13_characters` (`id`) ON UPDATE CASCADE ON DELETE CASCADE;
+29 -24
View File
@@ -241,36 +241,41 @@ GENERAL_PROTECT_DATUM(/datum/controller/subsystem/statistics)
return
if(!istype(H, /mob/living/carbon/human) && !istype(H, /mob/living/silicon/robot))
return
if(!H.key || !H.mind)
return
var/area/placeofdeath = get_area(H)
var/podname = placeofdeath ? "[placeofdeath]" : "Unknown area"
if(!establish_db_connection(GLOB.dbcon))
log_game("SQL ERROR during death reporting. Failed to connect.")
else
var/DBQuery/query = GLOB.dbcon.NewQuery("INSERT INTO ss13_death (name, ckey, char_id, job, special, pod, tod, laname, lackey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES \
(:name:, :ckey:, :char_id:, :job:, :special:, :pod:, :tod:, :laname:, :lackey:, :gender:, :bruteloss:, :fireloss:, :brainloss:, :oxyloss:, :coord:')")
if(!query.Execute(list(
"name"=H.real_name,
"ckey"=H.ckey,
"char_id"=H.character_id,
"job"=H?.mind.assigned_role,
"special"=H?.mind.special_role,
"pod"=podname,
"tod"=time2text(world.realtime, "YYYY-MM-DD hh:mm:ss"),
"laname"=H?.lastattacker?.real_name,
"lackey"=H?.lastattacker?.ckey,
"gender"=H.gender,
"bruteloss"=H.getBruteLoss(),
"fireloss"=H.getFireLoss(),
"brainloss"=H.getBrainLoss(),
"oxyloss"=H.getOxyLoss(),
"coord"="[H.x], [H.y], [H.z]")
))
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
return
//Prepare location data
var/turf/T = get_turf(H)
var/DBQuery/query = GLOB.dbcon.NewQuery("INSERT INTO ss13_death (name, ckey, char_id, job, special, pod, tod, laname, lackey, lachar_id, gender, bruteloss, fireloss, brainloss, oxyloss, loc_x, loc_y, loc_z) VALUES \
(:name:, :ckey:, :char_id:, :job:, :special:, :pod:, :tod:, :laname:, :lackey:, :lachar_id:, :gender:, :bruteloss:, :fireloss:, :brainloss:, :oxyloss:, :loc_x:, :loc_y:, :loc_z:)")
if(!query.Execute(list(
"name"=H.real_name,
"ckey"=H.ckey,
"char_id"=H.character_id,
"job"=H?.mind?.assigned_role,
"special"=H?.mind?.special_role,
"pod"=podname,
"tod"=time2text(world.realtime, "YYYY-MM-DD hh:mm:ss"),
"laname"=H?.lastattacker?.real_name,
"lackey"=H?.lastattacker?.ckey,
"lachar_id"=H?.lastattacker?.character_id,
"gender"=H.gender,
"bruteloss"=H.getBruteLoss(),
"fireloss"=H.getFireLoss(),
"brainloss"=H.getBrainLoss(),
"oxyloss"=H.getOxyLoss(),
"loc_x"=T?.x,
"loc_y"=T?.y,
"loc_z"=T?.z)
))
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
/datum/controller/subsystem/statistics/proc/IncrementSimpleStat(stat)
. = TRUE
@@ -0,0 +1,41 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
# admin
# backend
# security
# refactor
#################################
# Your name.
author: arrow768
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- backend: "Changes how the coordinates for the death stats are stored."