From 8fdc0a62454528cb4d744b6f21b377807b150ef5 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Wed, 25 Mar 2020 22:15:18 +0000 Subject: [PATCH] Adds a permission to only view runtimes (#13072) * Adds a permission to only view runtimes * It would appear I am half asleep * Almost failed my own CI tests there. good job AA --- code/__DEFINES/admin.dm | 5 +++-- code/__HELPERS/type2type.dm | 3 ++- code/modules/admin/admin_ranks.dm | 1 + code/modules/admin/admin_verbs.dm | 6 +++++- code/modules/admin/verbs/debug.dm | 2 +- config/example/admin_ranks.txt | 3 ++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/admin.dm b/code/__DEFINES/admin.dm index bbf394c6c0b..95494fb88cf 100644 --- a/code/__DEFINES/admin.dm +++ b/code/__DEFINES/admin.dm @@ -40,10 +40,11 @@ #define R_MOD 8192 #define R_MENTOR 16384 #define R_PROCCALL 32768 +#define R_VIEWRUNTIMES 65536 -#define R_MAXPERMISSION 32768 //This holds the maximum value for a permission. It is used in iteration, so keep it updated. +#define R_MAXPERMISSION 65536 //This holds the maximum value for a permission. It is used in iteration, so keep it updated. -#define R_HOST 65535 +#define R_HOST 131071 // Sum of all permissions to allow easy setting #define ADMIN_QUE(user,display) "[display]" #define ADMIN_FLW(user,display) "[display]" diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 661d09f0412..bf44f6a4bc9 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -167,7 +167,7 @@ return SOUTH if(225.6 to 315.5) return WEST - + //returns the north-zero clockwise angle in degrees, given a direction /proc/dir2angle(var/D) @@ -212,6 +212,7 @@ if(rights & R_PROCCALL) . += "[seperator]+PROCCALL" if(rights & R_MOD) . += "[seperator]+MODERATOR" if(rights & R_MENTOR) . += "[seperator]+MENTOR" + if(rights & R_VIEWRUNTIMES) . += "[seperator]+VIEWRUNTIMES" return . /proc/ui_style2icon(ui_style) diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm index f8a31f885ed..1986bd8f787 100644 --- a/code/modules/admin/admin_ranks.dm +++ b/code/modules/admin/admin_ranks.dm @@ -44,6 +44,7 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons if("mod") rights |= R_MOD if("mentor") rights |= R_MENTOR if("proccall") rights |= R_PROCCALL + if("viewruntimes") rights |= R_VIEWRUNTIMES GLOB.admin_ranks[rank] = rights previous_rights = rights diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 34929b52f53..a8e3f33aa2c 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -230,7 +230,9 @@ GLOBAL_LIST_INIT(admin_verbs_ticket, list( /client/proc/add_admin_verbs() if(holder) - verbs += GLOB.admin_verbs_default + // If they have ANYTHING OTHER THAN ONLY VIEW RUNTIMES (65536), then give them the default admin verbs + if(holder.rights != R_VIEWRUNTIMES) + verbs += GLOB.admin_verbs_default if(holder.rights & R_BUILDMODE) verbs += /client/proc/togglebuildmodeself if(holder.rights & R_ADMIN) @@ -264,6 +266,8 @@ GLOBAL_LIST_INIT(admin_verbs_ticket, list( verbs += GLOB.admin_verbs_mentor if(holder.rights & R_PROCCALL) verbs += GLOB.admin_verbs_proccall + if(holder.rights & R_VIEWRUNTIMES) + verbs += /client/proc/view_runtimes /client/proc/remove_admin_verbs() verbs.Remove( diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 5ec8ecde253..32dcf3daa7b 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -832,7 +832,7 @@ GLOBAL_PROTECT(AdminProcCaller) set name = "View Runtimes" set desc = "Open the Runtime Viewer" - if(!check_rights(R_DEBUG)) + if(!check_rights(R_DEBUG|R_VIEWRUNTIMES)) return GLOB.error_cache.showTo(usr) diff --git a/config/example/admin_ranks.txt b/config/example/admin_ranks.txt index c7d1cccef98..6f37f5bf234 100644 --- a/config/example/admin_ranks.txt +++ b/config/example/admin_ranks.txt @@ -23,7 +23,8 @@ # +SOUND (or +SOUNDS) = allows you to upload and play sounds # +SPAWN (or +CREATE) = mob transformations, spawning of most atoms including mobs (high-risk atoms, e.g. blackholes, will require the +FUN flag too) # +EVERYTHING (or +HOST or +ALL) = Simply gives you everything without having to type every flag - +# +VIEWRUNTIMES = Allows a player to view the runtimes of the server, but not use other debug verbs + # Admin Ranks Admin Observer Mentor +MENTOR