From c538e5f9842f92e78477d82612879de8a54070c0 Mon Sep 17 00:00:00 2001 From: mattsc Date: Tue, 19 May 2015 19:43:23 -0700 Subject: [PATCH] Micro AIs: issue warning if side defined in [micro_ai] tag does not exist Previously this would cause a whole series of Lua error messages and, potentially, some code not being executed. --- data/ai/micro_ais/micro_ai_wml_tag.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/ai/micro_ais/micro_ai_wml_tag.lua b/data/ai/micro_ais/micro_ai_wml_tag.lua index 3ca187bdbe4c..6e4e630cdcc1 100644 --- a/data/ai/micro_ais/micro_ai_wml_tag.lua +++ b/data/ai/micro_ais/micro_ai_wml_tag.lua @@ -50,6 +50,10 @@ function wesnoth.wml_actions.micro_ai(cfg) -- Check that the required common keys are all present and set correctly if (not cfg.ai_type) then H.wml_error("[micro_ai] is missing required ai_type= key") end if (not cfg.side) then H.wml_error("[micro_ai] is missing required side= key") end + if (not wesnoth.sides[cfg.side]) then + wesnoth.message("Warning", "[micro_ai] uses side=" .. cfg.side .. ": side does not exist") + return + end if (not cfg.action) then H.wml_error("[micro_ai] is missing required action= key") end if (cfg.action ~= 'add') and (cfg.action ~= 'delete') and (cfg.action ~= 'change') then