Merge pull request #7790 from tigercat2000/vv_improved

VV Refactor & Upgrade
This commit is contained in:
Crazy Lemon
2017-09-17 15:13:04 -07:00
committed by GitHub
21 changed files with 1564 additions and 1161 deletions
+6
View File
@@ -100,3 +100,9 @@ you will have to do something like if(client.holder.rights & R_ADMIN) yourself.
return 0
return 1
return 0
/datum/admins/vv_edit_var(var_name, var_value)
return FALSE // no admin abuse
/datum/admins/can_vv_delete()
return FALSE // don't break shit either
+9 -14
View File
@@ -89,8 +89,12 @@
if("delete")
for(var/d in objs)
if(!datum_is_forbidden(d))
qdel(d)
if(istype(d, /datum))
var/datum/D = d
if(!D.can_vv_delete())
to_chat(usr, "[D] rejected your deletion")
continue
qdel(d)
if("select")
var/text = ""
@@ -118,9 +122,6 @@
if("set" in query_tree)
var/list/set_list = query_tree["set"]
for(var/d in objs)
// Forbid explicitly modifying an admin datum's vars
if(datum_is_forbidden(d))
return
for(var/list/sets in set_list)
var/datum/temp = d
var/i = 0
@@ -128,11 +129,10 @@
if(++i == sets.len)
if(istype(temp, /turf) && (v == "x" || v == "y" || v == "z"))
continue
if(!datum_is_forbidden(temp.vars[v]))
return
temp.vars[v] = SDQL_expression(d, set_list[sets])
if(!temp.vv_edit_var(v, SDQL_expression(d, set_list[sets])))
to_chat(usr, "[temp] rejected your varedit.")
break
if(temp.vars.Find(v) && (istype(temp.vars[v], /datum) || istype(temp.vars[v], /client)) && !datum_is_forbidden(temp.vars[v]))
if(temp.vars.Find(v) && (istype(temp.vars[v], /datum) || istype(temp.vars[v], /client)))
temp = temp.vars[v]
else
break
@@ -440,11 +440,6 @@
for(var/arg in arguments)
new_args[++new_args.len] = SDQL_expression(source, arg)
for(var/p in forbidden_varedit_object_types)
if(istype(object, p))
to_chat(usr, "<span class='warning'>It is forbidden to run this object's procs.</span>")
return
if(object == world) // Global proc.
procname = "/proc/[procname]"
return call(procname)(arglist(new_args))
+207 -316
View File
@@ -22,360 +22,251 @@
src.massmodify_variables(A, var_name, method)
feedback_add_details("admin_verb","MEV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/massmodify_variables(var/atom/O, var/var_name = "", var/method = 0)
if(!check_rights(R_VAREDIT)) return
var/list/locked = list("vars", "key", "ckey", "client")
for(var/p in forbidden_varedit_object_types)
if( istype(O,p) )
to_chat(usr, "<span class='danger'>It is forbidden to edit this object's variables.</span>")
return
var/list/names = list()
for(var/V in O.vars)
names += V
names = sortList(names)
/client/proc/massmodify_variables(datum/O, var_name = "", method = 0)
if(!check_rights(R_VAREDIT))
return
if(!istype(O))
return
var/variable = ""
if(!var_name)
variable = input("Which var?","Var") as null|anything in names
var/list/names = list()
for(var/V in O.vars)
names += V
names = sortList(names)
variable = input("Which var?", "Var") as null|anything in names
else
variable = var_name
if(!variable) return
if(!variable || !O.can_vv_get(variable))
return
var/default
var/var_value = O.vars[variable]
var/dir
if(variable == "holder" || (variable in locked))
if(!check_rights(R_DEBUG)) return
if(variable in VVckey_edit)
to_chat(src, "It's forbidden to mass-modify ckeys. It'll crash everyone's client you dummy.")
return
if(variable in VVlocked)
if(!check_rights(R_DEBUG))
return
if(variable in VVicon_edit_lock)
if(!check_rights(R_EVENT | R_DEBUG))
return
if(variable in VVpixelmovement)
if(!check_rights(R_DEBUG))
return
var/prompt = alert(src, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT ", "Continue", " ABORT")
if(prompt != "Continue")
return
if(isnull(var_value))
to_chat(usr, "Unable to determine variable type.")
else if(isnum(var_value))
to_chat(usr, "Variable appears to be <b>NUM</b>.")
default = "num"
dir = 1
else if(istext(var_value))
to_chat(usr, "Variable appears to be <b>TEXT</b>.")
default = "text"
else if(isloc(var_value))
to_chat(usr, "Variable appears to be <b>REFERENCE</b>.")
default = "reference"
else if(isicon(var_value))
to_chat(usr, "Variable appears to be <b>ICON</b>.")
var_value = "[bicon(var_value)]"
default = "icon"
else if(istype(var_value,/atom) || istype(var_value,/datum))
to_chat(usr, "Variable appears to be <b>TYPE</b>.")
default = "type"
else if(istype(var_value,/list))
to_chat(usr, "Variable appears to be <b>LIST</b>.")
default = "list"
else if(istype(var_value,/client))
to_chat(usr, "Variable appears to be <b>CLIENT</b>.")
default = "cancel"
default = vv_get_class(var_value)
if(isnull(default))
to_chat(src, "Unable to determine variable type.")
else
to_chat(usr, "Variable appears to be <b>FILE</b>.")
default = "file"
to_chat(src, "Variable appears to be <b>[uppertext(default)]</b>.")
to_chat(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)
to_chat(usr, "If a direction, direction is: [dir]")
to_chat(src, "Variable contains: [var_value]")
var/class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
"num","type","icon","file","edit referenced object","restore to default")
if(default == VV_NUM)
var/dir_text = ""
if(dir < 0 && dir < 16)
if(dir & 1)
dir_text += "NORTH"
if(dir & 2)
dir_text += "SOUTH"
if(dir & 4)
dir_text += "EAST"
if(dir & 8)
dir_text += "WEST"
if(!class)
if(dir_text)
to_chat(src, "If a direction, direction is: [dir_text]")
var/value = vv_get_value(default_class = default)
var/new_value = value["value"]
var/class = value["class"]
if(!class || !new_value == null && class != VV_NULL)
return
var/original_name
if(class == VV_MESSAGE)
class = VV_TEXT
if(!istype(O, /atom))
original_name = "\ref[O] ([O])"
else
original_name = O:name
if(value["type"])
class = VV_NEW_TYPE
var/original_name = "[O]"
var/rejected = 0
var/accepted = 0
switch(class)
if(VV_RESTORE_DEFAULT)
to_chat(src, "Finding items...")
var/list/items = get_all_of_type(O.type, method)
to_chat(src, "Changing [items.len] items...")
for(var/thing in items)
if(!thing)
continue
var/datum/D = thing
if(D.vv_edit_var(variable, initial(D.vars[variable])) != FALSE)
accepted++
else
rejected++
CHECK_TICK
if("restore to default")
O.vars[variable] = initial(O.vars[variable])
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if( istype(M , O.type) )
M.vars[variable] = O.vars[variable]
M.on_varedit(variable)
if(VV_TEXT)
var/list/varsvars = vv_parse_text(O, new_value)
var/pre_processing = new_value
var/unique
if(varsvars && varsvars.len)
unique = alert(usr, "Process vars unique to each instance, or same for all?", "Variable Association", "Unique", "Same")
if(unique == "Unique")
unique = TRUE
else
unique = FALSE
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[O.vars[V]]")
else if(istype(O, /obj))
for(var/obj/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
A.on_varedit(variable)
to_chat(src, "Finding items...")
var/list/items = get_all_of_type(O.type, method)
to_chat(src, "Changing [items.len] items...")
for(var/thing in items)
if(!thing)
continue
var/datum/D = thing
if(unique)
new_value = pre_processing
for(var/V in varsvars)
new_value = replacetext(new_value,"\[[V]]","[D.vars[V]]")
else if(istype(O, /turf))
for(var/turf/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
A.on_varedit(variable)
if(D.vv_edit_var(variable, new_value) != FALSE)
accepted++
else
rejected++
CHECK_TICK
if(VV_NEW_TYPE)
var/many = alert(src, "Create only one [value["type"]] and assign each or a new one for each thing", "How Many", "One", "Many", "Cancel")
if(many == "Cancel")
return
if(many == "Many")
many = TRUE
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if(M.type == O.type)
M.vars[variable] = O.vars[variable]
M.on_varedit(variable)
many = FALSE
else if(istype(O, /obj))
for(var/obj/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
A.on_varedit(variable)
var/type = value["type"]
to_chat(src, "Finding items...")
var/list/items = get_all_of_type(O.type, method)
to_chat(src, "Changing [items.len] items...")
for(var/thing in items)
if(!thing)
continue
var/datum/D = thing
if(many && !new_value)
new_value = new type()
else if(istype(O, /turf))
for(var/turf/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
A.on_varedit(variable)
if(D.vv_edit_var(variable, new_value) != FALSE)
accepted++
else
rejected++
new_value = null
CHECK_TICK
if("edit referenced object")
return .(O.vars[variable])
else
to_chat(src, "Finding items...")
var/list/items = get_all_of_type(O.type, method)
to_chat(src, "Changing [items.len] items...")
for(var/thing in items)
if(!thing)
continue
var/datum/D = thing
if(D.vv_edit_var(variable, new_value) != FALSE)
accepted++
else
rejected++
CHECK_TICK
if("text")
var/new_value = input("Enter new text:","Text",O.vars[variable]) as message|null
if(new_value == null) return
O.vars[variable] = new_value
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if( istype(M , O.type) )
M.vars[variable] = O.vars[variable]
var/count = rejected+accepted
if(!count)
to_chat(src, "No objects found")
return
if(!accepted)
to_chat(src, "Every object rejected your edit")
return
if(rejected)
to_chat(src, "[rejected] out of [count] objects rejected your edit")
else if(istype(O, /obj))
for(var/obj/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
log_to_dd("### MassVarEdit by [src]: [O.type] (A/R [accepted]/[rejected]) [variable]=[html_encode("[O.vars[variable]]")]([list2params(value)])")
log_admin("[key_name(src)] mass modified [original_name]'s [variable] to [O.vars[variable]] ([accepted] objects modified)")
message_admins("[key_name_admin(src)] mass modified [original_name]'s [variable] to [O.vars[variable]] ([accepted] objects modified)")
else if(istype(O, /turf))
for(var/turf/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if(M.type == O.type)
M.vars[variable] = O.vars[variable]
/proc/get_all_of_type(var/T, subtypes = TRUE)
var/list/typecache = list()
typecache[T] = 1
if(subtypes)
typecache = typecacheof(typecache)
. = list()
if(ispath(T, /mob))
for(var/mob/thing in mob_list)
if(typecache[thing.type])
. += thing
CHECK_TICK
else if(istype(O, /obj))
for(var/obj/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(ispath(T, /obj/machinery/door))
for(var/obj/machinery/door/thing in airlocks)
if(typecache[thing.type])
. += thing
CHECK_TICK
else if(istype(O, /turf))
for(var/turf/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(ispath(T, /obj/machinery))
for(var/obj/machinery/thing in machines)
if(typecache[thing.type])
. += thing
CHECK_TICK
if("num")
var/new_value = input("Enter new number:","Num",\
O.vars[variable]) as num|null
if(new_value == null) return
else if(ispath(T, /obj))
for(var/obj/thing in world)
if(typecache[thing.type])
. += thing
CHECK_TICK
if(variable=="light_range")
O.set_light(new_value)
else
O.vars[variable] = new_value
else if(ispath(T, /atom/movable))
for(var/atom/movable/thing in world)
if(typecache[thing.type])
. += thing
CHECK_TICK
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if( istype(M , O.type) )
if(variable=="light_range")
M.set_light(new_value)
else
M.vars[variable] = O.vars[variable]
else if(ispath(T, /turf))
for(var/turf/thing in world)
if(typecache[thing.type])
. += thing
CHECK_TICK
else if(istype(O, /obj))
for(var/obj/A in world)
if( istype(A , O.type) )
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
else if(ispath(T, /atom))
for(var/atom/thing in world)
if(typecache[thing.type])
. += thing
CHECK_TICK
else if(istype(O, /turf))
for(var/turf/A in world)
if( istype(A , O.type) )
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
else if(ispath(T, /client))
for(var/client/thing in clients)
if(typecache[thing.type])
. += thing
CHECK_TICK
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if(M.type == O.type)
if(variable=="light_range")
M.set_light(new_value)
else
M.vars[variable] = O.vars[variable]
else if(ispath(T, /datum))
for(var/datum/thing)
if(typecache[thing.type])
. += thing
CHECK_TICK
else if(istype(O, /obj))
for(var/obj/A in world)
if(A.type == O.type)
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if(A.type == O.type)
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
if("type")
var/new_value
new_value = input("Enter type:","Type",O.vars[variable]) as null|anything in typesof(/obj,/mob,/area,/turf)
if(new_value == null) return
O.vars[variable] = new_value
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if( istype(M , O.type) )
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if(M.type == O.type)
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
if("file")
var/new_value = input("Pick file:","File",O.vars[variable]) as null|file
if(new_value == null) return
O.vars[variable] = new_value
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if( istype(M , O.type) )
M.vars[variable] = O.vars[variable]
else if(istype(O.type, /obj))
for(var/obj/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O.type, /turf))
for(var/turf/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if(M.type == O.type)
M.vars[variable] = O.vars[variable]
else if(istype(O.type, /obj))
for(var/obj/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O.type, /turf))
for(var/turf/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
if("icon")
var/new_value = input("Pick icon:","Icon",O.vars[variable]) as null|icon
if(new_value == null) return
O.vars[variable] = new_value
if(method)
if(istype(O, /mob))
for(var/mob/M in mob_list)
if( istype(M , O.type) )
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
if(istype(O, /mob))
for(var/mob/M in mob_list)
if(M.type == O.type)
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if(A.type == O.type)
A.vars[variable] = O.vars[variable]
log_admin("[key_name(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]")
message_admins("[key_name_admin(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]", 1)
else
for(var/datum/thing in world)
if(typecache[thing.type])
. += thing
CHECK_TICK
File diff suppressed because it is too large Load Diff
+16 -8
View File
@@ -588,22 +588,30 @@ Traitors and the like can also be revived with the previous role mostly intact.
feedback_add_details("admin_verb","CCR") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/cmd_admin_delete(atom/O as obj|mob|turf in view())
/client/proc/cmd_admin_delete(atom/A as obj|mob|turf in view())
set category = "Admin"
set name = "Delete"
if(!check_rights(R_ADMIN))
return
if(alert(src, "Are you sure you want to delete:\n[O]\nat ([O.x], [O.y], [O.z])?", "Confirmation", "Yes", "No") == "Yes")
log_admin("[key_name(usr)] deleted [O] at ([O.x],[O.y],[O.z])")
message_admins("[key_name_admin(usr)] deleted [O] at ([O.x],[O.y],[O.z])", 1)
admin_delete(A)
/client/proc/admin_delete(datum/D)
if(istype(D) && !D.can_vv_delete())
to_chat(src, "[D] rejected your deletion")
return
var/atom/A = D
var/coords = istype(A) ? "at ([A.x], [A.y], [A.z])" : ""
if(alert(src, "Are you sure you want to delete:\n[D]\n[coords]?", "Confirmation", "Yes", "No") == "Yes")
log_admin("[key_name(usr)] deleted [D][coords]")
message_admins("[key_name_admin(usr)] deleted [D][coords]", 1)
feedback_add_details("admin_verb","DEL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
if(istype(O, /turf))
var/turf/T = O
if(isturf(D))
var/turf/T = D
T.ChangeTurf(/turf/space)
return
qdel(O)
else
qdel(D)
/client/proc/cmd_admin_list_open_jobs()
set category = "Admin"
+15 -1
View File
@@ -2033,7 +2033,21 @@
..()
mob/living/carbon/human/get_taste_sensitivity()
/mob/living/carbon/human/vv_get_dropdown()
. = ..()
. += "---"
.["Set Species"] = "?_src_=vars;setspecies=[UID()]"
.["Make AI"] = "?_src_=vars;makeai=[UID()]"
.["Make Mask of Nar'sie"] = "?_src_=vars;makemask=[UID()]"
.["Make cyborg"] = "?_src_=vars;makerobot=[UID()]"
.["Make monkey"] = "?_src_=vars;makemonkey=[UID()]"
.["Make alien"] = "?_src_=vars;makealien=[UID()]"
.["Make slime"] = "?_src_=vars;makeslime=[UID()]"
.["Make superhero"] = "?_src_=vars;makesuper=[UID()]"
. += "---"
/mob/living/carbon/human/get_taste_sensitivity()
if(species)
return species.taste_sensitivity
else
+4 -4
View File
@@ -97,8 +97,9 @@
/mob/living/proc/update_stamina()
return
/mob/living/on_varedit(modified_var)
switch(modified_var)
/mob/living/vv_edit_var(var_name, var_value)
. = ..()
switch(var_name)
if("weakened")
SetWeakened(weakened)
if("stunned")
@@ -120,5 +121,4 @@
if("maxHealth")
updatehealth()
if("resize")
update_transform()
..()
update_transform()
+28
View File
@@ -1237,3 +1237,31 @@ var/list/slot_equipment_priority = list( \
attack_log += new_log
last_log = world.timeofday
/mob/vv_get_dropdown()
. = ..()
.["Show player panel"] = "?_src_=vars;mob_player_panel=[UID()]"
.["Give Spell"] = "?_src_=vars;give_spell=[UID()]"
.["Give Disease"] = "?_src_=vars;give_disease=[UID()]"
.["Toggle Godmode"] = "?_src_=vars;godmode=[UID()]"
.["Toggle Build Mode"] = "?_src_=vars;build_mode=[UID()]"
.["Make 2spooky"] = "?_src_=vars;make_skeleton=[UID()]"
.["Assume Direct Control"] = "?_src_=vars;direct_control=[UID()]"
.["Offer Control to Ghosts"] = "?_src_=vars;offer_control=[UID()]"
.["Drop Everything"] = "?_src_=vars;drop_everything=[UID()]"
.["Regenerate Icons"] = "?_src_=vars;regenerateicons=[UID()]"
.["Add Language"] = "?_src_=vars;addlanguage=[UID()]"
.["Remove Language"] = "?_src_=vars;remlanguage=[UID()]"
.["Add Organ"] = "?_src_=vars;addorgan=[UID()]"
.["Remove Organ"] = "?_src_=vars;remorgan=[UID()]"
.["Fix NanoUI"] = "?_src_=vars;fix_nano=[UID()]"
.["Add Verb"] = "?_src_=vars;addverb=[UID()]"
.["Remove Verb"] = "?_src_=vars;remverb=[UID()]"
.["Gib"] = "?_src_=vars;gib=[UID()]"
+8 -7
View File
@@ -163,13 +163,14 @@
playsound(loc, 'sound/weapons/empty.ogg', 50, 1, -1)
return (OXYLOSS)
/obj/item/weapon/gun/energy/on_varedit(modified_var)
if(modified_var == "selfcharge")
if(selfcharge)
processing_objects.Add(src)
else
processing_objects.Remove(src)
..()
/obj/item/weapon/gun/energy/vv_edit_var(var_name, var_value)
switch(var_name)
if("selfcharge")
if(var_value)
processing_objects.Add(src)
else
processing_objects.Remove(src)
. = ..()
/obj/item/weapon/gun/energy/proc/robocharge()
if(isrobot(loc))
+7
View File
@@ -140,6 +140,9 @@ var/global/list/obj/machinery/message_server/message_servers = list()
variable = param_variable
value = param_value
/datum/feedback_variable/vv_edit_var(var_name, var_value)
return FALSE // come on guys don't break the stats
/datum/feedback_variable/proc/inc(var/num = 1)
if(isnum(value))
value += num
@@ -189,6 +192,7 @@ var/global/list/obj/machinery/message_server/message_servers = list()
var/obj/machinery/blackbox_recorder/blackbox
//TODO: kill whoever designed this cancer
/obj/machinery/blackbox_recorder
icon = 'icons/obj/stationobjs.dmi'
icon_state = "blackbox"
@@ -314,6 +318,9 @@ var/obj/machinery/blackbox_recorder/blackbox
var/DBQuery/query_insert = dbcon.NewQuery(sql)
query_insert.Execute()
/obj/machinery/blackbox_recorder/vv_edit_var(var_name, var_value)
return FALSE // don't fuck with the stupid blackbox shit
proc/feedback_set(var/variable,var/value)
if(!blackbox) return