From 157c2f564c13696c6ae627e5e53e285ac652be69 Mon Sep 17 00:00:00 2001 From: Duncan Brown Date: Sat, 9 Apr 2022 10:28:41 -0400 Subject: [PATCH] fix: properly validate min_args and remove superfluous validation call to argument descriptor --- .../game/core-scripts/esc/types/esc_command.gd | 9 ++++----- .../esc/types/esc_command_argument_descriptor.gd | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd index 40c19058..bc2bd595 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_command.gd @@ -117,11 +117,10 @@ func run() -> int: return ESCExecution.RC_ERROR else: var argument_descriptor = command_object.configure() - var prepared_arguments = argument_descriptor.prepare_arguments( - self.parameters - ) - if argument_descriptor.validate(self.name, prepared_arguments) and\ - command_object.validate(prepared_arguments): + if command_object.validate(self.parameters): + var prepared_arguments = argument_descriptor.prepare_arguments( + self.parameters + ) escoria.logger.debug("Running command %s with parameters %s" % [ self.name, prepared_arguments diff --git a/addons/escoria-core/game/core-scripts/esc/types/esc_command_argument_descriptor.gd b/addons/escoria-core/game/core-scripts/esc/types/esc_command_argument_descriptor.gd index a79b1be5..2342803e 100644 --- a/addons/escoria-core/game/core-scripts/esc/types/esc_command_argument_descriptor.gd +++ b/addons/escoria-core/game/core-scripts/esc/types/esc_command_argument_descriptor.gd @@ -72,6 +72,10 @@ func validate(command: String, arguments: Array) -> bool: ] ) + # We also validate the arguments as they'll appear being passed in to the + # command in question, including any default values. + arguments = self.prepare_arguments(arguments) + for index in range(arguments.size()): if arguments[index] == null: # No type checking for null values