summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/scenery-editor.cpp4
-rw-r--r--src/anim-atlas.cpp12
-rw-r--r--src/anim-atlas.hpp1
3 files changed, 14 insertions, 3 deletions
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp
index dd7ca563..a6870180 100644
--- a/editor/scenery-editor.cpp
+++ b/editor/scenery-editor.cpp
@@ -41,7 +41,11 @@ void scenery_editor::prev_rotation()
void scenery_editor::select_tile(const scenery_& s)
{
+ const auto rot = is_anything_selected() && s.proto.atlas->check_rotation(_selected.proto.frame.r)
+ ? _selected.proto.frame.r
+ : s.proto.frame.r;
_selected = s;
+ _selected.proto.frame.r = rot;
}
void scenery_editor::clear_selection()
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp
index 10d33bac..e7190df2 100644
--- a/src/anim-atlas.cpp
+++ b/src/anim-atlas.cpp
@@ -163,13 +163,19 @@ rotation anim_atlas::prev_rotation_from(rotation r) const noexcept
{
using ssize = std::make_signed_t<std::size_t>;
constexpr auto count = ssize(rotation_COUNT);
- for (auto i = ssize(r)-1; i >= 0; i--)
- if (_group_indices[std::size_t(i)] != 0xff)
- return rotation(i);
+ if (r < rotation_COUNT)
+ for (auto i = ssize(r)-1; i >= 0; i--)
+ if (_group_indices[std::size_t(i)] != 0xff)
+ return rotation(i);
for (auto i = count-1; i >= 0; i--)
if (_group_indices[std::size_t(i)] != 0xff)
return rotation(i);
fm_abort("where did the rotations go?!");
}
+bool anim_atlas::check_rotation(rotation r) const noexcept
+{
+ return r < rotation_COUNT && _group_indices[std::size_t(r)] < 0xff;
+}
+
} // namespace floormat
diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp
index f64e4e01..1a110a2b 100644
--- a/src/anim-atlas.hpp
+++ b/src/anim-atlas.hpp
@@ -37,6 +37,7 @@ struct anim_atlas final
[[nodiscard]] rotation next_rotation_from(rotation r) const noexcept;
[[nodiscard]] rotation prev_rotation_from(rotation r) const noexcept;
+ [[nodiscard]] bool check_rotation(rotation r) const noexcept;
fm_DECLARE_DELETED_COPY_ASSIGNMENT(anim_atlas);