From 7dc3d906d1843f47398e3bfa6496ab4c8804d6ae Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 13 Oct 2021 18:26:41 +0100 Subject: [PATCH] Actually tack the values on --- SQL/updates/26-27.sql | 2 ++ code/__HELPERS/unsorted.dm | 5 +++-- code/controllers/subsystem/blackbox.dm | 7 ++++--- code/controllers/subsystem/dbcore.dm | 4 ++-- code/controllers/subsystem/statistics.dm | 5 +++-- code/modules/admin/db_ban/functions.dm | 7 ++++--- code/modules/admin/sql_notes.dm | 9 ++------- code/modules/karma/karma.dm | 7 ++++--- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/SQL/updates/26-27.sql b/SQL/updates/26-27.sql index 3acef9a45a8..b4931236600 100644 --- a/SQL/updates/26-27.sql +++ b/SQL/updates/26-27.sql @@ -25,6 +25,8 @@ ALTER TABLE `legacy_population` ADD COLUMN `server_id` VARCHAR(50) NULL DEFAULT NULL AFTER `admincount`; # Notes already has a column for this +ALTER TABLE `notes` + CHANGE COLUMN `server` `server` VARCHAR(50) NULL COLLATE 'utf8mb4_general_ci' AFTER `edits`; ALTER TABLE `round` ADD COLUMN `server_id` VARCHAR(50) NULL DEFAULT NULL AFTER `station_name`; diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 6d3f119af47..399f669761e 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -2061,11 +2061,12 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) /proc/log_connection(ckey, ip, cid, connection_type) ASSERT(connection_type in list(CONNECTION_TYPE_ESTABLISHED, CONNECTION_TYPE_DROPPED_IPINTEL, CONNECTION_TYPE_DROPPED_BANNED, CONNECTION_TYPE_DROPPED_INVALID)) - var/datum/db_query/query_accesslog = SSdbcore.NewQuery("INSERT INTO connection_log (`datetime`, `ckey`, `ip`, `computerid`, `result`) VALUES(Now(), :ckey, :ip, :cid, :result)", list( + var/datum/db_query/query_accesslog = SSdbcore.NewQuery("INSERT INTO connection_log (`datetime`, `ckey`, `ip`, `computerid`, `result`, `server_id`) VALUES(Now(), :ckey, :ip, :cid, :result, :server_id)", list( "ckey" = ckey, "ip" = "[ip ? ip : ""]", // This is important. NULL is not the same as "", and if you directly open the `.dmb` file, you get a NULL IP. "cid" = cid, - "result" = connection_type + "result" = connection_type, + "server_id" = GLOB.configuration.system.instance_id )) query_accesslog.warn_execute() qdel(query_accesslog) diff --git a/code/controllers/subsystem/blackbox.dm b/code/controllers/subsystem/blackbox.dm index 37e4299b06d..273fd71dbc1 100644 --- a/code/controllers/subsystem/blackbox.dm +++ b/code/controllers/subsystem/blackbox.dm @@ -287,8 +287,8 @@ SUBSYSTEM_DEF(blackbox) lakey = L.lastattackerckey var/datum/db_query/deathquery = SSdbcore.NewQuery({" - INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) - VALUES (:name, :key, :job, :special, :pod, NOW(), :laname, :lakey, :gender, :bruteloss, :fireloss, :brainloss, :oxyloss, :coord)"}, + INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord, server_id) + VALUES (:name, :key, :job, :special, :pod, NOW(), :laname, :lakey, :gender, :bruteloss, :fireloss, :brainloss, :oxyloss, :coord, :server_id)"}, list( "name" = L.real_name, "key" = L.key, @@ -302,7 +302,8 @@ SUBSYSTEM_DEF(blackbox) "fireloss" = L.getFireLoss(), "brainloss" = L.getBrainLoss(), "oxyloss" = L.getOxyLoss(), - "coord" = "[L.x], [L.y], [L.z]" + "coord" = "[L.x], [L.y], [L.z]", + "server_id" = GLOB.configuration.system.instance_id ) ) deathquery.warn_execute() diff --git a/code/controllers/subsystem/dbcore.dm b/code/controllers/subsystem/dbcore.dm index f6974a2fb17..ed7e8c25596 100644 --- a/code/controllers/subsystem/dbcore.dm +++ b/code/controllers/subsystem/dbcore.dm @@ -160,8 +160,8 @@ SUBSYSTEM_DEF(dbcore) if(!IsConnected()) return var/datum/db_query/query_round_initialize = SSdbcore.NewQuery( - "INSERT INTO round (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(:internet_address), :port)", - list("internet_address" = world.internet_address || "0", "port" = "[world.port]") + "INSERT INTO round (initialize_datetime, server_ip, server_port, server_id) VALUES (Now(), INET_ATON(:internet_address), :port, :server_id)", + list("internet_address" = world.internet_address || "0", "port" = "[world.port]", "server_id" = GLOB.configuration.system.instance_id) ) query_round_initialize.Execute(async = FALSE) GLOB.round_id = "[query_round_initialize.last_insert_id]" diff --git a/code/controllers/subsystem/statistics.dm b/code/controllers/subsystem/statistics.dm index 63c20742904..01ebaf215f7 100644 --- a/code/controllers/subsystem/statistics.dm +++ b/code/controllers/subsystem/statistics.dm @@ -18,10 +18,11 @@ SUBSYSTEM_DEF(statistics) return else var/datum/db_query/statquery = SSdbcore.NewQuery( - "INSERT INTO legacy_population (playercount, admincount, time) VALUES (:playercount, :admincount, NOW())", + "INSERT INTO legacy_population (playercount, admincount, time, server_id) VALUES (:playercount, :admincount, NOW(), :server_id)", list( "playercount" = length(GLOB.clients), - "admincount" = length(GLOB.admins) + "admincount" = length(GLOB.admins), + "server_id" = GLOB.configuration.system.instance_id ) ) statquery.warn_execute() diff --git a/code/modules/admin/db_ban/functions.dm b/code/modules/admin/db_ban/functions.dm index d16b61ae690..999ba84b5e6 100644 --- a/code/modules/admin/db_ban/functions.dm +++ b/code/modules/admin/db_ban/functions.dm @@ -146,8 +146,8 @@ qdel(adm_query) var/datum/db_query/query_insert = SSdbcore.NewQuery({" - INSERT INTO ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`,`ban_round_id`,`unbanned_round_id`) - VALUES (null, Now(), :serverip, :bantype_str, :reason, :job, :duration, :rounds, Now() + INTERVAL :duration MINUTE, :ckey, :computerid, :ip, :a_ckey, :a_computerid, :a_ip, :who, :adminwho, '', null, null, null, null, null, :roundid, null) + INSERT INTO ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`,`ban_round_id`,`unbanned_round_id`, `server_id`) + VALUES (null, Now(), :serverip, :bantype_str, :reason, :job, :duration, :rounds, Now() + INTERVAL :duration MINUTE, :ckey, :computerid, :ip, :a_ckey, :a_computerid, :a_ip, :who, :adminwho, '', null, null, null, null, null, :roundid, null, :server_id) "}, list( // Get ready for parameters "serverip" = serverip, @@ -164,7 +164,8 @@ "a_ip" = a_ip, "who" = who, "adminwho" = adminwho, - "roundid" = GLOB.round_id + "roundid" = GLOB.round_id, + "server_id" = GLOB.configuration.system.instance_id )) if(!query_insert.warn_execute()) qdel(query_insert) diff --git a/code/modules/admin/sql_notes.dm b/code/modules/admin/sql_notes.dm index af7a7150d92..2fc02253315 100644 --- a/code/modules/admin/sql_notes.dm +++ b/code/modules/admin/sql_notes.dm @@ -1,5 +1,4 @@ -// Do not attemtp to remove the blank string from the server arg. It will break DB saving. -/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, server = "", checkrights = 1, show_after = TRUE, automated = FALSE) +/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, checkrights = 1, show_after = TRUE, automated = FALSE) if(checkrights && !check_rights(R_ADMIN|R_MOD)) return if(!SSdbcore.IsConnected()) @@ -53,10 +52,6 @@ else if(usr && (usr.ckey == ckey(adminckey))) // Don't ckeyize special note sources adminckey = ckey(adminckey) - if(!server) - if(GLOB.configuration.general.server_name) - server = GLOB.configuration.general.server_name - // Force cast this to 1/0 incase someone tries to feed bad data automated = !!automated @@ -67,7 +62,7 @@ "targetckey" = target_ckey, "notetext" = notetext, "adminkey" = adminckey, - "server" = server, + "server" = GLOB.configuration.system.instance_id, "crewnum" = crew_number, "roundid" = GLOB.round_id, "automated" = automated diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index dd0743cfcef..f684a8b261c 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -16,15 +16,16 @@ return var/datum/db_query/log_query = SSdbcore.NewQuery({" - INSERT INTO karma (spendername, spenderkey, receivername, receiverkey, receiverrole, receiverspecial, spenderip, time) - VALUES (:sname, :skey, :rname, :rkey, :rrole, :rspecial, :sip, Now())"}, list( + INSERT INTO karma (spendername, spenderkey, receivername, receiverkey, receiverrole, receiverspecial, spenderip, time, server_id) + VALUES (:sname, :skey, :rname, :rkey, :rrole, :rspecial, :sip, Now(), :server_id)"}, list( "sname" = spender.name, "skey" = spender.ckey, "rname" = receiver.name, "rkey" = receiver.ckey, "rrole" = receiverrole, "rspecial" = receiverspecial, - "sip" = spender.client.address + "sip" = spender.client.address, + "server_id" = GLOB.configuration.system.instance_id )) if(!log_query.warn_execute())