From 6e1cd35850d9f6173d93b62dd02abf734c1d3551 Mon Sep 17 00:00:00 2001 From: Gabriel Adamson Date: Sat, 11 Sep 2021 01:11:34 -0500 Subject: [PATCH 1/4] Adds a minimum admin count to auto-deadmin, also adds a preference for auto-deadmin on critical roles --- code/__DEFINES/preferences.dm | 1 + code/controllers/configuration/entries/general.dm | 5 +++++ code/controllers/subsystem/job.dm | 2 ++ code/modules/admin/permissionedit.dm | 4 ++++ code/modules/client/preferences.dm | 7 +++++++ code/modules/jobs/job_types/ai.dm | 2 +- code/modules/jobs/job_types/captain.dm | 2 +- code/modules/jobs/job_types/head_of_security.dm | 2 +- config/config.txt | 3 +++ 9 files changed, 25 insertions(+), 3 deletions(-) diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index 3691e3f1c4ba..4515f4126476 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -22,6 +22,7 @@ #define DEADMIN_POSITION_HEAD (1<<18) #define DEADMIN_POSITION_SECURITY (1<<19) #define DEADMIN_POSITION_SILICON (1<<20) +#define DEADMIN_POSITION_CRITICAL (1<<21) #define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|MEMBER_PUBLIC|INTENT_STYLE|MIDROUND_ANTAG|SOUND_INSTRUMENTS|SOUND_SHIP_AMBIENCE|SOUND_PRAYERS|SOUND_ANNOUNCEMENTS|SOUND_JUKEBOX) diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 1e0b6ceadf45..6d8786398d9a 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -20,6 +20,11 @@ /datum/config_entry/flag/auto_deadmin_security protection = CONFIG_ENTRY_LOCKED +/datum/config_entry/flag/auto_deadmin_critical + protection = CONFIG_ENTRY_LOCKED + +/datum/config_entry/number/auto_deadmin_threshold + protection = CONFIG_ENTRY_LOCKED /datum/config_entry/string/servername // server name (the name of the game window) diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm index 5dafdac0c3f9..c36df21596d9 100644 --- a/code/controllers/subsystem/job.dm +++ b/code/controllers/subsystem/job.dm @@ -562,6 +562,8 @@ SUBSYSTEM_DEF(job) var/datum/job/job = GetJob(rank) if(!job) return + if((job.auto_deadmin_role_flags & DEADMIN_POSITION_CRITICAL) && (CONFIG_GET(flag/auto_deadmin_critical) || (C.prefs?.toggles & DEADMIN_POSITION_CRITICAL))) + return C.holder.auto_deadmin() if((job.auto_deadmin_role_flags & DEADMIN_POSITION_HEAD) && (CONFIG_GET(flag/auto_deadmin_heads) || (C.prefs?.toggles & DEADMIN_POSITION_HEAD))) return C.holder.auto_deadmin() else if((job.auto_deadmin_role_flags & DEADMIN_POSITION_SECURITY) && (CONFIG_GET(flag/auto_deadmin_security) || (C.prefs?.toggles & DEADMIN_POSITION_SECURITY))) diff --git a/code/modules/admin/permissionedit.dm b/code/modules/admin/permissionedit.dm index 09f416d9e8d8..7563b2c610fa 100644 --- a/code/modules/admin/permissionedit.dm +++ b/code/modules/admin/permissionedit.dm @@ -291,6 +291,10 @@ D.deactivate() //after logs so the deadmined admin can see the message. /datum/admins/proc/auto_deadmin() + if(GLOB.admins.len <= CONFIG_GET(number/auto_deadmin_threshold)) + log_admin("[owner] auto-deadmin failed due to low admin count.") + to_chat(owner, "You have not be auto-deadminned due to lack of admins on the server, you can still deadmin manually") + return FALSE to_chat(owner, "You are now a normal player.") var/old_owner = owner deactivate() diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 4a4f06ce10da..8be896f6e000 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -796,6 +796,11 @@ GLOBAL_LIST_EMPTY(preferences_datums) else dat += "As Silicon: FORCED
" + if(!CONFIG_GET(flag/auto_deadmin_critical)) + dat += "As Critical Roles: [(toggles & DEADMIN_POSITION_CRITICAL)?"Deadmin":"Keep Admin"]
" + else + dat += "As Critical Roles: FORCED
" + dat += "" dat += "" // yogs start - Donor features @@ -1823,6 +1828,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) toggles ^= DEADMIN_POSITION_SECURITY if("toggle_deadmin_silicon") toggles ^= DEADMIN_POSITION_SILICON + if("toggle_deadmin_critical") + toggles ^= DEADMIN_POSITION_CRITICAL if("be_special") diff --git a/code/modules/jobs/job_types/ai.dm b/code/modules/jobs/job_types/ai.dm index f4d2d1a88f5a..27c3204449bd 100644 --- a/code/modules/jobs/job_types/ai.dm +++ b/code/modules/jobs/job_types/ai.dm @@ -1,7 +1,7 @@ /datum/job/ai title = "AI" flag = AI_JF - auto_deadmin_role_flags = DEADMIN_POSITION_SILICON + auto_deadmin_role_flags = DEADMIN_POSITION_SILICON|DEADMIN_POSITION_CRITICAL department_flag = ENGSEC faction = "Station" total_positions = 1 diff --git a/code/modules/jobs/job_types/captain.dm b/code/modules/jobs/job_types/captain.dm index ed41d6e3f60f..b4fada77658b 100755 --- a/code/modules/jobs/job_types/captain.dm +++ b/code/modules/jobs/job_types/captain.dm @@ -1,7 +1,7 @@ /datum/job/captain title = "Captain" flag = CAPTAIN - auto_deadmin_role_flags = DEADMIN_POSITION_HEAD|DEADMIN_POSITION_SECURITY + auto_deadmin_role_flags = DEADMIN_POSITION_HEAD|DEADMIN_POSITION_SECURITY|DEADMIN_POSITION_CRITICAL department_head = list("CentCom") department_flag = ENGSEC faction = "Station" diff --git a/code/modules/jobs/job_types/head_of_security.dm b/code/modules/jobs/job_types/head_of_security.dm index ce3922f03431..ae1265c89b35 100644 --- a/code/modules/jobs/job_types/head_of_security.dm +++ b/code/modules/jobs/job_types/head_of_security.dm @@ -1,7 +1,7 @@ /datum/job/hos title = "Head of Security" flag = HOS - auto_deadmin_role_flags = DEADMIN_POSITION_HEAD|DEADMIN_POSITION_SECURITY + auto_deadmin_role_flags = DEADMIN_POSITION_HEAD|DEADMIN_POSITION_SECURITY|DEADMIN_POSITION_CRITICAL department_head = list("Captain") department_flag = ENGSEC head_announce = list(RADIO_CHANNEL_SECURITY) diff --git a/config/config.txt b/config/config.txt index 82f10f23585f..2e01aaa976d4 100644 --- a/config/config.txt +++ b/config/config.txt @@ -322,7 +322,10 @@ MAPROTATIONCHANCEDELTA 1 #AUTO_DEADMIN_HEADS #AUTO_DEADMIN_SECURITY #AUTO_DEADMIN_SILICONS +AUTO_DEADMIN_CRITICAL +## The number of admins at which it auto-deadminning will be disabled +AUTO_DEADMIN_THRESHOLD 1 ## CLIENT VERSION CONTROL ## This allows you to configure the minimum required client version, as well as a warning version, and message for both. From 246382634f11954076805a208a47873b19943d88 Mon Sep 17 00:00:00 2001 From: Gabriel Adamson Date: Sat, 11 Sep 2021 01:37:30 -0500 Subject: [PATCH 2/4] Disables the forced deadmin, increases the threshold --- config/config.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.txt b/config/config.txt index 2e01aaa976d4..1bb35111110b 100644 --- a/config/config.txt +++ b/config/config.txt @@ -322,10 +322,10 @@ MAPROTATIONCHANCEDELTA 1 #AUTO_DEADMIN_HEADS #AUTO_DEADMIN_SECURITY #AUTO_DEADMIN_SILICONS -AUTO_DEADMIN_CRITICAL +#AUTO_DEADMIN_CRITICAL -## The number of admins at which it auto-deadminning will be disabled -AUTO_DEADMIN_THRESHOLD 1 +## The number of admins at which it auto-deadminning will be disabled, includes the admin trying to auto-deadmin +AUTO_DEADMIN_THRESHOLD 3 ## CLIENT VERSION CONTROL ## This allows you to configure the minimum required client version, as well as a warning version, and message for both. From 5370e8065428e3e753dc5f8e0324c64e877a0417 Mon Sep 17 00:00:00 2001 From: Gabriel Adamson Date: Sat, 11 Sep 2021 01:46:52 -0500 Subject: [PATCH 3/4] Changed config to be the minimum to auto-deadming, as its more intuitive --- code/modules/admin/permissionedit.dm | 2 +- config/config.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/permissionedit.dm b/code/modules/admin/permissionedit.dm index 7563b2c610fa..1230d51eb94b 100644 --- a/code/modules/admin/permissionedit.dm +++ b/code/modules/admin/permissionedit.dm @@ -291,7 +291,7 @@ D.deactivate() //after logs so the deadmined admin can see the message. /datum/admins/proc/auto_deadmin() - if(GLOB.admins.len <= CONFIG_GET(number/auto_deadmin_threshold)) + if(GLOB.admins.len < CONFIG_GET(number/auto_deadmin_threshold)) log_admin("[owner] auto-deadmin failed due to low admin count.") to_chat(owner, "You have not be auto-deadminned due to lack of admins on the server, you can still deadmin manually") return FALSE diff --git a/config/config.txt b/config/config.txt index 1bb35111110b..e2f736b11a2e 100644 --- a/config/config.txt +++ b/config/config.txt @@ -324,8 +324,8 @@ MAPROTATIONCHANCEDELTA 1 #AUTO_DEADMIN_SILICONS #AUTO_DEADMIN_CRITICAL -## The number of admins at which it auto-deadminning will be disabled, includes the admin trying to auto-deadmin -AUTO_DEADMIN_THRESHOLD 3 +## The minimum nubmer of admins to allow for auto deadminning, includes the deadminning admin +AUTO_DEADMIN_THRESHOLD 4 ## CLIENT VERSION CONTROL ## This allows you to configure the minimum required client version, as well as a warning version, and message for both. From e36700b640870c56df8fdda12cb7b358b1196715 Mon Sep 17 00:00:00 2001 From: Gabriel Adamson Date: Sat, 11 Sep 2021 01:51:37 -0500 Subject: [PATCH 4/4] Remove drone from silicon auto-deadmin --- .../mob/living/simple_animal/friendly/drone/_drone.dm | 7 ------- 1 file changed, 7 deletions(-) diff --git a/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm b/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm index a65d3e2b2a5f..b755bc9a48ad 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm @@ -142,13 +142,6 @@ if(!picked) pickVisualAppearence() -/mob/living/simple_animal/drone/auto_deadmin_on_login() - if(!client?.holder) - return TRUE - if(CONFIG_GET(flag/auto_deadmin_silicons) || (client.prefs?.toggles & DEADMIN_POSITION_SILICON)) - return client.holder.auto_deadmin() - return ..() - /mob/living/simple_animal/drone/death(gibbed) ..(gibbed) if(internal_storage)