mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 02:16:05 +00:00
SERVER HOSTS: This commit replaces the existing admin-rank system. It is now more customizable. Admin.txt essentially works the same as it always has. Each line should look like: ckey - admin rank There is now however, an admin_ranks.txt. This textfile allows you to define ranks like so: admin rank +ADMIN +FUN +BUILD the +KEYWORD are flags adding permissions to that rank. There are brief descriptions in the text-file explaining what they do. You can now name the ranks anything you like, and give them the permissions you want them to have. This allows, for instance, ranks like: Game Admin on disciplinary +ADMIN +BAN This would give that game admin only the tools they need to admin. They would not have access to 'fun' verbs which control events and antags. There's lots of things you can do. For instance, a coder rank whom can debug stuff but cannot do admin tasks: Codermin +DEBUG +VAREDIT +SERVER There's lots you can do. As it evolves it will hopefully become more flexible. admin_ranks.txt defaults to use the old admin rank names. Apologies in advance as there will be a lot of anomalies, such as ranks losing verbs they once had. Please let me know about any problems. I can fix them quite easily simply by moving verbs between the lists or splitting the lists up into new flags. CODERS: There is now a check_rights(flags) proc. It check is usr is and admin and has -at least one of- the rights specified. It checks > usr < not src, so keep that in mind! If you need to check if something other than usr has specific tights, you can do if(holder.rights & R_ADMIN) etc. KNOWN ISSUES: +FUN probably needs to be split up into +MOBS and +EVENTS In-game promotion/demotion is currently disabled. It will be readded after everything else works ok. Erro's sql rights changes stuff is currently commented out. It will be re-added. There are still many many verbs which need updating. Apologies in advance for any inconvenience. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4991 316c924e-a436-60f5-8080-3fe189b3f50e
94 lines
3.0 KiB
Plaintext
94 lines
3.0 KiB
Plaintext
var/list/admin_datums = list()
|
|
|
|
/datum/admins
|
|
var/rank = "Temporary Admin"
|
|
var/client/owner = null
|
|
|
|
var/rights = 0
|
|
|
|
var/fakekey = null
|
|
var/ooccolor = "#b82e00"
|
|
var/sound_adminhelp = 0 //If set to 1 this will play a sound when adminhelps are received.
|
|
|
|
var/datum/marked_datum
|
|
|
|
var/admincaster_screen = 0 //See newscaster.dm under machinery for a full description
|
|
var/datum/feed_message/admincaster_feed_message = new /datum/feed_message //These two will act as holders.
|
|
var/datum/feed_channel/admincaster_feed_channel = new /datum/feed_channel
|
|
var/admincaster_signature //What you'll sign the newsfeeds as
|
|
|
|
/datum/admins/New(initial_rank = "Temporary Admin", initial_rights = 0, ckey)
|
|
if(!ckey)
|
|
error("Admin datum created without a ckey argument. Datum has been deleted")
|
|
del(src)
|
|
return
|
|
admincaster_signature = "Nanotrasen Officer #[rand(0,9)][rand(0,9)][rand(0,9)]"
|
|
rank = initial_rank
|
|
rights = initial_rights
|
|
admin_datums[ckey] = src
|
|
|
|
/datum/admins/proc/associate(client/C)
|
|
if(C)
|
|
owner = C
|
|
owner.holder = src
|
|
owner.add_admin_verbs() //TODO
|
|
admins += src
|
|
|
|
/datum/admins/proc/disassociate()
|
|
if(owner)
|
|
admins -= owner
|
|
owner.remove_admin_verbs()
|
|
owner.holder = null
|
|
owner = null
|
|
|
|
/*
|
|
checks if usr is an admin with at least ONE of the flags in rights_required. (Note, they don't need all the flags)
|
|
if rights_required == 0, then it simply checks if they are an admin.
|
|
if it doesn't return 1 and show_msg=1 it will prints a message explaining why the check has failed
|
|
generally it would be used like so:
|
|
|
|
proc/admin_proc()
|
|
if(!check_rights(R_ADMIN)) return
|
|
world << "you have enough rights!"
|
|
|
|
NOTE: it checks usr! not src! So if you're checking somebody's rank in a proc which they did not call
|
|
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>"
|
|
else
|
|
if(usr.client.holder)
|
|
return 1
|
|
else
|
|
if(show_msg)
|
|
usr << "<font color='red'>Error: You are not an admin.</font>"
|
|
return 0
|
|
|
|
/proc/check_if_greater_rights_than(client/other)
|
|
if(usr && usr.client)
|
|
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
|
|
usr << "<font color='red'>Error: Cannot proceed. They have more or equal rights to us.</font>"
|
|
return 0
|
|
|
|
/client/proc/update_admin()
|
|
add_admin_verbs()
|
|
|
|
|
|
/client/proc/deadmin()
|
|
admin_datums -= ckey
|
|
if(holder)
|
|
holder.disassociate()
|
|
del(holder)
|
|
return 1 |