mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 11:37:40 +01:00
Improved antag fishing busting (#19542)
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file houses all the code for antag tracking datum serialization and deserialization
|
||||
//
|
||||
// If you are going to modify ANYTHING in here, please test it THOROUGHLY
|
||||
// The serialization and deserialization here is so complicated that you WILL break something here
|
||||
// PLEASE test things properly if you modify this file. -aa07
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// All these defines are integral to the workings and mesh together with the database.
|
||||
// DO NOT EDIT THESE UNDER ANY CIRCUMSTANCES EVER
|
||||
#define ANTAGRECORD_FIRST_INFRACTION "First infraction: "
|
||||
#define ANTAGRECORD_LAST_INFRACTION "Last infraction: "
|
||||
#define ANTAGRECORD_TOTAL_INFRACTIONS "Total infractions: "
|
||||
|
||||
/datum/antag_record
|
||||
var/holder_ckey
|
||||
var/first_infraction_date
|
||||
var/last_infraction_date
|
||||
var/infraction_count
|
||||
var/has_note = FALSE
|
||||
|
||||
/datum/antag_record/New(_holder_ckey)
|
||||
holder_ckey = _holder_ckey
|
||||
|
||||
/datum/antag_record/proc/handle_data(datum/db_query/Q)
|
||||
var/notetxt = null
|
||||
|
||||
while(Q.NextRow())
|
||||
notetxt = Q.item[1]
|
||||
|
||||
if(notetxt)
|
||||
has_note = TRUE
|
||||
deserialize_and_load(notetxt)
|
||||
infraction_count++
|
||||
else
|
||||
// Sane defaults
|
||||
first_infraction_date = SQLtime()
|
||||
infraction_count = 1
|
||||
|
||||
last_infraction_date = SQLtime()
|
||||
|
||||
// Seems pointless but it allows code to flow smoother
|
||||
// Also I grew too dependant on languages that have nice syntax stuff
|
||||
/datum/antag_record/proc/get_load_query()
|
||||
return SSdbcore.NewQuery("SELECT notetext FROM notes WHERE ckey=:ckey AND adminckey=:ackey LIMIT 1", list(
|
||||
"ckey" = holder_ckey,
|
||||
"ackey" = ANTAGTRACKING_PSUEDO_CKEY
|
||||
))
|
||||
|
||||
/*
|
||||
Expected output below. These are parsed from raw_text by splitting by <br>
|
||||
[1] ANTAGRECORD_FIRST_INFRACTION
|
||||
[2] ANTAGRECORD_LAST_INFRACTION
|
||||
[3] ANTAGRECORD_TOTAL_INFRACTIONS
|
||||
*/
|
||||
|
||||
/datum/antag_record/proc/deserialize_and_load(raw_text)
|
||||
var/list/lines = splittext(raw_text, "<br>")
|
||||
// Text
|
||||
first_infraction_date = splittext(lines[1], ANTAGRECORD_FIRST_INFRACTION)[2]
|
||||
last_infraction_date = splittext(lines[2], ANTAGRECORD_LAST_INFRACTION)[2]
|
||||
// Number
|
||||
infraction_count = text2num(splittext(lines[3], ANTAGRECORD_TOTAL_INFRACTIONS)[2]) // Make sure its a number
|
||||
|
||||
/datum/antag_record/proc/get_save_query()
|
||||
var/serialized_text
|
||||
var/list/serialized_list = list()
|
||||
serialized_list.len = 3 // Make it 3 off the bat
|
||||
|
||||
serialized_list[1] = "[ANTAGRECORD_FIRST_INFRACTION][first_infraction_date]"
|
||||
serialized_list[2] = "[ANTAGRECORD_LAST_INFRACTION][last_infraction_date]"
|
||||
serialized_list[3] = "[ANTAGRECORD_TOTAL_INFRACTIONS][infraction_count]"
|
||||
|
||||
serialized_text = serialized_list.Join("<br>")
|
||||
|
||||
if(has_note) // They have a note. Update.
|
||||
var/datum/db_query/update_existing_note = SSdbcore.NewQuery("UPDATE notes SET notetext=:nt, timestamp=NOW(), round_id=:rid WHERE ckey=:ckey AND adminckey=:ackey", list(
|
||||
"nt" = serialized_text,
|
||||
"rid" = GLOB.round_id,
|
||||
"ckey" = holder_ckey,
|
||||
"ackey" = ANTAGTRACKING_PSUEDO_CKEY
|
||||
))
|
||||
|
||||
return update_existing_note
|
||||
else
|
||||
// They dont have a note. Make an insert query.
|
||||
// To the person who asks "why dont you juse use add_note()"
|
||||
// By making a query batch, we can use async magic to make it go faster
|
||||
var/datum/db_query/query_noteadd = SSdbcore.NewQuery({"
|
||||
INSERT INTO notes (ckey, timestamp, notetext, adminckey, server, round_id, automated)
|
||||
VALUES (:targetckey, NOW(), :notetext, :adminkey, :server, :roundid, 1)
|
||||
"}, list(
|
||||
"targetckey" = holder_ckey,
|
||||
"notetext" = serialized_text,
|
||||
"adminkey" = ANTAGTRACKING_PSUEDO_CKEY,
|
||||
"server" = GLOB.configuration.system.instance_id,
|
||||
"roundid" = GLOB.round_id,
|
||||
"automated" = TRUE
|
||||
))
|
||||
|
||||
return query_noteadd
|
||||
@@ -730,28 +730,6 @@ GLOBAL_LIST_INIT(intents, list(INTENT_HELP,INTENT_DISARM,INTENT_GRAB,INTENT_HARM
|
||||
// Cast to 1/0
|
||||
return !!(client.prefs.toggles & toggleflag)
|
||||
|
||||
// Used to make sure that a player has a valid job preference setup, used to knock players out of eligibility for anything if their prefs don't make sense.
|
||||
// A "valid job preference setup" in this situation means at least having one job set to low, or not having "return to lobby" enabled
|
||||
// Prevents "antag rolling" by setting antag prefs on, all jobs to never, and "return to lobby if preferences not availible"
|
||||
// Doing so would previously allow you to roll for antag, then send you back to lobby if you didn't get an antag role
|
||||
// This also does some admin notification and logging as well
|
||||
/mob/proc/has_valid_preferences()
|
||||
if(!client)
|
||||
return FALSE //Not sure how this would get run without the mob having a client, but let's just be safe.
|
||||
if(client.prefs.active_character.alternate_option != RETURN_TO_LOBBY)
|
||||
return TRUE
|
||||
// If they have antags enabled, they're potentially doing this on purpose instead of by accident. Notify admins if so.
|
||||
var/has_antags = FALSE
|
||||
if(client.prefs.be_special.len > 0)
|
||||
has_antags = TRUE
|
||||
if(!client.prefs.active_character.check_any_job())
|
||||
to_chat(src, "<span class='danger'>You have no jobs enabled, along with return to lobby if job is unavailable. This makes you ineligible for any round start role, please update your job preferences.</span>")
|
||||
if(has_antags)
|
||||
log_admin("[src.ckey] just got booted back to lobby with no jobs, but antags enabled.")
|
||||
message_admins("[src.ckey] just got booted back to lobby with no jobs enabled, but antag rolling enabled. Likely antag rolling abuse.")
|
||||
return FALSE //This is the only case someone should actually be completely blocked from antag rolling as well
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* Helper proc to determine if a mob can use emotes that make sound or not.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user