diff --git a/data/lua/wml-tags.lua b/data/lua/wml-tags.lua index d2ef4c761c0..fc587aace1e 100644 --- a/data/lua/wml-tags.lua +++ b/data/lua/wml-tags.lua @@ -967,7 +967,9 @@ function wml_actions.terrain_mask(cfg) rules[#rules + 1] = rule end if cfg.mask_file then - mask = filesystem.read_file(cfg.mask_file) + local resolved = filesystem.resolve_asset(filesystem.asset_type.MAP, cfg.mask_file) + resolved = resolved:sub(6) -- strip off 'data/' prefix + mask = filesystem.read_file(resolved) end wesnoth.current.map:terrain_mask({x, y}, mask, { is_odd = is_odd, diff --git a/data/test/_main.cfg b/data/test/_main.cfg index bdfe3657a8b..def017c508b 100644 --- a/data/test/_main.cfg +++ b/data/test/_main.cfg @@ -22,6 +22,10 @@ #ifdef TEST +[binary_path] + path="data/test" +[/binary_path] + #Load test macros {test/macros} diff --git a/data/test/maps/test_hills_square.mask b/data/test/maps/test_hills_square.mask new file mode 100644 index 00000000000..5ad8649c853 --- /dev/null +++ b/data/test/maps/test_hills_square.mask @@ -0,0 +1,2 @@ +Hh, Hh +Hh, Hh \ No newline at end of file diff --git a/data/test/scenarios/test_terrain_mask.cfg b/data/test/scenarios/test_terrain_mask.cfg index 8bc51c380c7..03c5aee61c1 100644 --- a/data/test/scenarios/test_terrain_mask.cfg +++ b/data/test/scenarios/test_terrain_mask.cfg @@ -11,6 +11,8 @@ raw#endarg #endarg #arg RULES #endarg +#arg MASK_TYPE +mask#endarg {GENERIC_UNIT_TEST test_terrain_mask_{SUFFIX} ( [event] name=start @@ -18,7 +20,7 @@ raw#endarg [terrain_mask] x,y={POS} alignment={ALIGNMENT} - mask={MASK} + {MASK_TYPE}={MASK} {RULES} [/terrain_mask] {POST_MASK} @@ -138,6 +140,14 @@ Hh, Hh"#enddef {ASSERT_LOCATION_TERRAIN 8 4 Hh} )} +# mask_file= works (this is the same as the above test in all other respects) +{TERRAIN_MASK_TEST file "test_hills_square.mask" (POS=7,3) (RULES={TERRAIN_RULE_SIMPLE Kha^Kov Hh Ko}{TERRAIN_RULE_SIMPLE Cha^Kov Hh Co}) (POST_MASK= + {ASSERT_LOCATION_TERRAIN 7 3 Ko} + {ASSERT_LOCATION_TERRAIN 7 4 Co} + {ASSERT_LOCATION_TERRAIN 8 3 Hh} + {ASSERT_LOCATION_TERRAIN 8 4 Hh} +) (MASK_TYPE=mask_file)} + # TODO: Add more terrain rule tests? #undef TERRAIN_MASK_TEST