From 6e2de00ab4e66ef5d0999d8c04d1ee2867860672 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Fri, 11 Feb 2022 09:06:35 +0000 Subject: [PATCH] Fixes an issue with tags for mobs not properly being handled correctly and adds logging to admin circuits (#64821) Tags would bug out due to how the 'Save Shell' component would copy all the variables on an object except a few restricted ones, though this proved to be very buggy. The duplicator part has been removed and more proper logging has been added. To compensate for the duplicator part being removed, admin circuit display names will now replace the entire name of the shell. --- code/__HELPERS/_logging.dm | 5 +++++ .../wiremod/components/admin/animate.dm | 1 + .../wiremod/components/admin/getvar.dm | 1 + .../wiremod/components/admin/proccall.dm | 4 +++- .../wiremod/components/admin/save_shell.dm | 14 +------------ code/modules/wiremod/components/admin/sdql.dm | 1 + .../wiremod/components/admin/setvar.dm | 1 + .../admin/signal_handler/signal_handler.dm | 7 ++++++- .../modules/wiremod/components/admin/spawn.dm | 1 + code/modules/wiremod/core/duplicator.dm | 6 +++--- .../wiremod/core/integrated_circuit.dm | 21 +++++++++++-------- 11 files changed, 35 insertions(+), 27 deletions(-) diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm index d821b40b23f..19f947bdc7e 100644 --- a/code/__HELPERS/_logging.dm +++ b/code/__HELPERS/_logging.dm @@ -76,6 +76,11 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) if (CONFIG_GET(flag/log_admin)) WRITE_LOG(GLOB.world_game_log, "ADMIN: [text]") +/proc/log_admin_circuit(text) + GLOB.admin_log.Add(text) + if(CONFIG_GET(flag/log_admin)) + WRITE_LOG(GLOB.world_game_log, "ADMIN: CIRCUIT: [text]") + /proc/log_admin_private(text) GLOB.admin_log.Add(text) if (CONFIG_GET(flag/log_admin)) diff --git a/code/modules/wiremod/components/admin/animate.dm b/code/modules/wiremod/components/admin/animate.dm index 825eba83b77..4af25578f3e 100644 --- a/code/modules/wiremod/components/admin/animate.dm +++ b/code/modules/wiremod/components/admin/animate.dm @@ -83,6 +83,7 @@ if(parallel.value) extra_flags |= ANIMATION_PARALLEL + log_admin_circuit("[parent.get_creator()] performed an animation on [target_atom].") var/list/first_step = popleft(result["animation_steps"]) animate(target_for_animation, time = first_step["time"], first_step["vars"], loop = animation_loops.value, easing = first_step["easing"], flags = first_step["flags"]|extra_flags) for(var/list/step as anything in result["animation_steps"]) diff --git a/code/modules/wiremod/components/admin/getvar.dm b/code/modules/wiremod/components/admin/getvar.dm index 87690b79148..2fe8f18b09e 100644 --- a/code/modules/wiremod/components/admin/getvar.dm +++ b/code/modules/wiremod/components/admin/getvar.dm @@ -58,4 +58,5 @@ output_value.set_output(null) return + log_admin_circuit("[parent.get_creator()] requested the variable '[var_name]' on [object].") output_value.set_output(object.vars[var_name]) diff --git a/code/modules/wiremod/components/admin/proccall.dm b/code/modules/wiremod/components/admin/proccall.dm index 11475ebba67..16730ce27fe 100644 --- a/code/modules/wiremod/components/admin/proccall.dm +++ b/code/modules/wiremod/components/admin/proccall.dm @@ -71,7 +71,9 @@ if(called_on != GLOBAL_PROC && !hascall(called_on, to_invoke)) return - INVOKE_ASYNC(src, .proc/do_proccall, called_on, to_invoke, recursive_list_resolve(params)) + var/list/resolved_params = recursive_list_resolve(params) + log_admin_circuit("[parent.get_creator()] proccalled '[to_invoke]' on [called_on] with params \[[resolved_params.Join(", ")]].") + INVOKE_ASYNC(src, .proc/do_proccall, called_on, to_invoke, resolved_params) /obj/item/circuit_component/proccall/proc/do_proccall(called_on, to_invoke, params) var/result = HandleUserlessProcCall(parent.get_creator(), called_on, to_invoke, params) diff --git a/code/modules/wiremod/components/admin/save_shell.dm b/code/modules/wiremod/components/admin/save_shell.dm index 80ce13e0d02..4727d460baa 100644 --- a/code/modules/wiremod/components/admin/save_shell.dm +++ b/code/modules/wiremod/components/admin/save_shell.dm @@ -45,14 +45,6 @@ . = ..() var/atom/movable/shell = parent.shell component_data["shell_type"] = shell.type - var/list/shell_variables = list() - for(var/variable in shell.vars - GLOB.duplicate_forbidden_vars) - var/variable_data = shell.vars[variable] - if(!istext(variable_data) && !isnum(variable_data)) - continue - shell_variables[variable] = variable_data - - component_data["shell_variables"] = shell_variables /obj/item/circuit_component/save_shell/load_data_from_list(list/component_data) if(parent.shell) @@ -63,12 +55,8 @@ return ..() loaded_shell = new shell_type(drop_location()) + log_admin_circuit("[parent.get_creator()] spawned in [shell_type] at [ADMIN_COORDJMP(loaded_shell)].") if(!loaded_shell) return loaded_shell.datum_flags |= DF_VAR_EDITED - - var/list/shell_variables = component_data["shell_variables"] - for(var/variable in shell_variables - GLOB.duplicate_forbidden_vars) - var/variable_data = shell_variables[variable] - loaded_shell.vv_edit_var(variable, variable_data) return ..() diff --git a/code/modules/wiremod/components/admin/sdql.dm b/code/modules/wiremod/components/admin/sdql.dm index 1da54d96926..effa4be8976 100644 --- a/code/modules/wiremod/components/admin/sdql.dm +++ b/code/modules/wiremod/components/admin/sdql.dm @@ -31,5 +31,6 @@ if(!operation) return + log_admin_circuit("[parent.get_creator()] performed SDQL query [operation].") var/result = HandleUserlessSDQL(parent.get_creator(), operation) results.set_output(result) diff --git a/code/modules/wiremod/components/admin/setvar.dm b/code/modules/wiremod/components/admin/setvar.dm index 07a05d4ba27..dcf1022719d 100644 --- a/code/modules/wiremod/components/admin/setvar.dm +++ b/code/modules/wiremod/components/admin/setvar.dm @@ -35,4 +35,5 @@ var/list/to_resolve = resolved_new_value resolved_new_value = recursive_list_resolve(to_resolve) + log_admin_circuit("[parent.get_creator()] set the variable '[var_name]' on [object] to [resolved_new_value].") object.vv_edit_var(var_name, resolved_new_value) diff --git a/code/modules/wiremod/components/admin/signal_handler/signal_handler.dm b/code/modules/wiremod/components/admin/signal_handler/signal_handler.dm index 4d374b5c2b8..326a24e0110 100644 --- a/code/modules/wiremod/components/admin/signal_handler/signal_handler.dm +++ b/code/modules/wiremod/components/admin/signal_handler/signal_handler.dm @@ -132,6 +132,7 @@ target_datum = SSdcs if(target_datum) + log_admin_circuit("[parent.get_creator()] registered the signal '[registered_signal]' on [target_datum]") // We override because an admin may try registering a signal on the same object/datum again, so this prevents any runtimes from occuring RegisterSignal(target_datum, registered_signal, .proc/handle_signal_received, override = TRUE) registered_entities |= WEAKREF(target_datum) @@ -198,6 +199,8 @@ var/temp_usr = usr usr = null + var/list/displayArgs = arguments.Copy() + log_admin_circuit("[parent.get_creator()] received a signal from [popleft(displayArgs)] ([registered_signal]) with the parameters \[[displayArgs.Join(", ")]]") SScircuit_component.queue_instant_run() run_ports_on_args(arguments) var/list/output = SScircuit_component.execute_instant_run() @@ -218,7 +221,9 @@ if(!return_values["bitflag"]) return_values["bitflag"] = NONE - return_values["bitflag"] |= input_signal_ports[port] + var/bitflag = input_signal_ports[port] + log_admin_circuit("[parent.get_creator()] received bitflag [bitflag] for '[registered_signal]'") + return_values["bitflag"] |= bitflag #undef COMP_SIGNAL_HANDLER_GLOBAL #undef COMP_SIGNAL_HANDLER_OBJECT diff --git a/code/modules/wiremod/components/admin/spawn.dm b/code/modules/wiremod/components/admin/spawn.dm index 9690b04a8ef..bc50552369e 100644 --- a/code/modules/wiremod/components/admin/spawn.dm +++ b/code/modules/wiremod/components/admin/spawn.dm @@ -43,6 +43,7 @@ resolved_params.Insert(1, spawn_at.value) + log_admin_circuit("[parent.get_creator()] spawned in [typepath] with parameters \[[resolved_params.Join(", ")]].") var/atom/spawned = new typepath(arglist(resolved_params)) spawned.datum_flags |= DF_VAR_EDITED spawned_atom.set_output(spawned) diff --git a/code/modules/wiremod/core/duplicator.dm b/code/modules/wiremod/core/duplicator.dm index 2d480e9dc85..20df74ae0cf 100644 --- a/code/modules/wiremod/core/duplicator.dm +++ b/code/modules/wiremod/core/duplicator.dm @@ -16,9 +16,6 @@ GLOBAL_LIST_INIT(circuit_dupe_whitelisted_types, list( LOG_ERROR(errors, "Invalid json format!") return - if(general_data["display_name"]) - set_display_name(general_data["display_name"]) - var/list/variable_data = general_data["variables"] for(var/list/variable as anything in variable_data) var/variable_name = variable["name"] @@ -32,6 +29,9 @@ GLOBAL_LIST_INIT(circuit_dupe_whitelisted_types, list( admin_only = general_data["admin_only"] + if(general_data["display_name"]) + set_display_name(general_data["display_name"]) + var/list/circuit_data = general_data["components"] var/list/identifiers_to_circuit = list() for(var/identifier in circuit_data) diff --git a/code/modules/wiremod/core/integrated_circuit.dm b/code/modules/wiremod/core/integrated_circuit.dm index a59d513732f..f0b96d32d50 100644 --- a/code/modules/wiremod/core/integrated_circuit.dm +++ b/code/modules/wiremod/core/integrated_circuit.dm @@ -541,16 +541,9 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit) var/new_name = params["display_name"] if(new_name) - set_display_name(strip_html(params["display_name"], label_max_length)) + set_display_name(params["display_name"]) else set_display_name("") - - if(shell) - if(display_name != "") - shell.name = "[initial(shell.name)] ([display_name])" - else - shell.name = initial(shell.name) - . = TRUE if("set_examined_component") var/component_id = text2num(params["component_id"]) @@ -666,7 +659,17 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit) /// Sets the display name that appears on the shell. /obj/item/integrated_circuit/proc/set_display_name(new_name) - display_name = new_name + display_name = copytext(new_name, 1, label_max_length) + if(!shell) + return + + if(display_name != "") + if(!admin_only) + shell.name = "[initial(shell.name)] ([strip_html(display_name)])" + else + shell.name = display_name + else + shell.name = initial(shell.name) /** * Returns the creator of the integrated circuit. Used in admin messages and other related things.