From 05f139ef1af50a02182882e8724591d50537260f Mon Sep 17 00:00:00 2001 From: Julian Murgia Date: Fri, 8 Apr 2022 21:20:20 +0200 Subject: [PATCH] Fix: Avoid globals starting with 'i/' (#556) --- .../game/core-scripts/esc/commands/inventory_add.gd | 13 +++++++++++++ .../game/core-scripts/esc/esc_globals_manager.gd | 1 + 2 files changed, 14 insertions(+) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd b/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd index 070a7504..125fffa3 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/inventory_add.gd @@ -22,6 +22,19 @@ func configure() -> ESCCommandArgumentDescriptor: ) +# Validate whether the given arguments match the command descriptor +func validate(arguments: Array): + if arguments[0].begins_with("i/"): + escoria.logger.report_errors( + "inventory_add: invalid item name", + [ + "Item name %s cannot start with 'i/'." % arguments[0] + ] + ) + return false + return .validate(arguments) + + # Run the command func run(command_params: Array) -> int: escoria.inventory_manager.add_item(command_params[0]) diff --git a/addons/escoria-core/game/core-scripts/esc/esc_globals_manager.gd b/addons/escoria-core/game/core-scripts/esc/esc_globals_manager.gd index 2ce7dd83..5831d8d0 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_globals_manager.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_globals_manager.gd @@ -92,6 +92,7 @@ func set_global(key: String, value, ignore_reserved: bool = false) -> void: "Global key %s is reserved and can not be overridden" % key ] ) + emit_signal( "global_changed", key,