summaryrefslogtreecommitdiffhomepage
path: root/loader
diff options
context:
space:
mode:
Diffstat (limited to 'loader')
-rw-r--r--loader/atlas.cpp4
-rw-r--r--loader/error-tex.cpp13
-rw-r--r--loader/impl.hpp2
-rw-r--r--loader/texture.cpp2
-rw-r--r--loader/wall-atlas.cpp4
5 files changed, 16 insertions, 9 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index c32ae345..39442b6a 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -30,9 +30,11 @@ bool loader_::check_atlas_name(StringView str) noexcept
{
constexpr auto first_char =
"_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"_s;
+ if (str == "<invalid>"_s)
+ return true;
if (!str || !first_char.find(str[0]))
return false;
- if (str.findAny("\\\"'\n\r\t\a\033\0|$!%{}#^*?<>&;:^"_s) || str.find("/."_s))
+ if (str.findAny("\\\"'\n\r\t\a\033\0|$!%{}^*?<>&;:^"_s) || str.find("/."_s))
return false;
return true;
diff --git a/loader/error-tex.cpp b/loader/error-tex.cpp
index 4cc64f91..7f91f032 100644
--- a/loader/error-tex.cpp
+++ b/loader/error-tex.cpp
@@ -1,15 +1,20 @@
#include "impl.hpp"
+#include "compat/assert.hpp"
+#include <Corrade/Containers/Array.h>
#include <Magnum/Math/Vector4.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/Trade/ImageData.h>
namespace floormat::loader_detail {
-Trade::ImageData2D loader_impl::make_error_texture()
+Trade::ImageData2D loader_impl::make_error_texture(Vector2ui size)
{
- static const Vector4ub data[] = { {255, 0, 255, 255} }; // magenta
- return Trade::ImageData2D{PixelFormat::RGBA8Unorm, {1, 1}, {},
- Containers::arrayView(data, 1), {}, {}};
+ fm_assert(size.product() != 0);
+ constexpr auto magenta = Vector4ub{255, 0, 255, 255};
+ auto array = Array<Vector4ub>{DirectInit, size.product(), magenta};
+ auto img = Trade::ImageData2D{PixelFormat::RGBA8Unorm, Vector2i(size), {},
+ std::move(array), {}, {}};
+ return img;
}
} // namespace floormat::loader_detail
diff --git a/loader/impl.hpp b/loader/impl.hpp
index 84022f8d..4cb9236b 100644
--- a/loader/impl.hpp
+++ b/loader/impl.hpp
@@ -41,7 +41,7 @@ struct loader_impl final : loader_
Optional<Utility::Resource> shader_res;
StringView shader(StringView filename) noexcept override;
- Trade::ImageData2D make_error_texture();
+ Trade::ImageData2D make_error_texture(Vector2ui size);
Trade::ImageData2D texture(StringView prefix, StringView filename, bool fail_ok = true) noexcept(false) override;
// >-----> walls >----->
diff --git a/loader/texture.cpp b/loader/texture.cpp
index 1e4ac709..a12986b4 100644
--- a/loader/texture.cpp
+++ b/loader/texture.cpp
@@ -51,7 +51,7 @@ Trade::ImageData2D loader_impl::texture(StringView prefix, StringView filename_,
if (!fail_ok)
fm_throw("can't open image '{}' (cwd '{}'): {}"_cf, buf, path ? StringView{*path} : "(null)"_s, get_error_string(errbuf));
else
- return make_error_texture();
+ return make_error_texture({1,1});
}
} // namespace floormat::loader_detail
diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp
index 4f13e91a..502cfd0c 100644
--- a/loader/wall-atlas.cpp
+++ b/loader/wall-atlas.cpp
@@ -65,10 +65,10 @@ const wall_info& loader_impl::make_invalid_wall_atlas()
wall_atlas_def {
Wall::Info{.name = name, .depth = 8},
{{ {}, frame_size}, },
- {{ {.index = 0, .count = 1, .pixel_size = frame_size, } } },
+ {{ {.index = 0, .count = 1, .pixel_size = frame_size, .is_defined = true, } } },
{{ {.val = 0}, {}, }},
{1u},
- }, name, make_error_texture());
+ }, name, make_error_texture(frame_size));
invalid_wall_atlas = Pointer<wall_info>{InPlaceInit, wall_info{ .name = name, .atlas = std::move(a) } };
return *invalid_wall_atlas;
}