From 7be74af23fd75ec7930da138de42e4099bbdbe46 Mon Sep 17 00:00:00 2001 From: kane-f <57303506+kane-f@users.noreply.github.com> Date: Sat, 29 Jan 2022 20:34:22 +0000 Subject: [PATCH] Pax bans (#31926) * Pax bans * Fixes * Stops removal during it * Fix * Annotation * Actual ban loading too * New way of doing it * New way of doing it * Truncates code * Even more truncating Co-authored-by: kanef --- __DEFINES/setup.dm | 4 +++ code/modules/admin/admin.dm | 1 + code/modules/admin/banpax.dm | 34 ++++++++++++++++++++++ code/modules/admin/topic.dm | 56 ++++++++++++++++++++++++++++++++++-- code/modules/mob/mob.dm | 4 +++ code/world.dm | 1 + vgstation13.dme | 1 + 7 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 code/modules/admin/banpax.dm diff --git a/__DEFINES/setup.dm b/__DEFINES/setup.dm index 4e6806eac1b..be476741ed8 100644 --- a/__DEFINES/setup.dm +++ b/__DEFINES/setup.dm @@ -680,6 +680,8 @@ var/list/liftable_structures = list(\ #define BANTYPE_APPEARANCE 6 #define BANTYPE_OOC_PERMA 7 #define BANTYPE_OOC_TEMP 8 +#define BANTYPE_PAX_PERMA 9 +#define BANTYPE_PAX_TEMP 10 #define SEE_INVISIBLE_MINIMUM 5 @@ -1446,6 +1448,8 @@ var/proccalls = 1 //OOC isbanned #define oocban_isbanned(key) oocban_keylist.Find("[ckey(key)]") +#define paxban_isbanned(key) paxban_keylist.Find("[ckey(key)]") + //message modes. you're not supposed to mess with these. #define MODE_HEADSET "headset" #define MODE_ROBOT "robot" diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index dfa7e0a4aaf..a4f942cd901 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -69,6 +69,7 @@ var/global/floorIsLava = 0 Ban | Jobban | OOC Ban | + Pax Ban | Identity Ban | Notes "} diff --git a/code/modules/admin/banpax.dm b/code/modules/admin/banpax.dm new file mode 100644 index 00000000000..9bfeb3f825c --- /dev/null +++ b/code/modules/admin/banpax.dm @@ -0,0 +1,34 @@ +var/paxban_keylist[0] + +/proc/pax_unban(mob/M) + if(!M) + return 0 + return paxban_keylist.Remove("[M.ckey]") + +/proc/pax_ban(mob/M) + if(!M) + return 0 + return paxban_keylist.Add("[M.ckey]") + +/proc/paxban_loadbanfile() + if(!SSdbcore.Connect()) + world.log << "Database connection failed. Skipping pax ban loading" + diary << "Database connection failed. Skipping pax ban loading" + return + + //OOC permabans + var/datum/DBQuery/query = SSdbcore.NewQuery("SELECT ckey FROM erro_ban WHERE (bantype = :pax_perma OR (bantype = :pax_temp AND expiration_time > Now())) AND isnull(unbanned)", + list( + "pax_perma" = "pax_PERMABAN", + "pax_temp" = "pax_TEMPBAN", + )) + if(!query.Execute()) + message_admins("Error: [query.ErrorMsg()]") + log_sql("Error: [query.ErrorMsg()]") + qdel(query) + return + + while(query.NextRow()) + var/ckey = query.item[1] + paxban_keylist.Add("[ckey]") + qdel(query) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 94e33334596..7dbdc1630bc 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -193,12 +193,12 @@ return banduration = null banjob = null - if(BANTYPE_OOC_PERMA) + if(BANTYPE_OOC_PERMA || BANTYPE_PAX_PERMA) if(!banckey || !banreason) to_chat(usr, "Not enough parameters (Requires ckey and reason)") return banduration = null - if(BANTYPE_OOC_TEMP) + if(BANTYPE_OOC_TEMP || BANTYPE_PAX_TEMP) if(!banckey || !banreason || !banduration) to_chat(usr, "Not enough parameters (Requires ckey, reason, and duration)") return @@ -923,6 +923,58 @@ return else return + else if(href_list["paxban"]) + if(!check_rights(R_BAN)) + return + var/mob/M = locate(href_list["paxban"]) + if(!ismob(M)) + to_chat(usr, "This can only be used on instances of type /mob") + return + if(!M.ckey) //sanity + to_chat(usr, "This mob has no ckey") + return + var/paxbanned = paxban_isbanned("[M.ckey]") + if(paxbanned && alert("Remove pax ban?","Please Confirm","Yes","No") == "Yes") + ban_unban_log_save("[key_name(usr)] removed [key_name(M)]'s pax ban") + log_admin("[key_name(usr)] removed [key_name(M)]'s pax ban") + feedback_inc("ban_pax_unban", 1) + DB_ban_unban(M.ckey, BANTYPE_PAX_PERMA) + pax_unban(M) + message_admins("[key_name_admin(usr)] removed [key_name_admin(M)]'s PAX ban", 1) + to_chat(M, "[usr.client.ckey] has removed your PAX ban.") + else if(alert("Pax ban [M.ckey]?","Please Confirm","Yes","No") == "Yes") + var/temp = alert("Temporary Ban?",,"Yes","No", "Cancel") + var/mins = 0 + switch(temp) + if("Yes") + mins = input(usr,"How long (in minutes)?","PAX Ban time",1440) as num|null + if(!mins) + return + if(mins >= 525600) + mins = 525599 + if("Cancel") + return + var/istemp = temp == "Yes" + var/reason = input(usr,"Reason?","reason","Greytider") as text|null + if(!reason) + return + to_chat(M, "You have been PAX banned by [usr.client.ckey].\nReason: [reason].") + to_chat(M, "This is a [istemp ? "temporary" : "permanent"] pax ban[istemp ? ", it will be removed in [mins] minutes" : ""].") + if(config.banappeals) + to_chat(M, "To try to resolve this matter head to [config.banappeals]") + else + to_chat(M, "No ban appeals URL has been set.") + var/resolvetext = istemp ? "This will be removed in [mins] minutes." : "This is a permanent pax ban." + ban_unban_log_save("[usr.client.ckey] has [istemp ? "temp-" : "perma-"]pax banned [M.ckey]. - Reason: [reason] - [resolvetext]") + feedback_inc(istemp ? "ban_pax_tmp" : "ban_pax_perma",1) + DB_ban_record(istemp ? BANTYPE_PAX_TEMP : BANTYPE_PAX_PERMA, M, istemp ? mins : -1, reason) + if(istemp) + feedback_inc("ban_pax_tmp_mins",mins) + log_admin("[usr.client.ckey] has pax banned [M.ckey].\nReason: [reason]\n[resolvetext]") + message_admins("[usr.client.ckey] has pax banned [M.ckey].\nReason: [reason]\n[resolvetext]") + pax_ban(M) + else + return else if(href_list["appearanceban"]) if(!check_rights(R_BAN)) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 821bce1d1ce..917dbfa6df7 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -2103,6 +2103,10 @@ Use this proc preferably at the end of an equipment loadout alphas.Remove(source_define) /mob/proc/is_pacified(var/message = VIOLENCE_SILENT,var/target,var/weapon) + if(paxban_isbanned(ckey)) + to_chat(src, "You feel some strange force preventing you from being violent.") + return TRUE + if (runescape_pvp) var/area/A = get_area(src) if (!istype(A, /area/maintenance) && !is_type_in_list(A,non_standard_maint_areas)) diff --git a/code/world.dm b/code/world.dm index a97331f2464..b1badb0aaf5 100644 --- a/code/world.dm +++ b/code/world.dm @@ -91,6 +91,7 @@ var/auxtools_path load_alienwhitelist() jobban_loadbanfile() oocban_loadbanfile() + paxban_loadbanfile() jobban_updatelegacybans() appearance_loadbanfile() LoadBans() diff --git a/vgstation13.dme b/vgstation13.dme index a449b7edf30..8852cc6c07e 100644 --- a/vgstation13.dme +++ b/vgstation13.dme @@ -1336,6 +1336,7 @@ #include "code\modules\admin\banappearance.dm" #include "code\modules\admin\banjob.dm" #include "code\modules\admin\banooc.dm" +#include "code\modules\admin\banpax.dm" #include "code\modules\admin\body_archive_panel.dm" #include "code\modules\admin\buildmode.dm" #include "code\modules\admin\check_antagonists.dm"