Does the rest of the if()'s/ else's

This commit is contained in:
Firecage
2016-01-17 19:03:12 +02:00
parent 754491ce4c
commit 332bde0f4f
186 changed files with 2169 additions and 1085 deletions
+80 -40
View File
@@ -14,30 +14,48 @@ var/list/admin_ranks = list() //list of all admin_rank datums
qdel(src)
throw EXCEPTION("invalid admin-rank name")
return
if(init_rights) rights = init_rights
if(!init_adds) init_adds = list()
if(!init_subs) init_subs = list()
if(init_rights)
rights = init_rights
if(!init_adds)
init_adds = list()
if(!init_subs)
init_subs = list()
adds = init_adds
subs = init_subs
/proc/admin_keyword_to_flag(word, previous_rights=0)
var/flag = 0
switch(ckey(word))
if("buildmode","build") flag = R_BUILDMODE
if("admin") flag = R_ADMIN
if("ban") flag = R_BAN
if("fun") flag = R_FUN
if("server") flag = R_SERVER
if("debug") flag = R_DEBUG
if("permissions","rights") flag = R_PERMISSIONS
if("possess") flag = R_POSSESS
if("stealth") flag = R_STEALTH
if("rejuv","rejuvinate") flag = R_REJUVINATE
if("varedit") flag = R_VAREDIT
if("everything","host","all") flag = 65535
if("sound","sounds") flag = R_SOUNDS
if("spawn","create") flag = R_SPAWN
if("@","prev") flag = previous_rights
if("buildmode","build")
flag = R_BUILDMODE
if("admin")
flag = R_ADMIN
if("ban")
flag = R_BAN
if("fun")
flag = R_FUN
if("server")
flag = R_SERVER
if("debug")
flag = R_DEBUG
if("permissions","rights")
flag = R_PERMISSIONS
if("possess")
flag = R_POSSESS
if("stealth")
flag = R_STEALTH
if("rejuv","rejuvinate")
flag = R_REJUVINATE
if("varedit")
flag = R_VAREDIT
if("everything","host","all")
flag = 65535
if("sound","sounds")
flag = R_SOUNDS
if("spawn","create")
flag = R_SPAWN
if("@","prev")
flag = previous_rights
return flag
/proc/admin_keyword_to_path(word) //use this with verb keywords eg +/client/proc/blah
@@ -48,8 +66,10 @@ var/list/admin_ranks = list() //list of all admin_rank datums
var/flag = admin_keyword_to_flag(word, previous_rights)
if(flag)
switch(text2ascii(word,1))
if(43) rights |= flag //+
if(45) rights &= ~flag //-
if(43)
rights |= flag //+
if(45)
rights &= ~flag //-
else
//isn't a keyword so maybe it's a verbpath?
var/path = admin_keyword_to_path(word)
@@ -82,12 +102,15 @@ var/list/admin_ranks = list() //list of all admin_rank datums
var/previous_rights = 0
//load text from file and process each line seperately
for(var/line in file2list("config/admin_ranks.txt"))
if(!line) continue
if(findtextEx(line,"#",1,2)) continue
if(!line)
continue
if(findtextEx(line,"#",1,2))
continue
var/next = findtext(line, "=")
var/datum/admin_rank/R = new(ckeyEx(copytext(line, 1, next)))
if(!R) continue
if(!R)
continue
admin_ranks += R
var/prev = findchar(line, "+-", next, 0)
@@ -111,9 +134,11 @@ var/list/admin_ranks = list() //list of all admin_rank datums
while(query.NextRow())
var/rank_name = ckeyEx(query.item[1])
var/flags = query.item[2]
if(istext(flags)) flags = text2num(flags)
if(istext(flags))
flags = text2num(flags)
var/datum/admin_rank/R = new(rank_name, flags)
if(!R) continue
if(!R)
continue
admin_ranks += R
#ifdef TESTING
@@ -121,7 +146,8 @@ var/list/admin_ranks = list() //list of all admin_rank datums
for(var/datum/admin_rank/R in admin_ranks)
msg += "\t[R.name]"
var/rights = rights2text(R.rights,"\n\t\t",R.adds,R.subs)
if(rights) msg += "\t\t[rights]\n"
if(rights)
msg += "\t\t[rights]\n"
testing(msg)
#endif
@@ -145,16 +171,20 @@ var/list/admin_ranks = list() //list of all admin_rank datums
//process each line seperately
for(var/line in Lines)
if(!length(line)) continue
if(findtextEx(line,"#",1,2)) continue
if(!length(line))
continue
if(findtextEx(line,"#",1,2))
continue
//Split the line at every "="
var/list/List = text2list(line, "=")
if(!List.len) continue
if(!List.len)
continue
//ckey is before the first "="
var/ckey = ckey(List[1])
if(!ckey) continue
if(!ckey)
continue
//rank follows the first "="
var/rank = ""
@@ -162,7 +192,8 @@ var/list/admin_ranks = list() //list of all admin_rank datums
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
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
@@ -183,7 +214,8 @@ var/list/admin_ranks = list() //list of all admin_rank datums
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
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
#ifdef TESTING
@@ -225,7 +257,8 @@ var/list/admin_ranks = list() //list of all admin_rank datums
switch(task)
if("add")
var/new_ckey = ckey(input(usr,"New admin's ckey","Admin ckey", null) as text|null)
if(!new_ckey) return
if(!new_ckey)
return
if(new_ckey in admin_datums)
usr << "<font color='red'>Error: Topic 'editrights': [new_ckey] is already an admin</font>"
return
@@ -242,7 +275,8 @@ var/list/admin_ranks = list() //list of all admin_rank datums
switch(task)
if("remove")
if(alert("Are you sure you want to remove [adm_ckey]?","Message","Yes","Cancel") == "Yes")
if(!D) return
if(!D)
return
if(!check_if_greater_rights_than_holder(D))
message_admins("[key_name_admin(usr)] attempted to remove [adm_ckey] from the admins list without sufficient rights.")
log_admin("[key_name(usr)] attempted to remove [adm_ckey] from the admins list without sufficient rights.")
@@ -265,10 +299,12 @@ var/list/admin_ranks = list() //list of all admin_rank datums
var/new_rank = input("Please select a rank", "New rank", null, null) as null|anything in rank_names
switch(new_rank)
if(null) return
if(null)
return
if("*New Rank*")
new_rank = ckeyEx(input("Please input a new rank", "New custom rank", null, null) as null|text)
if(!new_rank) return
if(!new_rank)
return
if(D)
if(!check_if_greater_rights_than_holder(D))
@@ -278,8 +314,10 @@ var/list/admin_ranks = list() //list of all admin_rank datums
R = rank_names[new_rank]
if(!R) //rank with that name doesn't exist yet - make it
if(D) R = new(new_rank, D.rank.rights, D.rank.adds, D.rank.subs) //duplicate our previous admin_rank but with a new name
else R = new(new_rank) //blank new admin_rank
if(D)
R = new(new_rank, D.rank.rights, D.rank.adds, D.rank.subs) //duplicate our previous admin_rank but with a new name
else
R = new(new_rank) //blank new admin_rank
admin_ranks += R
if(D) //they were previously an admin
@@ -297,10 +335,12 @@ var/list/admin_ranks = list() //list of all admin_rank datums
log_admin_rank_modification(adm_ckey, new_rank)
if("permissions")
if(!D) return //they're not an admin!
if(!D)
return //they're not an admin!
var/keyword = input("Input permission keyword (one at a time):\ne.g. +BAN or -FUN or +/client/proc/someverb", "Permission toggle", null, null) as null|text
if(!keyword) return
if(!keyword)
return
if(!check_keyword(keyword) || !check_if_greater_rights_than_holder(D))
message_admins("[key_name_admin(usr)] attempted to give [adm_ckey] the keyword [keyword] without sufficient rights.")