summaryrefslogtreecommitdiffhomepage
path: root/serialize
diff options
context:
space:
mode:
Diffstat (limited to 'serialize')
-rw-r--r--serialize/packbits-read.cpp9
-rw-r--r--serialize/packbits-write.cpp2
-rw-r--r--serialize/scenery.hpp1
-rw-r--r--serialize/wall-atlas.cpp13
-rw-r--r--serialize/wall-atlas.hpp3
-rw-r--r--serialize/world-reader.cpp2
-rw-r--r--serialize/world-writer.cpp12
7 files changed, 16 insertions, 26 deletions
diff --git a/serialize/packbits-read.cpp b/serialize/packbits-read.cpp
index 9980ca63..cc3fc3bd 100644
--- a/serialize/packbits-read.cpp
+++ b/serialize/packbits-read.cpp
@@ -2,15 +2,6 @@
#include "compat/assert.hpp"
#include "compat/exception.hpp"
-namespace floormat::Pack_impl {
-
-void throw_on_read_nonzero() noexcept(false)
-{
- throw std::runtime_error{"extra bits in pack_read()"};
-}
-
-} // namespace floormat::Pack_impl
-
namespace floormat {
using namespace floormat::Pack_impl;
diff --git a/serialize/packbits-write.cpp b/serialize/packbits-write.cpp
index f485a72e..f261abe5 100644
--- a/serialize/packbits-write.cpp
+++ b/serialize/packbits-write.cpp
@@ -33,7 +33,7 @@ static_assert(pack_write(std::tuple{f8<2>{0b10}, f8<3>{0b011}, f8<3>{0b01}}) ==
//static_assert(pack_write(std::tuple{}) == 0);
static_assert(pack_write(std::tuple{f8<1>{0b1}, f8<3>{0b101}, f8<2>{0b10}}) == 0b101011);
-#if 0 // check disasembly
+#if 0 // check disassembly
u32 foo1(u32 a, u32 b, u32 c);
u32 foo1(u32 a, u32 b, u32 c)
{
diff --git a/serialize/scenery.hpp b/serialize/scenery.hpp
index f3ceb586..93ceeb57 100644
--- a/serialize/scenery.hpp
+++ b/serialize/scenery.hpp
@@ -1,6 +1,5 @@
#pragma once
#include "src/scenery.hpp"
-#include <vector>
#include <Corrade/Containers/String.h>
#include <nlohmann/json_fwd.hpp>
diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp
index 0ba1c297..b2e7c2f5 100644
--- a/serialize/wall-atlas.cpp
+++ b/serialize/wall-atlas.cpp
@@ -5,6 +5,7 @@
#include "loader/loader.hpp"
#include "pass-mode.hpp"
#include "json-helper.hpp"
+#include "corrade-array.hpp"
#include <utility>
#include <string_view>
#include <Corrade/Containers/ArrayViewStl.h>
@@ -42,7 +43,7 @@ namespace {
struct direction_triple
{
- std::vector<Direction> array;
+ Array<Direction> array;
std::array<DirArrayIndex, Direction_COUNT> map;
std::bitset<Direction_COUNT> mask;
};
@@ -53,7 +54,7 @@ direction_triple read_all_directions(const json& jroot)
for (auto [str, _] : wall_atlas::directions)
if (jroot.contains(str))
count++;
- direction_triple ret = { std::vector<Direction>{count},
+ direction_triple ret = { Array<Direction>{count},
std::array<DirArrayIndex, Direction_COUNT>{},
std::bitset<Direction_COUNT>{0}, };
auto& [array, map, mask] = ret;
@@ -108,7 +109,7 @@ wall_atlas_def wall_atlas_def::deserialize(StringView filename)
fm_soft_assert(loader.check_atlas_name(atlas.header.name));
atlas.frames = read_all_frames(jroot);
auto [dirs, dir_indexes, mask] = read_all_directions(jroot);
- fm_soft_assert(!dirs.empty());
+ fm_soft_assert(!dirs.isEmpty());
fm_soft_assert(dir_indexes != std::array<Wall::DirArrayIndex, Direction_COUNT>{});
atlas.direction_array = std::move(dirs);
atlas.direction_map = dir_indexes;
@@ -155,17 +156,17 @@ void wall_atlas::serialize(StringView filename) const
namespace floormat::Wall::detail {
-std::vector<Frame> read_all_frames(const json& jroot)
+Array<Frame> read_all_frames(const json& jroot)
{
if (!jroot.contains("frames"))
return {};
- std::vector<Frame> frames;
+ Array<Frame> frames;
const auto& jframes = jroot["frames"];
fm_assert(jframes.is_array());
const auto sz = jframes.size();
- frames = std::vector<Frame>{sz};
+ frames = Array<Frame>{sz};
for (auto i = 0uz; i < sz; i++)
{
diff --git a/serialize/wall-atlas.hpp b/serialize/wall-atlas.hpp
index e7e553ce..1381591d 100644
--- a/serialize/wall-atlas.hpp
+++ b/serialize/wall-atlas.hpp
@@ -2,13 +2,14 @@
#include "src/wall-atlas.hpp"
#include <bitset>
#include <memory>
+#include <Corrade/Containers/Array.h>
#include <nlohmann/json_fwd.hpp>
namespace floormat::Wall::detail {
using nlohmann::json;
-[[nodiscard]] std::vector<Frame> read_all_frames(const json& jroot);
+[[nodiscard]] Array<Frame> read_all_frames(const json& jroot);
[[nodiscard]] Group read_group_metadata(const json& jgroup);
[[nodiscard]] Direction read_direction_metadata(const json& jroot, Direction_ dir);
Info read_info_header(const json& jroot);
diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp
index 366648d5..ac247553 100644
--- a/serialize/world-reader.cpp
+++ b/serialize/world-reader.cpp
@@ -24,7 +24,7 @@ using namespace floormat::Serialize;
constexpr inline atlasid meta_short_scenery_bit_ = highbits<atlasid, 1, 0>;
constexpr inline atlasid meta_rotation_bits_ = highbits<atlasid, rotation_BITS, 1>;
constexpr inline atlasid scenery_id_flag_mask_ = meta_short_scenery_bit_ | meta_rotation_bits_;
-constexpr inline atlasid scenery_id_max_ = int_max<atlasid> & ~scenery_id_flag_mask_;
+constexpr inline atlasid scenery_id_max_ = int_traits<atlasid>::max & ~scenery_id_flag_mask_;
struct reader_state final {
explicit reader_state(world& world) noexcept;
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp
index fd533cee..649c1e9f 100644
--- a/serialize/world-writer.cpp
+++ b/serialize/world-writer.cpp
@@ -6,7 +6,6 @@
#include "src/global-coords.hpp"
#include "src/chunk.hpp"
#include "src/world.hpp"
-#include "src/emplacer.hpp"
#include "loader/loader.hpp"
#include "src/scenery.hpp"
#include "src/critter.hpp"
@@ -15,7 +14,6 @@
#include "src/light.hpp"
#include "compat/strerror.hpp"
#include <cerrno>
-#include <cstring>
#include <concepts>
#include <vector>
#include <algorithm>
@@ -210,12 +208,12 @@ void write_object_flags(binary_writer<T>& s, const U& e)
void writer_state::serialize_atlases()
{
- fm_assert(tile_images.size() < int_max<atlasid>);
+ fm_assert(tile_images.size() < int_traits<atlasid>::max);
const auto sz = (atlasid)tile_images.size();
const auto atlasbuf_size = sizeof(sz) + atlas_name_max*sz;
atlas_buf.resize(atlasbuf_size);
auto s = binary_writer{atlas_buf.begin()};
- fm_assert(sz <= int_max<atlasid>);
+ fm_assert(sz <= int_traits<atlasid>::max);
s << sz;
@@ -241,7 +239,7 @@ void writer_state::serialize_atlases()
}
constexpr auto atlasbuf_size0 = sizeof(atlasid) + sizeof(scenery);
-constexpr auto atlasbuf_size1 = sizeof(uint8_t) + atlasbuf_size0*int_max<uint8_t> + atlas_name_max;
+constexpr auto atlasbuf_size1 = sizeof(uint8_t) + atlasbuf_size0*int_traits<uint8_t>::max + atlas_name_max;
void writer_state::serialize_scenery_names()
{
@@ -284,7 +282,7 @@ void writer_state::serialize_scenery_names()
auto num = 1uz;
for (auto j = i+1; j < sz && vec[j].s->name == sc->name; j++)
num++;
- fm_assert(num < int_max<uint8_t>);
+ fm_assert(num < int_traits<uint8_t>::max);
s << (uint8_t)num;
fm_assert(sc->name.size() < atlas_name_max);
s.write_asciiz_string(sc->name);
@@ -564,7 +562,7 @@ ArrayView<const char> writer_state::serialize_world()
serialize_strings();
using proto_t = std::decay_t<decltype(proto_version)>;
- fm_assert(_world->size() <= int_max<chunksiz>);
+ fm_assert(_world->size() <= int_traits<chunksiz>::max);
const auto len = fm_begin(
auto len = 0uz;