diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-08 13:46:55 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-08 13:46:55 +0100 |
commit | 1ae0459c47ad9b27765336a73f039c578ef9e503 (patch) | |
tree | 44e8bf64d8316f0d2c8bac816066a8df08958815 | |
parent | 94fd8cbbc174ba8df12b5ada164b06ba6063eb8f (diff) |
serialize: die on tile atlas reuse with wrong pass flag
-rw-r--r-- | serialize/tile-atlas.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/serialize/tile-atlas.cpp b/serialize/tile-atlas.cpp index 6a51da4c..cb58d1b4 100644 --- a/serialize/tile-atlas.cpp +++ b/serialize/tile-atlas.cpp @@ -4,6 +4,7 @@ #include "serialize/magnum-vector2i.hpp" #include "loader/loader.hpp" #include "serialize/pass-mode.hpp" +#include <string_view> #include <Corrade/Containers/Optional.h> #include <Corrade/Containers/String.h> #include <nlohmann/json.hpp> @@ -50,6 +51,12 @@ void adl_serializer<std::shared_ptr<tile_atlas>>::from_json(const json& j, std:: if (j.contains("pass-mode")) p = {InPlaceInit, j["pass-mode"]}; val = loader.tile_atlas(x.name, x.size, p); + if (auto p2 = val->pass_mode(); p && p2 != p) + { + int m = p2 ? int(*p2) : -1; + const auto name = val->name(); + fm_throw("atlas {} wrong pass mode {} should be {}"_cf, std::string_view{name.data(), name.size()}, m, std::uint8_t(*p)); + } } } |