mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
Merge pull request #1002 from errorage/2013-07-22-permission-flags-expansion
Expands the max number of admin permission flags from 16 to 31
This commit is contained in:
@@ -37,10 +37,14 @@ var/list/admin_ranks = list() //list of all ranks with associated rights
|
||||
if("stealth") rights |= R_STEALTH
|
||||
if("rejuv","rejuvinate") rights |= R_REJUVINATE
|
||||
if("varedit") rights |= R_VAREDIT
|
||||
if("everything","host","all") rights |= R_HOST
|
||||
if("everything","host","all") rights |= ((2 * R_MAXPERMISSION) - 1)
|
||||
if("sound","sounds") rights |= R_SOUNDS
|
||||
if("spawn","create") rights |= R_SPAWN
|
||||
|
||||
/* --ONCE FLAGS LARGER OR EQUAL THAN 2^16 = 65536 START BEING USED, USE THIS CODE!
|
||||
if("nukeeverything") rights += R_NUKEEVERYTHING
|
||||
*/
|
||||
|
||||
admin_ranks[rank] = rights
|
||||
previous_rights = rights
|
||||
|
||||
|
||||
@@ -52,19 +52,11 @@ you will have to do something like if(client.rights & R_ADMIN) yourself.
|
||||
*/
|
||||
/proc/check_rights(rights_required, show_msg=1)
|
||||
if(usr && usr.client)
|
||||
if(rights_required)
|
||||
if(usr.client.holder)
|
||||
if(rights_required & usr.client.holder.rights)
|
||||
return 1
|
||||
else
|
||||
if(show_msg)
|
||||
usr << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")].</font>"
|
||||
if (check_rights_for(usr.client, rights_required))
|
||||
return 1
|
||||
else
|
||||
if(usr.client.holder)
|
||||
return 1
|
||||
else
|
||||
if(show_msg)
|
||||
usr << "<font color='red'>Error: You are not an admin.</font>"
|
||||
if(show_msg)
|
||||
usr << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")].</font>"
|
||||
return 0
|
||||
|
||||
//probably a bit iffy - will hopefully figure out a better solution
|
||||
@@ -73,9 +65,13 @@ you will have to do something like if(client.rights & R_ADMIN) yourself.
|
||||
if(usr.client.holder)
|
||||
if(!other || !other.holder)
|
||||
return 1
|
||||
if(usr.client.holder.rights != other.holder.rights)
|
||||
if( (usr.client.holder.rights & other.holder.rights) == other.holder.rights )
|
||||
return 1 //we have all the rights they have and more
|
||||
|
||||
var/usr_rights_pt2 = usr.client.holder.rights / 65536
|
||||
var/other_rights_pt2 = other.holder.rights / 65536
|
||||
if( (usr_rights_pt2 & other_rights_pt2) == other_rights_pt2 ) //Check values larger than 65535
|
||||
if(usr.client.holder.rights != other.holder.rights) //Check values smaller than 65536
|
||||
if( (usr.client.holder.rights & other.holder.rights) == other.holder.rights )
|
||||
return 1 //we have all the rights they have and more
|
||||
usr << "<font color='red'>Error: Cannot proceed. They have more or equal rights to us.</font>"
|
||||
return 0
|
||||
|
||||
@@ -85,4 +81,21 @@ you will have to do something like if(client.rights & R_ADMIN) yourself.
|
||||
if(holder)
|
||||
holder.disassociate()
|
||||
del(holder)
|
||||
return 1
|
||||
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)
|
||||
if(rights_required)
|
||||
if(subject.holder)
|
||||
if(rights_required >= 65536)
|
||||
var/rights_required_pt2 = rights_required / 65536
|
||||
var/rights_pt2 = subject.holder.rights / 65536
|
||||
if(rights_required_pt2 & rights_pt2)
|
||||
return 1
|
||||
if(rights_required & subject.holder.rights)
|
||||
return 1
|
||||
else
|
||||
if(subject.holder)
|
||||
return 1
|
||||
return 0
|
||||
@@ -50,8 +50,7 @@
|
||||
if(!usr.client)
|
||||
return
|
||||
|
||||
if(!usr.client.holder || !(usr.client.holder.rights & R_PERMISSIONS))
|
||||
usr << "\red You do not have permission to do this!"
|
||||
if (!check_rights(R_PERMISSIONS))
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
@@ -100,8 +99,7 @@
|
||||
if(!usr.client)
|
||||
return
|
||||
|
||||
if(!usr.client.holder || !(usr.client.holder.rights & R_PERMISSIONS))
|
||||
usr << "\red You do not have permission to do this!"
|
||||
if (check_rights(R_PERMISSIONS))
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
|
||||
@@ -700,7 +700,7 @@
|
||||
return
|
||||
|
||||
if(M != usr) //we can jobban ourselves
|
||||
if(M.client && M.client.holder && (M.client.holder.rights & R_BAN)) //they can ban too. So we can't ban them
|
||||
if (check_rights_for(M, R_BAN)) //they can ban too. So we can't ban them
|
||||
alert("You cannot perform this action. You must be of a higher administrative rank!")
|
||||
return
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ datum/preferences
|
||||
dat += "<b>Adminhelp Sound:</b> "
|
||||
dat += "<a href='?_src_=prefs;preference=hear_adminhelps'>[(toggles & SOUND_ADMINHELP)?"On":"Off"]</a><br>"
|
||||
|
||||
if(unlock_content || (user.client.holder && (user.client.holder.rights & R_ADMIN)))
|
||||
if(unlock_content || check_rights_for(user, R_ADMIN))
|
||||
dat += "<b>OOC:</b> <span style='border: 1px solid #161616; background-color: [ooccolor];'> </span> <a href='?_src_=prefs;preference=ooccolor;task=input'>Change</a><br>"
|
||||
|
||||
if(unlock_content)
|
||||
|
||||
Reference in New Issue
Block a user