Resolve [terrain_mask]mask_file= relative to the [binary_path] like map_file= is
This commit is contained in:
parent
ccb9f4f0e9
commit
574bc1a36e
4 changed files with 20 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#ifdef TEST
|
||||
|
||||
[binary_path]
|
||||
path="data/test"
|
||||
[/binary_path]
|
||||
|
||||
#Load test macros
|
||||
{test/macros}
|
||||
|
||||
|
|
2
data/test/maps/test_hills_square.mask
Normal file
2
data/test/maps/test_hills_square.mask
Normal file
|
@ -0,0 +1,2 @@
|
|||
Hh, Hh
|
||||
Hh, Hh
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue