Resolve [terrain_mask]mask_file= relative to the [binary_path] like map_file= is

This commit is contained in:
Celtic Minstrel 2021-04-27 13:46:09 -04:00
parent ccb9f4f0e9
commit 574bc1a36e
4 changed files with 20 additions and 2 deletions

View file

@ -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,

View file

@ -22,6 +22,10 @@
#ifdef TEST
[binary_path]
path="data/test"
[/binary_path]
#Load test macros
{test/macros}

View file

@ -0,0 +1,2 @@
Hh, Hh
Hh, Hh

View file

@ -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