From 96cb824895dadc2f9ca98a7d208bd7f57a1f53d5 Mon Sep 17 00:00:00 2001 From: atermonera Date: Thu, 22 Apr 2021 19:16:07 -0900 Subject: [PATCH] Adds verb to VV global variables --- code/controllers/globals.dm | 2 +- code/datums/datumvars.dm | 2 +- code/modules/admin/admin_verb_lists.dm | 16 +- code/modules/admin/view_variables/helpers.dm | 191 ++++++++++++++++++ .../view_variables/helpers_deprecated.dm | 48 ----- .../admin/view_variables/view_variables.dm | 3 +- .../view_variables/view_variables_global.dm | 91 +++++++++ polaris.dme | 3 +- 8 files changed, 297 insertions(+), 59 deletions(-) create mode 100644 code/modules/admin/view_variables/helpers.dm delete mode 100644 code/modules/admin/view_variables/helpers_deprecated.dm create mode 100644 code/modules/admin/view_variables/view_variables_global.dm diff --git a/code/controllers/globals.dm b/code/controllers/globals.dm index 56a9244347..5ceec9978d 100644 --- a/code/controllers/globals.dm +++ b/code/controllers/globals.dm @@ -36,7 +36,7 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars) if(!statclick) statclick = new/obj/effect/statclick/debug(null, "Initializing...", src) - stat("Globals:", statclick.update("Edit")) + stat("GLOB:", statclick.update("Edit")) /datum/controller/global_vars/vv_edit_var(var_name, var_value) if(gvars_datum_protected_varlist[var_name]) diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index 95db63ff33..cfd9107898 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -15,7 +15,7 @@ switch(var_name) if ("vars") return debug_variable(var_name, list(), 0, src) - return debug_variable(var_name, vars[var_name], 0, src) + return debug_variable(var_name, get_variable_value(var_name), 0, src) //please call . = ..() first and append to the result, that way parent items are always at the top and child items are further down //add separaters by doing . += "---" diff --git a/code/modules/admin/admin_verb_lists.dm b/code/modules/admin/admin_verb_lists.dm index 3fa8903f72..81f27842b2 100644 --- a/code/modules/admin/admin_verb_lists.dm +++ b/code/modules/admin/admin_verb_lists.dm @@ -106,7 +106,8 @@ var/list/admin_verbs_admin = list( /client/proc/fixatmos, /datum/admins/proc/sendFax, /client/proc/despawn_player, - /datum/admins/proc/view_feedback + /datum/admins/proc/view_feedback, + /client/proc/debug_global_variables ) var/list/admin_verbs_ban = list( @@ -183,7 +184,8 @@ var/list/admin_verbs_server = list( /client/proc/recipe_dump, /client/proc/panicbunker, /client/proc/paranoia_logging, - /client/proc/ip_reputation + /client/proc/ip_reputation, + /client/proc/debug_global_variables ) var/list/admin_verbs_debug = list( @@ -231,7 +233,8 @@ var/list/admin_verbs_debug = list( /datum/admins/proc/change_time, /client/proc/admin_give_modifier, /client/proc/simple_DPS, - /datum/admins/proc/view_feedback + /datum/admins/proc/view_feedback, + /client/proc/debug_global_variables ) var/list/admin_verbs_paranoid_debug = list( @@ -325,7 +328,8 @@ var/list/admin_verbs_hideable = list( /client/proc/roll_dices, /proc/possess, /proc/release, - /datum/admins/proc/set_tcrystals + /datum/admins/proc/set_tcrystals, + /client/proc/debug_global_variables ) var/list/admin_verbs_mod = list( /client/proc/cmd_admin_pm_context, //right-click adminPM interface, @@ -486,8 +490,8 @@ var/list/admin_verbs_event_manager = list( /client/proc/cmd_admin_delete, //delete an instance/object/mob/etc, /client/proc/cmd_debug_del_all, /client/proc/toggle_random_events, - /client/proc/modify_server_news - + /client/proc/modify_server_news, + /client/proc/debug_global_variables ) /client/proc/add_admin_verbs() diff --git a/code/modules/admin/view_variables/helpers.dm b/code/modules/admin/view_variables/helpers.dm new file mode 100644 index 0000000000..e9d9337cf4 --- /dev/null +++ b/code/modules/admin/view_variables/helpers.dm @@ -0,0 +1,191 @@ + +// Keep these two together, they *must* be defined on both +// If /client ever becomes /datum/client or similar, they can be merged +/datum/proc/get_view_variables_header() + return "[src]" + +/atom/get_view_variables_header() + return {" + [src] +
+ << + [dir2text(dir)] + >> + + "} + +/mob/living/get_view_variables_header() + return {" + [src] +
<< [dir2text(dir)] >> +
[ckey ? ckey : "No ckey"] / [real_name ? real_name : "No real name"] +
+ BRUTE:[getBruteLoss()] + FIRE:[getFireLoss()] + TOXIN:[getToxLoss()] + OXY:[getOxyLoss()] + CLONE:[getCloneLoss()] + BRAIN:[getBrainLoss()] +
+ "} + +//This entire file needs to be removed eventually +/datum/proc/get_view_variables_options() + return "" + +/mob/get_view_variables_options() + return ..() + {" + + + + + + + + + + + + + + + + + + + + + + + + + + + + "} + +/mob/living/carbon/human/get_view_variables_options() + return ..() + {" + + + + + + "} + +/obj/get_view_variables_options() + return ..() + {" + + "} + +/turf/get_view_variables_options() + return ..() + {" + + + "} + +/datum/proc/get_variables() + . = vars - VV_hidden() + if(!usr || !check_rights(R_ADMIN|R_DEBUG, FALSE)) + . -= VV_secluded() + +/datum/proc/get_variable_value(varname) + return vars[varname] + +/datum/proc/set_variable_value(varname, value) + vars[varname] = value + +/datum/proc/get_initial_variable_value(varname) + return initial(vars[varname]) + +/datum/proc/make_view_variables_variable_entry(var/varname, var/value, var/hide_watch = 0) + return {" + (E) + (C) + (M) + [hide_watch ? "" : "(W)"] + "} + +// No mass editing of clients +/client/make_view_variables_variable_entry(var/varname, var/value, var/hide_watch = 0) + return {" + (E) + (C) + [hide_watch ? "" : "(W)"] + "} + +// These methods are all procs and don't use stored lists to avoid VV exploits + +// The following vars cannot be viewed by anyone +/datum/proc/VV_hidden() + return list() + +// The following vars can only be viewed by R_ADMIN|R_DEBUG +/datum/proc/VV_secluded() + return list() + +/datum/configuration/VV_secluded() + return vars + +// The following vars cannot be edited by anyone +/datum/proc/VV_static() + return list("parent_type") + +/atom/VV_static() + return ..() + list("bound_x", "bound_y", "bound_height", "bound_width", "bounds", "step_x", "step_y", "step_size") + +/client/VV_static() + return ..() + list("holder", "prefs") + +/datum/admins/VV_static() + return vars + +// The following vars require R_DEBUG to edit +/datum/proc/VV_locked() + return list("vars", "cuffed") + +/client/VV_locked() + return list("vars", "mob") + +/mob/VV_locked() + return ..() + list("client") + +// The following vars require R_FUN|R_DEBUG to edit +/datum/proc/VV_icon_edit_lock() + return list() + +/atom/VV_icon_edit_lock() + return ..() + list("icon", "icon_state", "overlays", "underlays") + +// The following vars require R_SPAWN|R_DEBUG to edit +/datum/proc/VV_ckey_edit() + return list() + +/mob/VV_ckey_edit() + return list("key", "ckey") + +/client/VV_ckey_edit() + return list("key", "ckey") + +/datum/proc/may_edit_var(var/user, var/var_to_edit) + if(!user) + return FALSE + if(!(var_to_edit in vars)) + to_chat(user, "\The [src] does not have a var '[var_to_edit]'") + return FALSE + if(var_to_edit in VV_static()) + return FALSE + if((var_to_edit in VV_secluded()) && !check_rights(R_ADMIN|R_DEBUG, FALSE, C = user)) + return FALSE + if((var_to_edit in VV_locked()) && !check_rights(R_DEBUG, C = user)) + return FALSE + if((var_to_edit in VV_ckey_edit()) && !check_rights(R_SPAWN|R_DEBUG, C = user)) + return FALSE + if((var_to_edit in VV_icon_edit_lock()) && !check_rights(R_FUN|R_DEBUG, C = user)) + return FALSE + return TRUE + +/proc/forbidden_varedit_object_types() + return list( + /datum/admins //Admins editing their own admin-power object? Yup, sounds like a good idea. + ) \ No newline at end of file diff --git a/code/modules/admin/view_variables/helpers_deprecated.dm b/code/modules/admin/view_variables/helpers_deprecated.dm deleted file mode 100644 index 1a7e44d4a5..0000000000 --- a/code/modules/admin/view_variables/helpers_deprecated.dm +++ /dev/null @@ -1,48 +0,0 @@ -//This entire file needs to be removed eventually -/datum/proc/get_view_variables_options() - return "" - -/mob/get_view_variables_options() - return ..() + {" - - - - - - - - - - - - - - - - - - - - - - - - - - - - "} - -/mob/living/carbon/human/get_view_variables_options() - return ..() + {" - - - - - - "} - -/obj/get_view_variables_options() - return ..() + {" - - "} diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index 767d693abd..1d52941f47 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -78,8 +78,7 @@ var/list/names = list() if (!islist) - for (var/V in D.vars) - names += V + names = D.get_variables() sleep(1)//For some reason, without this sleep, VVing will cause client to disconnect on certain objects. var/list/variable_html = list() diff --git a/code/modules/admin/view_variables/view_variables_global.dm b/code/modules/admin/view_variables/view_variables_global.dm new file mode 100644 index 0000000000..1f6f2d52d6 --- /dev/null +++ b/code/modules/admin/view_variables/view_variables_global.dm @@ -0,0 +1,91 @@ +/proc/readglobal(which) + . = global.vars[which] + +/proc/writeglobal(which, newval) + global.vars[which] = newval + +/proc/getallglobals() + . = list() + for(var/some_global in global.vars) + . += some_global + +/var/decl/global_vars/global_vars_ + +/decl/global_vars + var/name = "Global Variables" + +/decl/global_vars/get_view_variables_options() + return "" // Ensuring changes to the base proc never affect us + +/decl/global_vars/get_variables() + . = getallglobals() - VV_hidden() + if(!usr || !check_rights(R_ADMIN|R_DEBUG, FALSE)) + . -= VV_secluded() + +/decl/global_vars/get_variable_value(varname) + return readglobal(varname) + +/decl/global_vars/set_variable_value(varname, value) + writeglobal(varname, value) + +/decl/global_vars/make_view_variables_variable_entry(varname, value) + return "(E) " + +/decl/global_vars/VV_locked() + return vars + +/decl/global_vars/VV_hidden() + return list( + "forumsqladdress", + "forumsqldb", + "forumsqllogin", + "forumsqlpass", + "forumsqlport", + "sqladdress", + "sqldb", + "sqllogin", + "sqlpass", + "sqlport", + "comms_password", + "ban_comms_password", + "login_export_addr", + "admin_verbs_default", + "admin_verbs_admin", + "admin_verbs_ban", + "admin_verbs_sounds", + "admin_verbs_fun", + "admin_verbs_spawn", + "admin_verbs_server", + "admin_verbs_debug", + "admin_verbs_paranoid_debug", + "admin_verbs_possess", + "admin_verbs_permissions", + "admin_verbs_rejuv", + "admin_verbs_hideable", + "admin_verbs_mod", + "admin_verbs_event_manager", + "adminProcCallCount", + "adminProcCaller", + "AdminProcCallSpamPrevention", + "admins", + "admin_datums", + "admin_log", + "admin_ranks", + "admin_state", + "alien_whitelist", + "alldirs", + "ahelp_tickets", + "adminfaxes", + "adminlogs", + "cardinal", + "cardinalz", + "IClog" + ) + +/client/proc/debug_global_variables() + set category = "Debug" + set name = "View Global Variables" + + if(!global_vars_) + global_vars_ = new() + debug_variables(global_vars_) \ No newline at end of file diff --git a/polaris.dme b/polaris.dme index e2aea3d736..4f44e273d0 100644 --- a/polaris.dme +++ b/polaris.dme @@ -1444,12 +1444,13 @@ #include "code\modules\admin\view_variables\admin_delete.dm" #include "code\modules\admin\view_variables\debug_variables.dm" #include "code\modules\admin\view_variables\get_variables.dm" -#include "code\modules\admin\view_variables\helpers_deprecated.dm" +#include "code\modules\admin\view_variables\helpers.dm" #include "code\modules\admin\view_variables\mass_edit_variables.dm" #include "code\modules\admin\view_variables\modify_variables.dm" #include "code\modules\admin\view_variables\topic.dm" #include "code\modules\admin\view_variables\topic_list.dm" #include "code\modules\admin\view_variables\view_variables.dm" +#include "code\modules\admin\view_variables\view_variables_global.dm" #include "code\modules\ai\_defines.dm" #include "code\modules\ai\ai_holder.dm" #include "code\modules\ai\ai_holder_combat.dm"