From b297831eeb90e445f9f477c48b36f34da1a6eb87 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Mon, 26 Jan 2015 08:35:50 +1100 Subject: [PATCH] Allow [disallow_recruit] to disable the whole recruit list of a side if passed without type= --- data/lua/wml-tags.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/data/lua/wml-tags.lua b/data/lua/wml-tags.lua index eda494d84c2f..9f8ded05cf5f 100644 --- a/data/lua/wml-tags.lua +++ b/data/lua/wml-tags.lua @@ -196,18 +196,22 @@ function wml_actions.allow_extra_recruit(cfg) end function wml_actions.disallow_recruit(cfg) - local unit_types = cfg.type or helper.wml_error("[disallow_recruit] missing required type= attribute") + local unit_types = cfg.type for index, team in ipairs(wesnoth.get_sides(cfg)) do - local v = team.recruit - for w in split(unit_types) do - for i, r in ipairs(v) do - if r == w then - table.remove(v, i) - break + if unit_types then + local v = team.recruit + for w in split(unit_types) do + for i, r in ipairs(v) do + if r == w then + table.remove(v, i) + break + end end end + team.recruit = v + else + team.recruit = nil end - team.recruit = v end end