diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-11 04:07:58 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-11 04:07:58 +0100 |
commit | be5ca3208891a8d45cbb7f9c25905f46332572a0 (patch) | |
tree | 04d89404a2aecb26f0dc2299bffdfba4f5eb8df3 /loader | |
parent | eaa6c76bd92e292ac59dcfa0a7aa70cd1e2f50fb (diff) |
w
Diffstat (limited to 'loader')
-rw-r--r-- | loader/atlas.cpp | 5 | ||||
-rw-r--r-- | loader/impl.hpp | 4 | ||||
-rw-r--r-- | loader/loader.hpp | 4 | ||||
-rw-r--r-- | loader/wall-atlas.cpp | 7 |
4 files changed, 10 insertions, 10 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp index de1d8e15..c32ae345 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -42,12 +42,11 @@ bool loader_::check_atlas_name(StringView str) noexcept namespace floormat::loader_detail { -std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size, Optional<pass_mode> pass) noexcept(false) +std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size, pass_mode pass) noexcept(false) { if (auto it = tile_atlas_map.find(name); it != tile_atlas_map.end()) { - if (pass) - fm_assert(it->second->pass_mode() == pass); + fm_assert(it->second->pass_mode() == pass); return it->second; } diff --git a/loader/impl.hpp b/loader/impl.hpp index c5fe83b2..84022f8d 100644 --- a/loader/impl.hpp +++ b/loader/impl.hpp @@ -51,7 +51,7 @@ struct loader_impl final : loader_ Pointer<wall_info> invalid_wall_atlas; - const wall_info& wall_atlas(StringView name, bool fail_ok = true) override; + std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = true) override; ArrayView<const wall_info> wall_atlas_list() override; void get_wall_atlas_list(); const wall_info& make_invalid_wall_atlas(); @@ -60,7 +60,7 @@ struct loader_impl final : loader_ // >-----> tile >-----> tsl::robin_map<StringView, std::shared_ptr<class tile_atlas>> tile_atlas_map; - std::shared_ptr<class tile_atlas> tile_atlas(StringView filename, Vector2ub size, Optional<pass_mode> pass) noexcept(false) override; + std::shared_ptr<class tile_atlas> tile_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) override; std::shared_ptr<class tile_atlas> tile_atlas(StringView filename) noexcept(false) override; // >-----> anim >-----> diff --git a/loader/loader.hpp b/loader/loader.hpp index e7824aa5..02c5dc67 100644 --- a/loader/loader.hpp +++ b/loader/loader.hpp @@ -29,11 +29,11 @@ struct loader_ virtual StringView shader(StringView filename) noexcept = 0; virtual Trade::ImageData2D texture(StringView prefix, StringView filename, bool fail_ok = true) noexcept(false) = 0; // todo remove Optional when wall_atlas is fully implemented -sh 20231122 - virtual std::shared_ptr<class tile_atlas> tile_atlas(StringView filename, Vector2ub size, Optional<pass_mode> pass) noexcept(false) = 0; + virtual std::shared_ptr<class tile_atlas> tile_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) = 0; virtual std::shared_ptr<class tile_atlas> tile_atlas(StringView filename) noexcept(false) = 0; virtual ArrayView<const String> anim_atlas_list() = 0; virtual std::shared_ptr<class anim_atlas> anim_atlas(StringView name, StringView dir = ANIM_PATH) noexcept(false) = 0; - virtual const wall_info& wall_atlas(StringView name, bool fail_ok = true) = 0; + virtual std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = true) = 0; virtual ArrayView<const wall_info> wall_atlas_list() = 0; static void destroy(); static loader_& default_loader() noexcept; diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp index 9d5c8c2b..026bd6d5 100644 --- a/loader/wall-atlas.cpp +++ b/loader/wall-atlas.cpp @@ -46,6 +46,7 @@ std::shared_ptr<wall_atlas> loader_impl::get_wall_atlas(StringView name, StringV auto tex = texture(""_s, path); fm_soft_assert(name == def.header.name); + fm_soft_assert(!def.frames.empty()); auto atlas = std::make_shared<class wall_atlas>(std::move(def), path, tex); return atlas; } @@ -70,7 +71,7 @@ const wall_info& loader_impl::make_invalid_wall_atlas() return *invalid_wall_atlas; } -const wall_info& loader_impl::wall_atlas(StringView name, bool fail_ok) +std::shared_ptr<class wall_atlas> loader_impl::wall_atlas(StringView name, bool fail_ok) { fm_soft_assert(check_atlas_name(name)); char buf[FILENAME_MAX]; @@ -82,12 +83,12 @@ const wall_info& loader_impl::wall_atlas(StringView name, bool fail_ok) if (!fail_ok) fm_throw("no such wall atlas '{}'"_cf, name); else - return make_invalid_wall_atlas(); + return make_invalid_wall_atlas().atlas; } fm_assert(it->second != nullptr); if (!it->second->atlas) it->second->atlas = get_wall_atlas(it->second->name, path); - return *it->second; + return it->second->atlas; } void loader_impl::get_wall_atlas_list() |