// // // /client/proc/debug_global_variable(var/S as text) set category = "Debug" set name = "View Global Variable" if( !src.holder || src.holder.level < LEVEL_CODER ) boutput( src, "Get down from there!!" ) return if (!S) boutput( src, "Can't enter null!!" ) return src.audit(AUDIT_VIEW_VARIABLES, "is viewing global variable [S]") var/body = {" "} var/V = global.vars[S] if (V == logs || V == logs["audit"]) src.audit(AUDIT_ACCESS_DENIED, "tried to access the logs datum for modification.") boutput(usr, "Yeah, no.") return if (V) body += debug_variable(S, V, V, 0) else boutput(usr, "Could not find [S] in the Global Variables list!!" ) return body += "
Var Value
" var/title = "[S][src.holder.level >= LEVEL_SHITGUY ? " (\ref[V])" : ""] - Refresh button doesn't work." //stole this from view_variables below var/html = {" [title] [Make_view_variabls_style()] Global Variable: [S]
Refresh
[body] "} if (src.holder.level >= LEVEL_CODER) html += " · Call Proc" usr << browse(html, "window=variables\ref[V];size=600x400") /client/proc/debug_variables(datum/D in world) set category = "Debug" set name = "View Variables" if( !src.holder || src.holder.level < LEVEL_PA ) src.audit(AUDIT_ACCESS_DENIED, "tried to use view variables while being below PA.") boutput( src, "Get down from there!!" ) return //set src in world if (!D) //Wire: Fix for runtime error: Cannot read null.type (datum having been deleted) return if(istype(D, /datum/configuration) || istype(D, /datum/admins)) boutput(src, "YEAH... no....") src.audit(AUDIT_ACCESS_DENIED, "tried to View-Variables a forbidden type([D.type])") return src.audit(AUDIT_VIEW_VARIABLES, "is viewing variables on [D]: [D.type] [istype(D, /atom) ? "at [D:x], [D:y], [D:z]" : ""]") var/title = "" var/body = "" if (istype(D, /atom)) var/atom/A = D title = "[A.name][src.holder.level >= LEVEL_SHITGUY ? " (\ref[A])" : ""] = [A.type]" #ifdef VARSICON if (A.icon) body += debug_variable("icon", new/icon(A.icon, A.icon_state, A.dir), 0) #endif if(D == "GLOB") title = "Global Variables" else title = "[D][src.holder.level >= LEVEL_SHITGUY ? " (\ref[D])" : ""] = [D.type]" body += {" "} var/list/names = list() if(D == "GLOB") for(var/V in global.vars) if(V != "logs") names += V else for (var/V in D.vars) if(!istype(D.vars[V], /datum/admins)) names += V names = sortList(names) if(D == "GLOB") for (var/V in names) body += debug_variable(V, global.vars[V], D, 0) else for (var/V in names) body += debug_variable(V, D.vars[V], D, 0) //body += debug_variable_link(V, D, (istype(D.vars[V], /datum) && src.holder.level >= LEVEL_CODER) ? 1 : 0) body += "
Var Value
" var/html = {" [title] [Make_view_variabls_style()] [title]
Refresh "} if (src.holder.level >= LEVEL_CODER && D != "GLOB") html += " · Call Proc" if (istype(D, /atom)) html += " · Jump To" if (ismob(D) || isobj(D)) html += " · Get (turf) · Get (loc)" if (ismob(D)) html += " · Player Options" html += {"
Direction: < 90° · < 45° · Set · 45° > · 90° >
[body] "} usr << browse(html, "window=variables\ref[D];size=600x400") return /client/proc/debug_variable_link(V, D, proccable) var/proctext = "" if (proccable) proctext = "· P" if (D != "GLOB") return {"
Edit · A · S [proctext]
"} else return {"
Edit ·
"} //Really, move this out to a .css file or something, too lazy and don't know how offhand /proc/Make_view_variabls_style() return {" "} /client/proc/debug_variable(name, value, var/fullvar, level) var/html = "" html += "" if (level == 0) html += "" html += debug_variable_link(name, fullvar, (istype(value, /datum) && src.holder.level >= LEVEL_CODER) ? 1 : 0) html += "" html += "" if (isnull(value)) html += "\[[name]\]null" else if (istext(value)) if(length(value) > 1000) html += "\[[name]\]\"[html_encode(copytext(value,1,1000))]...\"" else html += "\[[name]\]\"[html_encode(value)]\"" else if (isicon(value)) #ifdef VARSICON var/icon/I = new/icon(value) var/rnd = rand(1,10000) var/rname = "tmp\ref[I][rnd].png" usr << browse_rsc(I, rname) html += "\[[name]\]([value]) " #else html += "\[[name]\]/icon ([value])" #endif /* else if (istype(value, /image)) #ifdef VARSICON var/rnd = rand(1, 10000) var/image/I = value src << browse_rsc(I.icon, "tmp\ref[value][rnd].png") html += "[name]" #else html += "[name]/image ([value])" #endif */ else if (isfile(value)) html += "\[[name]\]file ([value])" else if (istype(value, /datum)) var/datum/D = value var/dname = null if ("name" in D.vars) dname = " (" + html_encode( "[D.vars["name"]]" ) + ")" html += "\[[name]\][dname] ([D.type][src.holder.level >= LEVEL_SHITGUY ? " \ref[value]" : ""])" else if (isclient(value)) var/client/C = value html += "\[[name]\][C] ([C.type][src.holder.level >= LEVEL_SHITGUY ? " \ref[value]" : ""])" else if (islist(value)) var/list/L = value html += "\[[name]\]List ([(!isnull(L) && L.len > 0) ? "[L.len] items" : "empty"])" if (!isnull(L) && L.len > 0 && !(name == "underlays" || name == "overlays" || name == "vars" || name == "verbs" || L.len > 100)) // not sure if this is completely right... //if (0) // (L.vars.len > 0) // html += "
    " // for (var/entry in L) // html += debug_variable(entry, L[entry], level + 1) // html += "
