diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-28 22:47:20 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-28 22:47:20 +0200 |
commit | 9954b8b4f5fb95470e127a4f24a0c73289dd49a9 (patch) | |
tree | cf1586b0ebc57837714fc809d523e847f0e286db /serialize | |
parent | 280b4c235fe11dd629f882f0fb5054384fcee1d7 (diff) |
a
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/world-impl.hpp | 4 | ||||
-rw-r--r-- | serialize/world-reader.cpp | 9 | ||||
-rw-r--r-- | serialize/world-writer.cpp | 2 |
3 files changed, 6 insertions, 9 deletions
diff --git a/serialize/world-impl.hpp b/serialize/world-impl.hpp index 26073edd..252f361e 100644 --- a/serialize/world-impl.hpp +++ b/serialize/world-impl.hpp @@ -1,5 +1,3 @@ -#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-macros"
#ifndef FM_SERIALIZE_WORLD_IMPL
#error "not meant to be included directly"
#endif
@@ -56,5 +54,3 @@ private: } // namespace
} // namespace floormat
-
-#pragma clang diagnostic pop
diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index 299386de..4b5d365c 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -64,7 +64,7 @@ void reader_state::read_chunks(reader_t& s) for (std::size_t i = 0; i < TILE_COUNT; i++)
{
const tilemeta flags = s.read<tilemeta>();
- const auto make_atlas = [&] -> tile_image {
+ const auto make_atlas = [&]() -> tile_image {
auto atlas = lookup_atlas(s.read<atlasid>());
auto id = s.read<imgvar>();
return { atlas, id };
@@ -120,7 +120,7 @@ world world::deserialize(StringView filename) return buf;
};
fm_assert(filename.flags() & StringViewFlag::NullTerminated);
- FILE_raii f = ::fopen(filename.data(), "r");
+ FILE_raii f = ::fopen(filename.data(), "rb");
if (!f)
fm_abort("fopen(\"%s\", \"r\"): %s", filename.data(), strerror(errbuf));
if (int ret = ::fseek(f, 0, SEEK_END); ret != 0)
@@ -133,8 +133,9 @@ world world::deserialize(StringView filename) if (int ret = ::fseek(f, 0, SEEK_SET); ret != 0)
fm_abort("fseek(SEEK_SET): %s", strerror(errbuf));
auto buf_ = std::make_unique<char[]>(len);
- if (auto ret = ::fread(&buf_[0], len, 1, f); ret != 1)
- fm_abort("fread %zu: %s", len, strerror(errbuf));
+
+ if (auto ret = ::fread(&buf_[0], 1, len, f); ret != len)
+ fm_abort("fread short read: %s", strerror(errbuf));
world w;
Serialize::reader_state s{w};
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp index c0f59e9b..faf60849 100644 --- a/serialize/world-writer.cpp +++ b/serialize/world-writer.cpp @@ -217,7 +217,7 @@ void world::serialize(StringView filename) fm_assert(filename.flags() & StringViewFlag::NullTerminated);
if (Path::exists(filename))
Path::remove(filename);
- FILE_raii file = ::fopen(filename.data(), "w");
+ FILE_raii file = ::fopen(filename.data(), "wb");
if (!file)
fm_abort("fopen(\"%s\", \"w\"): %s", filename.data(), strerror(errbuf));
Serialize::writer_state s{*this};
|