- Expands the maximum number of admin permission flags you can have from 16 to 31.

To test: add these debug lines somewhere:

//START COPY PASTE

mob/verb/give_allrights()
	src.client.holder.rights = 393087

mob/verb/hasright()
	var/hi = input(src,"Choose a file to access:","Download",null) as null|num
	var/r = check_rights(hi, 1);
	world << "[r]"

mob/verb/checkrights()
	for(var/i = 0; i < 32; i++)
		var/n = 1 << i
		var/r = check_rights(n , 1);
		world << "has right 2^[i] = [n]? [r]"

//END COPY PASTE

Start the game, run 'give allrights', which doesn't give all rights, but some of the rights. 128 and 131072 are missing. Then you can either run 'hasright' to check whether you have the permissions that correspond to a user defined number, or you can run 'checkrights' to check for all 31 theoretical permissions.
This commit is contained in:
errorage
2013-07-22 19:22:47 +02:00
parent 5925d3a876
commit 86a68cb55b
10 changed files with 67 additions and 41 deletions
+5 -1
View File
@@ -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
+29 -16
View File
@@ -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()
+1 -1
View File
@@ -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