" html += "" for (var/index = 1, index <= L.len, index++) if (name != "contents" && name != "screen" && name != "vis_contents" && name != "vis_locs" && !isnum(L[index]) && L["[L[index]]"]) html += debug_variable(L[index], L[L[index]], value, level + 1) else html += debug_variable("[index]", L[index], value, level + 1) html += "
IdxValue
" else html += "\[[name]\][html_encode("[value]")]" html += "" return html /client/Topic(href, href_list, hsrc) if (href_list["Refresh"]) usr_admin_only src.debug_variables(locate(href_list["Refresh"])) if (href_list["Refresh-Global-Var"]) usr_admin_only src.debug_variable(locate(href_list["Refresh-Global-Var"])) // src.debug_variable(S, V, V, 0) if (href_list["JumpToThing"]) usr_admin_only var/atom/A = locate(href_list["JumpToThing"]) if (istype(A)) src.jumptoturf(get_turf(A)) return if (href_list["GetThing"]) usr_admin_only var/atom/A = locate(href_list["GetThing"]) if (ismob(A) || isobj(A)) src.cmd_admin_get_mobject(A) return if (href_list["GetThing_Insert"]) usr_admin_only var/atom/A = locate(href_list["GetThing_Insert"]) if (ismob(A) || isobj(A)) src.cmd_admin_get_mobject_loc(A) return if (href_list["PlayerOptions"]) usr_admin_only var/mob/M = locate(href_list["PlayerOptions"]) if (istype(M)) src.holder.playeropt(M) return if (href_list["SetDirection"]) usr_admin_only var/atom/A = locate(href_list["SetDirection"]) if (istype(A)) var/new_dir = href_list["DirectionToSet"] if (new_dir == "L90") A.dir = turn(A.dir, 90) boutput(src, "Turned [A] 90° to the left: direction is now [uppertext(dir2text(A.dir))].") else if (new_dir == "L45") A.dir = turn(A.dir, 45) boutput(src, "Turned [A] 45° to the left: direction is now [uppertext(dir2text(A.dir))].") else if (new_dir == "R90") A.dir = turn(A.dir, -90) boutput(src, "Turned [A] 90° to the right: direction is now [uppertext(dir2text(A.dir))].") else if (new_dir == "R45") A.dir = turn(A.dir, -45) boutput(src, "Turned [A] 45° to the right: direction is now [uppertext(dir2text(A.dir))].") else var/list/english_dirs = list("NORTH", "NORTHEAST", "EAST", "SOUTHEAST", "SOUTH", "SOUTHWEST", "WEST", "NORTHWEST") new_dir = input(src, "Choose a direction for [A] to face.", "Selection", "NORTH") as null|anything in english_dirs if (new_dir) A.dir = text2dir(new_dir) boutput(src, "Set [A]'s direction to [new_dir]") return if (href_list["CallProc"]) usr_admin_only if(holder && src.holder.level >= LEVEL_CODER) doCallProc(locate(href_list["CallProc"])) else audit(AUDIT_ACCESS_DENIED, "tried to call a proc on something all rude-like.") return if (href_list["Vars"]) usr_admin_only if (href_list["varToEdit"]) modify_variable(locate(href_list["Vars"]), href_list["varToEdit"]) else if (href_list["varToEditAll"]) modify_variable(locate(href_list["Vars"]), href_list["varToEditAll"], 1) else if (href_list["setAll"]) set_all(locate(href_list["Vars"]), href_list["setAll"]) else if (href_list["procCall"]) var/datum/D = locate(href_list["Vars"]) if (D) var/datum/C = D.vars[href_list["procCall"]] if (istype(C, /datum)) doCallProc(C) else debug_variables(locate(href_list["Vars"])) else ..() /client/proc/set_all(datum/D, variable, val) if(!variable || !D || !(variable in D.vars)) return if(variable == "holder") boutput(src, "Access denied.") return if(!isadmin(src)) boutput(src, "Only administrators may use this command.") return var/var_value = D.vars[variable] if(istype(D, /client)) for(var/client/c) c:vars[variable] = var_value else for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = var_value LAGCHECK(LAG_LOW) /client/proc/modify_variable(datum/D, variable, set_global = 0) if(D != "GLOB" && (!variable || !D || !(variable in D.vars))) return var/list/locked = list("vars", "key", "ckey", "client", "holder") if(!isadmin(src)) boutput(src, "Only administrators may use this command.") return var/default var/var_value = D == "GLOB" ? global.vars[variable] : D.vars[variable] if( istype(var_value, /datum/admins) || istype(D, /datum/admins) || var_value == logs || var_value == logs["audit"] ) src.audit(AUDIT_ACCESS_DENIED, "tried to assign a value to a forbidden variable.") boutput(src, "You can't set that value.") return var/dir if (locked.Find(variable) && !(src.holder.rank in list("Host", "Coder", "Shit Person"))) boutput(usr, "You do not have access to edit this variable!") return //Let's prevent people from promoting themselves, yes? var/list/locked_type = list(/datum/admins) //Short list - might be good if there are more objects that oughta be paws-off if(D != "GLOB" && (D.type == /datum/configuration || (!(src.holder.rank in list("Host", "Coder")) && D.type in locked_type ))) boutput(usr, "You're not allowed to edit [D.type] for security reasons!") logTheThing("admin", usr, null, "tried to varedit [D.type] but was denied!") logTheThing("diary", usr, null, "tried to varedit [D.type] but was denied!", "admin") message_admins("[key_name(usr)] tried to varedit [D.type] but was denied.") //If someone tries this let's make sure we all know it. return if (isnull(var_value)) boutput(usr, "Unable to determine variable type.") else if (isnum(var_value)) boutput(usr, "Variable appears to be NUM.") default = "num" dir = 1 else if (is_valid_color_string(var_value)) boutput(usr, "Variable appears to be COLOR.") default = "color" else if (istext(var_value)) boutput(usr, "Variable appears to be TEXT.") default = "text" else if (isloc(var_value)) boutput(usr, "Variable appears to be REFERENCE.") default = "reference" else if (isicon(var_value)) boutput(usr, "Variable appears to be ICON.") //var_value = "[bicon(var_value)]" default = "icon" else if (istype(var_value,/atom) || istype(var_value,/datum)) boutput(usr, "Variable appears to be TYPE.") default = "type" else if (islist(var_value)) boutput(usr, "Variable appears to be LIST.") default = "list" else if (isclient(var_value)) boutput(usr, "Variable appears to be CLIENT.") default = "cancel" else boutput(usr, "Variable appears to be FILE.") default = "file" boutput(usr, "\"[variable]\" contains: [var_value]") if(dir) switch(var_value) if(1) dir = "NORTH" if(2) dir = "SOUTH" if(4) dir = "EAST" if(8) dir = "WEST" if(5) dir = "NORTHEAST" if(6) dir = "SOUTHEAST" if(9) dir = "NORTHWEST" if(10) dir = "SOUTHWEST" else dir = null if(dir) boutput(usr, "If a direction, direction is: [dir]") var/class = input("What kind of variable?","Variable Type",default) as null|anything in list("text", "num","type","reference","mob reference","turf by coordinates","reference picker","new instance of a type","icon","file","color","list","edit referenced object","create new list","null", "ref", "restore to default") if(!class) return var/original_name if(D == "GLOB") original_name = "Global Variable" else if (!istype(D, /atom)) original_name = "[src.holder.level >= LEVEL_SHITGUY ? "\ref[D] " : ""]([D])" else original_name = D:name var/oldVal = D == "GLOB" ? global.vars[variable] : D.vars[variable] switch(class) if("null") if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = null LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = null else D.vars[variable] = null if("ref") if (!(src.holder.rank in list("Host", "Coder", "Shit Person"))) boutput( src, "This can super break shit so you can't use this. Sorry. ") return var/theref = input("What ref?") as null|text if(theref) var/thing = locate(theref) if(!thing) thing = locate("\[[theref]\]") if(!thing) boutput(src, "Bad ref or couldn't find that thing. Drats.") return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = thing LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = thing else D.vars[variable] = thing if("list") if(D == "GLOB") mod_list(global.vars[variable]) else mod_list(D.vars[variable]) //return <- Way to screw up logging if("restore to default") if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = initial(x:vars[variable]) LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = initial(global.vars[variable]) else D.vars[variable] = initial(D.vars[variable]) if("edit referenced object") if(D == "GLOB") return .(global.vars[variable]) else return .(D.vars[variable]) if("create new list") if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = list() LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = list() else D.vars[variable] = list() if("text") var/theInput = input("Enter new text:","[variable]", D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|message if(theInput == null) return if(set_global) if(isclient(D)) for(var/client/x) x:vars[variable] = theInput LAGCHECK(LAG_LOW) else for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("num") var/theInput = input("Enter new number:","[variable]", D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|num if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("type") var/theInput = input("Enter type:","[variable]",D == "GLOB" ? global.vars[variable] : D.vars[variable]) in null|typesof(/obj,/mob,/area,/turf) if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("reference") var/theInput = input("Select reference:","[variable]", D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|mob|obj|turf|area in world if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("mob reference") var/theInput = input("Select reference:","[variable]", D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|mob in world if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("file") var/theInput = input("Pick file:","[variable]",D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|file if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("icon") var/theInput = input("Pick icon:","[variable]",D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|icon if(theInput == null) return if(set_global) for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("color") var/theInput = input("Pick color:","[variable]",D == "GLOB" ? global.vars[variable] : D.vars[variable]) as null|color if(theInput == null) return if(set_global) if(isclient(D)) for(var/client/x) x:vars[variable] = theInput LAGCHECK(LAG_LOW) else for(var/x in world) if(!istype(x, D.type)) continue x:vars[variable] = theInput LAGCHECK(LAG_LOW) else if(D == "GLOB") global.vars[variable] = theInput else D.vars[variable] = theInput if("turf by coordinates") var/x = input("X coordinate", "Set to turf at \[_, ?, ?\]", 1) as num var/y = input("Y coordinate", "Set to turf at \[[x], _, ?\]", 1) as num var/z = input("Z coordinate", "Set to turf at \[[x], [y], _\]", 1) as num var/turf/T = locate(x, y, z) if (istype(T)) if (set_global) for (var/datum/q in world) LAGCHECK(LAG_LOW) if (!istype(q, D.type)) continue q.vars[variable] = T else if(D == "GLOB") global.vars[variable] = T else D.vars[variable] = T else boutput(usr, "Invalid coordinates!") return if("reference picker") boutput(usr, "Click the mob, object or turf to use as a reference.") var/mob/M = usr if (istype(M)) var/datum/targetable/refpicker/R if (set_global) R = new /datum/targetable/refpicker/global() else R = new() R.target = D R.varname = variable M.targeting_spell = R M.update_cursor() return if ("new instance of a type") boutput(usr, "Type part of the path of type of thing to instantiate.") var/typename = input("Part of type path.", "Part of type path.", "/obj") as null|text if (typename) var/basetype = /obj if (src.holder.rank in list("Host", "Coder", "Shit Person")) basetype = /datum var/match = get_one_match(typename, basetype) if (match) if (set_global) for (var/datum/x in world) LAGCHECK(LAG_LOW) if (!istype(x, D.type)) continue x.vars[variable] = new match(x) else if(D == "GLOB") global.vars[variable] = new match() else D.vars[variable] = new match(D) else return logTheThing("admin", src, null, "modified [original_name]'s [variable] to [D == "GLOB" ? global.vars[variable] : D.vars[variable]]" + (set_global ? " on all entities of same type" : "")) logTheThing("diary", src, null, "modified [original_name]'s [variable] to [D == "GLOB" ? global.vars[variable] : D.vars[variable]]" + (set_global ? " on all entities of same type" : ""), "admin") message_admins("[key_name(src)] modified [original_name]'s [variable] to [D == "GLOB" ? global.vars[variable] : D.vars[variable]]" + (set_global ? " on all entities of same type" : ""), 1) SPAWN_DBG(0) if (istype(D, /datum)) D.onVarChanged(variable, oldVal, D.vars[variable]) src.debug_variables(D) /mob/proc/Delete(atom/A in view()) set category = "Debug" switch (alert("Are you sure you wish to delete \the [A.name] at ([A.x],[A.y],[A.z]) ?", "Admin Delete Object","Yes","No")) if("Yes") logTheThing("admin", usr, null, "deleted [A.name] at ([showCoords(A.x, A.y, A.z)])") logTheThing("diary", usr, null, "deleted [A.name] at ([showCoords(A.x, A.y, A.z, 1)])", "admin")