From 1b84fc144f77c4ebef6fdc0a476410420e0a95b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Oct 2022 18:31:18 +0200 Subject: refactoring work --- editor/editor.cpp | 7 ++++--- editor/editor.hpp | 4 ++-- editor/update.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'editor') diff --git a/editor/editor.cpp b/editor/editor.cpp index b3e3aec6..0cd15d17 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -66,7 +66,7 @@ void tile_editor::select_tile(const std::shared_ptr& atlas, std::siz fm_assert(atlas); clear_selection(); _selection_mode = sel_tile; - _selected_tile = { atlas, variant % atlas->num_tiles() }; + _selected_tile = { atlas, decltype(tile_image::variant)(variant % atlas->num_tiles()) }; } void tile_editor::select_tile_permutation(const std::shared_ptr& atlas) @@ -118,12 +118,13 @@ void fisher_yates(T begin, T end) tile_image tile_editor::get_selected_perm() { auto& [atlas, vec] = _permutation; - const std::size_t N = atlas->num_tiles(); + using variant_t = decltype(tile_image::variant); + const auto N = (variant_t)atlas->num_tiles(); if (N == 0) return {}; if (vec.empty()) { - for (std::size_t i = 0; i < N; i++) + for (variant_t i = 0; i < N; i++) vec.push_back(i); fisher_yates(vec.begin(), vec.end()); } diff --git a/editor/editor.hpp b/editor/editor.hpp index 4b1ba124..9203cd6e 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -2,7 +2,7 @@ #include "compat/defs.hpp" #include "tile-atlas.hpp" #include "global-coords.hpp" -#include "tile.hpp" +#include "tile-image.hpp" #include #include @@ -33,7 +33,7 @@ private: std::string _name; std::map> _atlases; tile_image _selected_tile; - std::tuple, std::vector> _permutation; + std::tuple, std::vector> _permutation; selection_mode _selection_mode = sel_none; editor_mode _mode; rotation _rotation{}; diff --git a/editor/update.cpp b/editor/update.cpp index d4bfa2d5..f22ad522 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -18,7 +18,7 @@ void app::maybe_initialize_chunk_(const chunk_coords& pos, chunk& c) #else const auto& atlas = pt.x == N/2 || pt.y == N/2 ? _floor2 : _floor1; #endif - x.ground_image = { atlas, k % atlas->num_tiles() }; + x.ground_image = { atlas, decltype(tile_image::variant)(k % atlas->num_tiles()) }; } #ifdef FM_NO_BINDINGS const auto& wall1 = floor1, wall2 = floor1; -- cgit v1.2.3