diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm
index 22b33f93b1d..8adf647f56b 100644
--- a/code/modules/admin/admin_ranks.dm
+++ b/code/modules/admin/admin_ranks.dm
@@ -59,7 +59,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums
return flag
/proc/admin_keyword_to_path(word) //use this with verb keywords eg +/client/proc/blah
- return text2path(copytext(word,2,findtext(word," ",2,0)))
+ return text2path(copytext(word, 2, findtext(word, " ", 2, 0)))
// Adds/removes rights to this admin_rank
/datum/admin_rank/proc/process_keyword(word, previous_rights=0)
@@ -115,7 +115,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums
var/prev = findchar(line, "+-", next, 0)
while(prev)
- next = findchar(line, "+-", prev+1, 0)
+ next = findchar(line, "+-", prev + 1, 0)
R.process_keyword(copytext(line, prev, next), previous_rights)
prev = next
@@ -152,14 +152,15 @@ var/list/admin_ranks = list() //list of all admin_rank datums
#endif
-/proc/load_admins()
+/proc/load_admins(target = null)
//clear the datums references
- admin_datums.Cut()
- for(var/client/C in admins)
- C.remove_admin_verbs()
- C.holder = null
- admins.Cut()
- load_admin_ranks()
+ if(!target)
+ admin_datums.Cut()
+ for(var/client/C in admins)
+ C.remove_admin_verbs()
+ C.holder = null
+ admins.Cut()
+ load_admin_ranks()
var/list/rank_names = list()
for(var/datum/admin_rank/R in admin_ranks)
@@ -167,35 +168,28 @@ var/list/admin_ranks = list() //list of all admin_rank datums
if(config.admin_legacy_system)
//load text from file
- var/list/Lines = file2list("config/admins.txt")
+ var/list/lines = file2list("config/admins.txt")
//process each line seperately
- for(var/line in Lines)
+ for(var/line in lines)
if(!length(line))
continue
- if(findtextEx(line,"#",1,2))
+ if(findtextEx(line, "#", 1, 2))
continue
- //Split the line at every "="
- var/list/List = splittext(line, "=")
- if(!List.len)
+ var/list/entry = splittext(line, "=")
+ if(entry.len < 2)
continue
- //ckey is before the first "="
- var/ckey = ckey(List[1])
- if(!ckey)
+ var/ckey = ckey(entry[1])
+ var/rank = ckeyEx(entry[2])
+ if(!ckey || !rank || (target && ckey != target))
continue
- //rank follows the first "="
- var/rank = ""
- if(List.len >= 2)
- rank = ckeyEx(List[2])
-
var/datum/admins/D = new(rank_names[rank], ckey) //create the admin datum and store it for later use
if(!D)
continue //will occur if an invalid rank is provided
D.associate(directory[ckey]) //find the client for a ckey if they are connected and associate them with the new admin datum
-
else
establish_db_connection()
if(!dbcon.IsConnected())
@@ -210,9 +204,13 @@ var/list/admin_ranks = list() //list of all admin_rank datums
while(query.NextRow())
var/ckey = ckey(query.item[1])
var/rank = ckeyEx(query.item[2])
+ if(target && ckey != target)
+ continue
+
if(rank_names[rank] == null)
WARNING("Admin rank ([rank]) does not exist.")
continue
+
var/datum/admins/D = new(rank_names[rank], ckey) //create the admin datum and store it for later use
if(!D)
continue //will occur if an invalid rank is provided
@@ -232,7 +230,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums
if(holder)
holder.rank = newrank
else
- holder = new /datum/admins(newrank,ckey)
+ holder = new /datum/admins(newrank, ckey)
remove_admin_verbs()
holder.associate(src)
@@ -240,10 +238,9 @@ var/list/admin_ranks = list() //list of all admin_rank datums
if(holder)
holder.rank.rights = newrights
else
- holder = new /datum/admins("testing",newrights,ckey)
+ holder = new /datum/admins("testing", newrights, ckey)
remove_admin_verbs()
holder.associate(src)
-
#endif
/datum/admins/proc/edit_rights_topic(list/href_list)
diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm
index cab1e1afa9f..97c96daee32 100644
--- a/code/modules/admin/admin_verbs.dm
+++ b/code/modules/admin/admin_verbs.dm
@@ -2,7 +2,7 @@
var/list/admin_verbs_default = list(
/client/proc/toggleadminhelpsound, /*toggles whether we hear a sound when adminhelps/PMs are used*/
/client/proc/toggleannouncelogin, /*toggles if an admin's login is announced during a round*/
- /client/proc/deadmin_self, /*destroys our own admin datum so we can play as a regular player*/
+ /client/proc/deadmin, /*destroys our own admin datum so we can play as a regular player*/
/client/proc/cmd_admin_say, /*admin-only ooc chat*/
/client/proc/hide_verbs, /*hides all our adminverbs*/
/client/proc/hide_most_verbs, /*hides all our hideable adminverbs*/
@@ -156,7 +156,7 @@ var/list/admin_verbs_rejuv = list(
var/list/admin_verbs_hideable = list(
/client/proc/set_ooc,
/client/proc/reset_ooc,
- /client/proc/deadmin_self,
+ /client/proc/deadmin,
/client/proc/deadchat,
/client/proc/toggleprayers,
/client/proc/toggle_hear_radio,
@@ -551,19 +551,6 @@ var/list/admin_verbs_hideable = list(
togglebuildmode(src.mob)
feedback_add_details("admin_verb","TBMS") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
-/client/proc/deadmin_self()
- set name = "De-admin self"
- set category = "Admin"
-
- if(holder)
- log_admin("[src] deadmined themself.")
- message_admins("[src] deadmined themself.")
- deadmin()
- verbs += /client/proc/readmin
- deadmins += ckey
- src << "You are now a normal player."
- feedback_add_details("admin_verb","DAS") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
-
/client/proc/toggle_log_hrefs()
set name = "Toggle href logging"
set category = "Server"
@@ -583,57 +570,44 @@ var/list/admin_verbs_hideable = list(
if(holder)
src.holder.output_ai_laws()
+/client/proc/deadmin()
+ set name = "Deadmin"
+ set category = "Admin"
+ set desc = "Shed your admin powers."
+
+ if(!holder)
+ return
+
+ holder.disassociate()
+ qdel(holder)
+
+ deadmins += ckey
+ admin_datums -= ckey
+ verbs += /client/proc/readmin
+
+ src << "You are now a normal player."
+ log_admin("[src] deadmined themself.")
+ message_admins("[src] deadmined themself.")
+ feedback_add_details("admin_verb","DAS")
+
/client/proc/readmin()
- set name = "Re-admin self"
+ set name = "Readmin"
set category = "Admin"
set desc = "Regain your admin powers."
- var/list/rank_names = list()
- for(var/datum/admin_rank/R in admin_ranks)
- rank_names[R.name] = R
- var/datum/admins/D = admin_datums[ckey]
- var/rank = null
- if(config.admin_legacy_system)
- //load text from file
- var/list/Lines = file2list("config/admins.txt")
- for(var/line in Lines)
- var/list/splitline = splittext(line, " = ")
- if(ckey(splitline[1]) == ckey)
- if(splitline.len >= 2)
- rank = ckeyEx(splitline[2])
- break
- continue
- else
- if(!dbcon.IsConnected())
- message_admins("Warning, mysql database is not connected.")
- src << "Warning, mysql database is not connected."
- return
- var/sql_ckey = sanitizeSQL(ckey)
- var/DBQuery/query = dbcon.NewQuery("SELECT rank FROM [format_table_name("admin")] WHERE ckey = '[sql_ckey]'")
- query.Execute()
- while(query.NextRow())
- rank = ckeyEx(query.item[1])
- if(!D)
- if(rank_names[rank] == null)
- var/error_extra = ""
- if(!config.admin_legacy_system)
- error_extra = " Check mysql DB connection."
- src << "Error while re-adminning, admin rank ([rank]) does not exist.[error_extra]"
- WARNING("Error while re-adminning [src], admin rank ([rank]) does not exist.[error_extra]")
- return
- D = new(rank_names[rank],ckey)
- var/client/C = directory[ckey]
- D.associate(C)
- message_admins("[src] re-adminned themselves.")
- log_admin("[src] re-adminned themselves.")
- deadmins -= ckey
- feedback_add_details("admin_verb","RAS")
- return
- else
- src << "You are already an admin."
- verbs -= /client/proc/readmin
- deadmins -= ckey
+
+ load_admins(ckey)
+
+ if(!holder) // Something went wrong...
return
+ deadmins -= ckey
+ verbs -= /client/proc/readmin
+
+ src << "You are now an admin."
+ message_admins("[src] re-adminned themselves.")
+ log_admin("[src] re-adminned themselves.")
+ feedback_add_details("admin_verb","RAS")
+
/client/proc/populate_world(amount = 50 as num)
set name = "Populate World"
set category = "Debug"
diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm
index e7a0550b862..d9ed6cb9f80 100644
--- a/code/modules/admin/holder2.dm
+++ b/code/modules/admin/holder2.dm
@@ -87,13 +87,6 @@ you will have to do something like if(client.rights & R_ADMIN) yourself.
return usr.client.holder.check_if_greater_rights_than_holder(other.holder)
return 0
-/client/proc/deadmin()
- admin_datums -= ckey
- if(holder)
- holder.disassociate()
- del(holder)
- return 1
-
//This proc checks whether subject has at least ONE of the rights specified in rights_required.
/proc/check_rights_for(client/subject, rights_required)
if(subject && subject.holder && subject.holder.rank)