diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-07 20:15:56 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-07 20:15:56 +0100 |
commit | 10a72bb7d695fd36675198fd52b467fc66fcea17 (patch) | |
tree | 6f241461e7c6fc1b2439e855b0d24f99e27a186b | |
parent | 24c7e1915bf16b4141d0502af040791fed65aa06 (diff) |
a
-rw-r--r-- | run-show-coverage.sh | 3 | ||||
-rw-r--r-- | serialize/wall-atlas.cpp | 9 | ||||
-rw-r--r-- | test/app.hpp | 1 | ||||
-rw-r--r-- | test/dijkstra.cpp | 2 | ||||
-rw-r--r-- | test/json/wall-atlas-02_groups.json | 2 | ||||
-rw-r--r-- | test/main.cpp | 1 | ||||
-rw-r--r-- | test/scenery.cpp | 24 | ||||
-rw-r--r-- | test/wall-atlas.cpp | 18 |
8 files changed, 46 insertions, 14 deletions
diff --git a/run-show-coverage.sh b/run-show-coverage.sh index 32bd11cf..9b5f6974 100644 --- a/run-show-coverage.sh +++ b/run-show-coverage.sh @@ -6,7 +6,8 @@ case "$OS" in Windows_NT) export PATH="$PATH:/usr/bin" ;; esac -self="$(basename -- "$1")" +self="$(basename -- "$0")" +cd -- "$(dirname -- "$0")" usage() { echo "usage: ${self} <all|compile|run|generate|open>..." >&2 diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp index 215b8eae..44620246 100644 --- a/serialize/wall-atlas.cpp +++ b/serialize/wall-atlas.cpp @@ -56,8 +56,10 @@ Group read_group_metadata(const json& jgroup) if (jgroup.contains("pixel-size"s)) val.pixel_size = jgroup["pixel-size"s]; - if (jgroup.contains("tint"s)) - std::tie(val.tint_mult, val.tint_add) = std::pair<Vector4, Vector3>{ jgroup["tint"s] }; + if (jgroup.contains("tint-mult"s)) + val.tint_mult = Vector4(jgroup["tint-mult"s]); + if (jgroup.contains("tint-add"s)) + val.tint_add = Vector3(jgroup["tint-add"s]); if (jgroup.contains("from-rotation"s)) val.from_rotation = (uint8_t)direction_index_from_name(std::string{ jgroup["from-rotation"s] }); if (jgroup.contains("mirrored"s)) @@ -104,7 +106,8 @@ void write_group_metadata(json& jgroup, const Group& val) jgroup["index"s] = val.index; jgroup["count"s] = val.count; jgroup["pixel-size"s] = val.pixel_size; - jgroup["tint"s] = std::pair<Vector4, Vector3>{{val.tint_mult}, {val.tint_add}}; + jgroup["tint-mult"s] = Vector4(val.tint_mult); + jgroup["tint-add"s] = Vector3(val.tint_add); jgroup["from-rotation"s] = val.from_rotation; jgroup["mirrored"s] = val.mirrored; jgroup["default-tint"s] = val.default_tint; diff --git a/test/app.hpp b/test/app.hpp index b3ea87fe..b0b7f30f 100644 --- a/test/app.hpp +++ b/test/app.hpp @@ -34,6 +34,7 @@ struct test_app final : private FM_APPLICATION static void test_path_search(); static void test_dijkstra(); static void test_hash(); + static void test_scenery(); static void test_path_search_node_pool(); static void test_wall_atlas(); static void zzz_test_misc(); diff --git a/test/dijkstra.cpp b/test/dijkstra.cpp index 28f59d4f..ad8a09e4 100644 --- a/test/dijkstra.cpp +++ b/test/dijkstra.cpp @@ -7,7 +7,7 @@ namespace floormat { void test_app::test_dijkstra() { - constexpr bool debug = true; + constexpr bool debug = false; auto A = astar{}; auto w = world(); diff --git a/test/json/wall-atlas-02_groups.json b/test/json/wall-atlas-02_groups.json index 1a6ea806..fe565acc 100644 --- a/test/json/wall-atlas-02_groups.json +++ b/test/json/wall-atlas-02_groups.json @@ -17,7 +17,7 @@ }, "overlay": { "pixel-size": "42 x 192", - "tint-mult": [ 0.1, 0.2, 0.3, 0.4 ], + "tint-mult": [ 0.125, 0.25, 0.5, 1 ], "tint-add": [ 1, 2, 3 ], "default-tint": false, "mirrored": true diff --git a/test/main.cpp b/test/main.cpp index 569d5130..2bd038ce 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -34,6 +34,7 @@ int test_app::exec() test_hash(); test_wall_atlas(); + test_scenery(); test_path_search_node_pool(); test_path_search(); test_dijkstra(); diff --git a/test/scenery.cpp b/test/scenery.cpp new file mode 100644 index 00000000..40669ec9 --- /dev/null +++ b/test/scenery.cpp @@ -0,0 +1,24 @@ +#include "app.hpp" +#include "loader/loader.hpp" +#include "loader/scenery.hpp" + +namespace floormat { + +namespace { + +void test_loading() +{ + fm_assert(!loader.sceneries().empty()); + + for (const auto& [name, descr, proto] : loader.sceneries()) + fm_assert(proto.sc_type != scenery_type::none); +} + +} // namespace + +void test_app::test_scenery() +{ + test_loading(); +} + +} // namespace floormat diff --git a/test/wall-atlas.cpp b/test/wall-atlas.cpp index 699043a3..92439800 100644 --- a/test/wall-atlas.cpp +++ b/test/wall-atlas.cpp @@ -64,14 +64,16 @@ void test_read_groups(StringView filename) fm_assert(read_direction_metadata(jroot, Direction_::S).is_empty()); const auto dir = read_direction_metadata(jroot, Direction_::W); - - fm_assert(dir.wall.pixel_size == Vector2ui{}); - fm_assert(!dir.wall.default_tint); - - fm_assert(dir.side.pixel_size == Vector2ui{42, 192}); - fm_assert(dir.side.default_tint); - - fm_assert(dir.top.default_tint == group_defaults.default_tint); + fm_assert(dir.wall.pixel_size == Vector2ui{} ); + fm_assert(dir.wall.default_tint == false ); + fm_assert(dir.wall.mirrored == group_defaults.mirrored ); + fm_assert(dir.wall.from_rotation == (uint8_t)-1 ); + fm_assert(dir.side.pixel_size == Vector2ui{42, 192} ); + fm_assert(dir.side.default_tint == true ); + fm_assert(dir.top.default_tint == group_defaults.default_tint ); + fm_assert(dir.overlay.tint_mult == Vector4{0.125f, 0.25f, 0.5f, 1.f } ); + fm_assert(dir.overlay.tint_add == Vector3{1, 2, 3} ); + fm_assert(dir.overlay.mirrored == true ); } } // namespace |