summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/exception.hpp2
-rw-r--r--loader/atlas.cpp107
-rw-r--r--loader/ground-atlas.cpp6
-rw-r--r--src/raycast.cpp6
-rw-r--r--src/tile.cpp2
-rw-r--r--test/path-search-result.cpp2
-rw-r--r--test/path-search.cpp2
-rw-r--r--wall-tileset-tool/main.cpp1
8 files changed, 21 insertions, 107 deletions
diff --git a/compat/exception.hpp b/compat/exception.hpp
index 8a5f34fb..eff75225 100644
--- a/compat/exception.hpp
+++ b/compat/exception.hpp
@@ -23,7 +23,7 @@ private:
template<typename Fmt, typename... Ts>
exception::exception(const Fmt& fmt, Ts&&... args) noexcept
{
- fmt::format_to(std::back_inserter(buf), fmt, Corrade::Utility::forward<Ts>(args)...);
+ fmt::format_to(std::back_inserter(buf), fmt, Corrade::Utility::forward<Ts>(args)...); // todo remove <iterator>
buf.push_back('\0');
}
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index b39bc8f5..a4c38264 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -1,18 +1,15 @@
#include "impl.hpp"
-#include "compat/assert.hpp"
+//#include "compat/assert.hpp"
#include "compat/exception.hpp"
-#include "src/emplacer.hpp"
-#include "src/anim-atlas.hpp"
-#include <cstdio>
-#include <algorithm>
-#include <Corrade/Containers/ArrayView.h>
-#include <Corrade/Containers/Pair.h>
-#include <Corrade/Containers/StridedArrayView.h>
-#include <Corrade/Containers/String.h>
-#include <Corrade/Utility/Path.h>
-#include <Magnum/Trade/ImageData.h>
-
-// todo rename file to 'scenery.cpp'
+//#include "src/emplacer.hpp"
+//#include "src/anim-atlas.hpp"
+#include <cstring>
+//#include <cstdio>
+//#include <Corrade/Containers/ArrayView.h>
+//#include <Corrade/Containers/Pair.h>
+//#include <Corrade/Containers/StridedArrayView.h>
+//#include <Corrade/Containers/String.h>
+//#include <Magnum/Trade/ImageData.h>
namespace floormat {
@@ -32,7 +29,7 @@ bool loader_::check_atlas_name(StringView str) noexcept
{
constexpr auto first_char =
"@_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"_s;
- if (str == "<invalid>"_s)
+ if (str == loader.INVALID)
return true;
if (!str || !first_char.find(str[0]))
return false;
@@ -42,86 +39,4 @@ bool loader_::check_atlas_name(StringView str) noexcept
return true;
}
-std::shared_ptr<class anim_atlas>
-loader_::get_anim_atlas(StringView path) noexcept(false)
-{
-
- auto anim_info = deserialize_anim_def(path + ".json");
-
- for (anim_group& group : anim_info.groups)
- {
- if (!group.mirror_from.isEmpty())
- {
- 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_throw("can't find group '{}' to mirror from '{}'"_cf, group.mirror_from, group.name);
- group.frames = array(arrayView(it->frames));
- for (anim_frame& f : group.frames)
- f.ground = Vector2i((Int)f.size[0] - f.ground[0], f.ground[1]);
- }
- }
-
- auto tex = texture(""_s, path);
-
- fm_soft_assert(!anim_info.object_name.isEmpty());
- fm_soft_assert(anim_info.pixel_size.product() > 0);
- fm_soft_assert(!anim_info.groups.isEmpty());
- 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_soft_assert(anim_info.pixel_size[0] == width && anim_info.pixel_size[1] == height);
-
- auto atlas = std::make_shared<class anim_atlas>(path, tex, std::move(anim_info));
- return atlas;
-}
-
} // namespace floormat
-
-
-
-namespace floormat::loader_detail {
-
-ArrayView<const String> loader_impl::anim_atlas_list()
-{
- if (anim_atlases.empty())
- get_anim_atlas_list();
- fm_assert(!anim_atlases.empty());
- return { anim_atlases.data(), anim_atlases.size() };
-}
-
-std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView dir) noexcept(false)
-{
- fm_soft_assert(check_atlas_name(name));
- fm_soft_assert(!dir || dir[dir.size()-1] == '/');
- char buf[FILENAME_MAX];
- auto path = make_atlas_path(buf, dir, name);
-
- if (auto it = anim_atlas_map.find(path); it != anim_atlas_map.end())
- return it->second;
- else
- {
- auto atlas = get_anim_atlas(path);
- return anim_atlas_map[atlas->name()] = atlas;
- }
-}
-
-void loader_impl::get_anim_atlas_list()
-{
- anim_atlases.clear();
- using f = Path::ListFlag;
- constexpr auto flags = f::SkipDirectories | f::SkipDotAndDotDot | f::SkipSpecial | f::SortAscending;
- if (const auto list = Path::list(ANIM_PATH, flags); list)
- {
- anim_atlases.reserve(list->size());
- constexpr auto suffix = ".json"_s;
- for (StringView str : *list)
- if (str.hasSuffix(suffix))
- anim_atlases.emplace_back(str.exceptSuffix(suffix.size()));
- }
- anim_atlases.shrink_to_fit();
- fm_assert(!anim_atlases.empty());
-}
-
-} // namespace floormat::loader_detail
diff --git a/loader/ground-atlas.cpp b/loader/ground-atlas.cpp
index b5e3d546..ba4eaeb0 100644
--- a/loader/ground-atlas.cpp
+++ b/loader/ground-atlas.cpp
@@ -17,7 +17,7 @@ using loader_detail::loader_impl;
std::shared_ptr<ground_atlas>
loader_::get_ground_atlas(StringView name, Vector2ub size, pass_mode pass) noexcept(false)
{
- fm_assert(name != "<invalid>"_s);
+ fm_assert(name != loader.INVALID);
char buf[FILENAME_MAX];
auto filename = make_atlas_path(buf, loader.GROUND_TILESET_PATH, name);
@@ -94,7 +94,7 @@ missing_warn:
ground_atlas_map[string_view] = (ground_info*)-1;
}
- if (name != "<invalid>")
+ if (name != loader.INVALID)
DBG_nospace << "ground_atlas '" << name << "' doesn't exist";
missing_ok:
@@ -132,7 +132,7 @@ void loader_impl::get_ground_atlas_list()
for (auto& x : ground_atlas_array)
{
- fm_soft_assert(x.name != "<invalid>"_s);
+ fm_soft_assert(x.name != loader.INVALID);
fm_soft_assert(check_atlas_name(x.name));
StringView name = x.name;
ground_atlas_map[name] = &x;
diff --git a/src/raycast.cpp b/src/raycast.cpp
index 3e77ecd0..598797eb 100644
--- a/src/raycast.cpp
+++ b/src/raycast.cpp
@@ -1,9 +1,9 @@
#include "raycast-diag.hpp"
#include "tile-constants.hpp"
#include "pass-mode.hpp"
-#include "src/world.hpp"
-#include "src/object.hpp"
-#include "src/RTree-search.hpp"
+#include "world.hpp"
+#include "object.hpp"
+#include "RTree-search.hpp"
#include <cfloat>
#include <bit>
#include <Corrade/Containers/StructuredBindings.h>
diff --git a/src/tile.cpp b/src/tile.cpp
index 07f162e6..89e49017 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -1,7 +1,7 @@
#include "tile.hpp"
#include "tile-constants.hpp"
#include "chunk.hpp"
-#include "src/ground-atlas.hpp"
+#include "ground-atlas.hpp"
namespace floormat {
diff --git a/test/path-search-result.cpp b/test/path-search-result.cpp
index 960f43dc..3f9782b4 100644
--- a/test/path-search-result.cpp
+++ b/test/path-search-result.cpp
@@ -5,7 +5,7 @@
namespace floormat {
-void test_app::test_path_search_pool()
+void test_app::test_astar_pool()
{
auto& pool = path_search_result::_pool;
fm_assert(!pool);
diff --git a/test/path-search.cpp b/test/path-search.cpp
index 724b8665..1345f091 100644
--- a/test/path-search.cpp
+++ b/test/path-search.cpp
@@ -341,7 +341,7 @@ void test_bbox()
} // namespace
-void test_app::test_path_search()
+void test_app::test_astar()
{
test_bbox();
}
diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp
index fba34797..f21368c2 100644
--- a/wall-tileset-tool/main.cpp
+++ b/wall-tileset-tool/main.cpp
@@ -7,7 +7,6 @@
#include "src/tile-constants.hpp"
#include "src/wall-atlas.hpp"
#include "serialize/wall-atlas.hpp"
-//#include "serialize/json-helper.hpp"
#include "loader/loader.hpp"
#include <utility>
#include <tuple>