Merge pull request #35696 from Xhuis/circuit_rpg_loot

Fixes wizard RPG loot from making circuit analyzers useless
This commit is contained in:
Jordan Brown
2018-02-16 08:52:14 -05:00
committed by CitadelStationBot
parent 757df53aa3
commit d6b493f2ec

View File

@@ -5,12 +5,13 @@
// The list is converted to JSON down the line.
/obj/item/integrated_circuit/proc/save()
var/list/component_params = list()
var/init_name = initial(name)
// Save initial name used for differentiating assemblies
component_params["type"] = name
component_params["type"] = init_name
// Save the modified name.
if(name != displayed_name)
if(init_name != displayed_name)
component_params["name"] = displayed_name
// Saving input values
@@ -43,25 +44,26 @@
// Verifies a list of component parameters
// Returns null on success, error name on failure
/obj/item/integrated_circuit/proc/verify_save(list/component_params)
var/init_name = initial(name)
// Validate name
if(component_params["name"] && !reject_bad_name(component_params["name"], TRUE))
return "Bad component name at [name]."
return "Bad component name at [init_name]."
// Validate input values
if(component_params["inputs"])
var/list/loaded_inputs = component_params["inputs"]
if(!islist(loaded_inputs))
return "Malformed input values list at [name]."
return "Malformed input values list at [init_name]."
var/inputs_amt = length(inputs)
// Too many inputs? Inputs for input-less component? This is not good.
if(!inputs_amt || inputs_amt < length(loaded_inputs))
return "Input values list out of bounds at [name]."
return "Input values list out of bounds at [init_name]."
for(var/list/input in loaded_inputs)
if(input.len != 3)
return "Malformed input data at [name]."
return "Malformed input data at [init_name]."
var/input_id = input[1]
var/input_type = input[2]
@@ -69,12 +71,12 @@
// No special type support yet.
if(input_type)
return "Unidentified input type at [name]!"
return "Unidentified input type at [init_name]!"
// TODO: support for special input types, such as typepaths and internal refs
// Input ID is a list index, make sure it's sane.
if(!isnum(input_id) || input_id % 1 || input_id > inputs_amt || input_id < 1)
return "Invalid input index at [name]."
return "Invalid input index at [init_name]."
// Loads component parameters from a list