diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm
index bdff5fb73a..50ddc81f41 100644
--- a/code/modules/admin/verbs/modifyvariables.dm
+++ b/code/modules/admin/verbs/modifyvariables.dm
@@ -4,6 +4,10 @@ var/list/forbidden_varedit_object_types = list(
/datum/feedback_variable //Prevents people messing with feedback gathering
)
+var/list/VVlocked = list("vars", "client", "virus", "viruses", "cuffed", "last_eaten", "unlock_content", "bound_x", "bound_y", "step_x", "step_y", "force_ending")
+var/list/VVicon_edit_lock = list("icon", "icon_state", "overlays", "underlays")
+var/list/VVckey_edit = list("key", "ckey")
+
/*
/client/proc/cmd_modify_object_variables(obj/O as obj|mob|turf|area in world)
set category = "Debug"
@@ -44,7 +48,7 @@ var/list/forbidden_varedit_object_types = list(
switch(class)
if("text")
- var_value = input("Enter new text:","Text") as null|text//todo: sanitize ???
+ var_value = input("Enter new text:","Text") as null|text
if("num")
var_value = input("Enter new number:","Num") as null|num
@@ -72,7 +76,7 @@ var/list/forbidden_varedit_object_types = list(
return var_value
-/client/proc/mod_list_add(var/list/L)
+/client/proc/mod_list_add(var/list/L, atom/O, original_name, objectvar)
var/class = "text"
if(src.holder && src.holder.marked_datum)
@@ -93,7 +97,7 @@ var/list/forbidden_varedit_object_types = list(
switch(class)
if("text")
- var_value = input("Enter new text:","Text") as text//todo: sanitize ???
+ var_value = input("Enter new text:","Text") as text
if("num")
var_value = input("Enter new number:","Num") as num
@@ -124,30 +128,58 @@ var/list/forbidden_varedit_object_types = list(
L[var_value] = mod_list_add_ass() //haha
if("No")
L += var_value
+ world.log << "### ListVarEdit by [src]: [O.type] [objectvar]: ADDED=[var_value]"
+ log_admin("[key_name(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]")
+ message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: ADDED=[var_value]")
-/client/proc/mod_list(var/list/L)
+/client/proc/mod_list(var/list/L, atom/O, original_name, objectvar)
if(!check_rights(R_VAREDIT)) return
-
if(!istype(L,/list)) src << "Not a List."
- var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "viruses", "cuffed", "ka", "last_eaten", "urine", "poo", "icon", "icon_state")
- var/list/names = sortList(L)
+ if(L.len > 1000)
+ var/confirm = alert(src, "The list you're trying to edit is very long, continuing may crash the server.", "Warning", "Continue", "Abort")
+ if(confirm != "Continue")
+ return
- var/variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
+ var/assoc = 0
+ if(L.len > 0)
+ var/a = L[1]
+ if(istext(a) && L[a] != null)
+ assoc = 1 //This is pretty weak test but i can't think of anything else
+ usr << "List appears to be associative."
+
+ var/list/names = null
+ if(!assoc)
+ names = sortList(L)
+
+ var/variable
+ var/assoc_key
+ if(assoc)
+ variable = input("Which var?","Var") as null|anything in L + "(ADD VAR)"
+ else
+ variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
if(variable == "(ADD VAR)")
- mod_list_add(L)
+ mod_list_add(L, O, original_name, objectvar)
return
- if(!variable)
+ if(assoc)
+ assoc_key = variable
+ variable = L[assoc_key]
+
+ if(!assoc && !variable || assoc && !assoc_key)
return
var/default
var/dir
- if(variable in locked)
+ if(variable in VVlocked)
if(!check_rights(R_DEBUG)) return
+ if(variable in VVckey_edit)
+ if(!check_rights(R_SPAWN|R_DEBUG)) return
+ if(variable in VVicon_edit_lock)
+ if(!check_rights(R_FUN|R_DEBUG)) return
if(isnull(variable))
usr << "Unable to determine variable type."
@@ -212,14 +244,12 @@ var/list/forbidden_varedit_object_types = list(
usr << "If a direction, direction is: [dir]"
var/class = "text"
- var/list/choices = list("text","num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default")
if(src.holder && src.holder.marked_datum)
- choices += "marked datum ([holder.marked_datum.type])"
- if(!isnull(default) && default != "num")
- choices += "edit associated variable"
- choices += "DELETE FROM LIST"
-
- class = input("What kind of variable?","Variable Type",default) as null|anything in choices
+ class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
+ "num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default","marked datum ([holder.marked_datum.type])", "DELETE FROM LIST")
+ else
+ class = input("What kind of variable?","Variable Type",default) as null|anything in list("text",
+ "num","type","reference","mob reference", "icon","file","list","edit referenced object","restore to default", "DELETE FROM LIST")
if(!class)
return
@@ -227,61 +257,107 @@ var/list/forbidden_varedit_object_types = list(
if(holder.marked_datum && class == "marked datum ([holder.marked_datum.type])")
class = "marked datum"
+ var/original_var
+ if(assoc)
+ original_var = L[assoc_key]
+ else
+ original_var = L[L.Find(variable)]
+
+ var/new_var
switch(class) //Spits a runtime error if you try to modify an entry in the contents list. Dunno how to fix it, yet.
if("list")
- mod_list(variable)
+ mod_list(variable, O, original_name, objectvar)
if("restore to default")
- L[L.Find(variable)]=initial(variable)
+ new_var = initial(variable)
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("edit referenced object")
modify_variables(variable)
if("DELETE FROM LIST")
+ world.log << "### ListVarEdit by [src]: [O.type] [objectvar]: REMOVED=[html_encode("[variable]")]"
+ log_admin("[key_name(src)] modified [original_name]'s [objectvar]: REMOVED=[variable]")
+ message_admins("[key_name_admin(src)] modified [original_name]'s [objectvar]: REMOVED=[variable]")
L -= variable
return
if("text")
- L[L.Find(variable)] = input("Enter new text:","Text") as text//todo: sanitize ???
+ new_var = input("Enter new text:","Text") as text
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("num")
- L[L.Find(variable)] = input("Enter new number:","Num") as num
+ new_var = input("Enter new number:","Num") as num
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("type")
- L[L.Find(variable)] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
+ new_var = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("reference")
- L[L.Find(variable)] = input("Select reference:","Reference") as mob|obj|turf|area in world
+ new_var = input("Select reference:","Reference") as mob|obj|turf|area in world
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("mob reference")
- L[L.Find(variable)] = input("Select reference:","Reference") as mob in world
+ new_var = input("Select reference:","Reference") as mob in world
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("file")
- L[L.Find(variable)] = input("Pick file:","File") as file
+ new_var = input("Pick file:","File") as file
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("icon")
- L[L.Find(variable)] = input("Pick icon:","Icon") as icon
+ new_var = input("Pick icon:","Icon") as icon
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
if("marked datum")
- L[L.Find(variable)] = holder.marked_datum
-
- if("edit associated variable")
- var/temp_var = mod_list_add_ass()
- if(temp_var)
- L[variable] = temp_var
+ new_var = holder.marked_datum
+ if(assoc)
+ L[assoc_key] = new_var
+ else
+ L[L.Find(variable)] = new_var
+ world.log << "### ListVarEdit by [src]: [O.type] [objectvar]: [original_var]=[new_var]"
+ log_admin("[key_name(src)] modified [original_name]'s [objectvar]: [original_var]=[new_var]")
+ message_admins("[key_name_admin(src)] modified [original_name]'s varlist [objectvar]: [original_var]=[new_var]")
/client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0)
if(!check_rights(R_VAREDIT)) return
- var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "cuffed", "ka", "last_eaten", "icon", "icon_state")
-
for(var/p in forbidden_varedit_object_types)
if( istype(O,p) )
- usr << "\red It is forbidden to edit this object's variables."
+ usr << "It is forbidden to edit this object's variables."
return
+ if(istype(O, /client) && (param_var_name == "ckey" || param_var_name == "key"))
+ usr << "You cannot edit ckeys on client objects."
+ return
+
var/class
var/variable
var/var_value
@@ -291,8 +367,12 @@ var/list/forbidden_varedit_object_types = list(
src << "A variable with this name ([param_var_name]) doesn't exist in this atom ([O])"
return
- if(param_var_name == "holder" || (param_var_name in locked))
+ if(param_var_name in VVlocked)
if(!check_rights(R_DEBUG)) return
+ if(param_var_name in VVckey_edit)
+ if(!check_rights(R_SPAWN|R_DEBUG)) return
+ if(param_var_name in VVicon_edit_lock)
+ if(!check_rights(R_FUN|R_DEBUG)) return
variable = param_var_name
@@ -349,8 +429,12 @@ var/list/forbidden_varedit_object_types = list(
if(!variable) return
var_value = O.vars[variable]
- if(variable == "holder" || (variable in locked))
- if(!check_rights(R_DEBUG)) return
+ if(variable in VVlocked)
+ if(!check_rights(R_DEBUG)) return
+ if(variable in VVckey_edit)
+ if(!check_rights(R_SPAWN|R_DEBUG)) return
+ if(variable in VVicon_edit_lock)
+ if(!check_rights(R_FUN|R_DEBUG)) return
if(!autodetect_class)
@@ -440,7 +524,7 @@ var/list/forbidden_varedit_object_types = list(
switch(class)
if("list")
- mod_list(O.vars[variable])
+ mod_list(O.vars[variable], O, original_name, variable)
return
if("restore to default")
@@ -450,7 +534,7 @@ var/list/forbidden_varedit_object_types = list(
return .(O.vars[variable])
if("text")
- var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|text//todo: sanitize ???
+ var/var_new = input("Enter new text:","Text",O.vars[variable]) as null|text
if(var_new==null) return
O.vars[variable] = var_new
@@ -504,5 +588,4 @@ var/list/forbidden_varedit_object_types = list(
world.log << "### VarEdit by [src]: [O.type] [variable]=[html_encode("[O.vars[variable]]")]"
log_admin("[key_name(src)] modified [original_name]'s [variable] to [O.vars[variable]]")
- message_admins("[key_name_admin(src)] modified [original_name]'s [variable] to [O.vars[variable]]", 1)
-
+ message_admins("[key_name_admin(src)] modified [original_name]'s [variable] to [O.vars[variable]]")