summaryrefslogtreecommitdiffhomepage
path: root/loader/atlas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'loader/atlas.cpp')
-rw-r--r--loader/atlas.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index 584d6b5a..d7f21ce5 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -1,5 +1,6 @@
#include "impl.hpp"
#include "compat/assert.hpp"
+#include "compat/exception.hpp"
#include "src/emplacer.hpp"
#include "src/tile-atlas.hpp"
#include "src/anim-atlas.hpp"
@@ -7,15 +8,15 @@
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedArrayView.h>
-#include <Corrade/Containers/StringView.h>
+#include <Corrade/Containers/StringStlView.h>
#include <Corrade/Utility/Path.h>
#include <Magnum/Trade/ImageData.h>
namespace floormat::loader_detail {
-std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size)
+std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size) noexcept(false)
{
- fm_assert(check_atlas_name(name));
+ fm_soft_assert(check_atlas_name(name));
const emplacer e{[&] { return std::make_shared<struct tile_atlas>(name, texture(IMAGE_PATH, name), size); }};
auto atlas = tile_atlas_map.try_emplace(name, e).first->second;
@@ -29,9 +30,9 @@ ArrayView<String> loader_impl::anim_atlas_list()
return anim_atlases;
}
-std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView dir)
+std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView dir) noexcept(false)
{
- fm_assert(check_atlas_name(name));
+ fm_soft_assert(check_atlas_name(name));
if (auto it = anim_atlas_map.find(name); it != anim_atlas_map.end())
return it->second;
@@ -47,7 +48,7 @@ std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView
auto it = std::find_if(anim_info.groups.cbegin(), anim_info.groups.cend(),
[&](const anim_group& x) { return x.name == group.mirror_from; });
if (it == anim_info.groups.cend())
- fm_abort("can't find group '%s' to mirror from '%s'", group.mirror_from.data(), group.name.data());
+ fm_throw("can't find group '{}' to mirror from '{}'"_cf, group.mirror_from.data(), group.name.data());
group.frames = it->frames;
for (anim_frame& f : group.frames)
f.ground = Vector2i((Int)f.size[0] - f.ground[0], f.ground[1]);
@@ -56,14 +57,14 @@ std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView
auto tex = texture("", path);
- fm_assert(!anim_info.object_name.isEmpty());
- fm_assert(anim_info.pixel_size.product() > 0);
- fm_assert(!anim_info.groups.empty());
- fm_assert(anim_info.nframes > 0);
- fm_assert(anim_info.nframes == 1 || anim_info.fps > 0);
+ fm_soft_assert(!anim_info.object_name.isEmpty());
+ fm_soft_assert(anim_info.pixel_size.product() > 0);
+ fm_soft_assert(!anim_info.groups.empty());
+ fm_soft_assert(anim_info.nframes > 0);
+ fm_soft_assert(anim_info.nframes == 1 || anim_info.fps > 0);
const auto size = tex.pixels().size();
const auto width = size[1], height = size[0];
- fm_assert(Vector2uz{anim_info.pixel_size} == Vector2uz{width, height});
+ fm_soft_assert(Vector2uz{anim_info.pixel_size} == Vector2uz{width, height});
auto atlas = std::make_shared<struct anim_atlas>(path, tex, std::move(anim_info));
return anim_atlas_map[atlas->name()] = atlas;