diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/local-coords.hpp | 2 | ||||
-rw-r--r-- | src/tile-atlas.cpp | 3 | ||||
-rw-r--r-- | src/tile-image.hpp | 24 | ||||
-rw-r--r-- | src/tile.hpp | 20 |
4 files changed, 29 insertions, 20 deletions
diff --git a/src/local-coords.hpp b/src/local-coords.hpp index 2d449aae..01101ded 100644 --- a/src/local-coords.hpp +++ b/src/local-coords.hpp @@ -1,7 +1,7 @@ #pragma once #include "compat/assert.hpp" +#include "compat/int-hash.hpp" #include "tile-defs.hpp" -#include <cstdint> #include <concepts> namespace floormat { diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp index 533cc8e9..e6df942f 100644 --- a/src/tile-atlas.cpp +++ b/src/tile-atlas.cpp @@ -1,5 +1,7 @@ #include "tile-atlas.hpp" #include "compat/assert.hpp" +#include "tile-image.hpp" +#include <limits> #include <Corrade/Containers/StringView.h> #include <Magnum/Math/Color.h> #include <Magnum/ImageView.h> @@ -11,6 +13,7 @@ tile_atlas::tile_atlas(StringView name, const ImageView2D& image, Vector2ub tile texcoords_{make_texcoords_array(Vector2ui(image.size()), tile_count)}, name_{name}, size_{image.size()}, dims_{tile_count} { + fm_assert(num_tiles() <= std::numeric_limits<decltype(tile_image::variant)>::max()); fm_assert(dims_[0] > 0 && dims_[1] > 0); fm_assert(size_ % Vector2ui{tile_count} == Vector2ui()); tex_.setWrapping(GL::SamplerWrapping::ClampToEdge) diff --git a/src/tile-image.hpp b/src/tile-image.hpp new file mode 100644 index 00000000..deb04e9a --- /dev/null +++ b/src/tile-image.hpp @@ -0,0 +1,24 @@ +#pragma once
+#include "compat/integer-types.hpp"
+#include <compare>
+#include <memory>
+
+namespace floormat {
+
+struct tile_atlas;
+
+struct tile_image final
+{
+ std::shared_ptr<tile_atlas> atlas;
+ std::uint8_t variant = (std::uint8_t)-1;
+
+ explicit operator bool() const noexcept { return !!atlas; }
+
+ std::strong_ordering operator<=>(const tile_image& o) const noexcept
+ {
+ const auto ret = atlas.get() <=> o.atlas.get();
+ return ret != std::strong_ordering::equal ? ret : variant <=> o.variant;
+ }
+};
+
+} // namespace floormat
diff --git a/src/tile.hpp b/src/tile.hpp index e8bac834..5103479d 100644 --- a/src/tile.hpp +++ b/src/tile.hpp @@ -1,27 +1,9 @@ #pragma once #include "compat/defs.hpp" -#include "compat/integer-types.hpp" -#include "tile-defs.hpp" -#include <memory> +#include "tile-image.hpp" namespace floormat { -struct tile_atlas; - -struct tile_image final -{ - std::shared_ptr<tile_atlas> atlas; - std::size_t variant = (std::size_t)-1; - - explicit operator bool() const noexcept { return !!atlas; } - - std::strong_ordering operator<=>(const tile_image& o) const noexcept - { - const auto ret = atlas.get() <=> o.atlas.get(); - return ret != std::strong_ordering::equal ? ret : variant <=> o.variant; - } -}; - struct tile final { enum pass_mode : std::uint8_t { pass_blocked, pass_ok, pass_shoot_through, }; |