summaryrefslogtreecommitdiffhomepage
path: root/serialize/world-reader.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-02 19:03:32 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-02 20:25:31 +0100
commit5a95eb1282e30bd803d7e0b352a8443795842e42 (patch)
treec97bc43e4d5107a427817c65aa1b0c2eeb64a427 /serialize/world-reader.cpp
parent0fe5336b9a53f20817f54be0bd7cd935db14914c (diff)
fix build with Linux and/or GCC
Diffstat (limited to 'serialize/world-reader.cpp')
-rw-r--r--serialize/world-reader.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp
index aa156609..e55ea059 100644
--- a/serialize/world-reader.cpp
+++ b/serialize/world-reader.cpp
@@ -4,11 +4,10 @@
#include "src/world.hpp"
#include "src/loader.hpp"
#include "src/tile-atlas.hpp"
+#include <cstring>
namespace floormat::Serialize {
-namespace {
-
struct reader_state final {
explicit reader_state(world& world) noexcept;
void deserialize_world(ArrayView<const char> buf);
@@ -21,10 +20,10 @@ private:
void read_chunks(reader_t& reader);
std::unordered_map<atlasid, std::shared_ptr<tile_atlas>> atlases;
- struct world* world;
+ world* _world;
};
-reader_state::reader_state(struct world& world) noexcept : world{&world} {}
+reader_state::reader_state(world& world) noexcept : _world{&world} {}
void reader_state::read_atlases(reader_t& s)
{
@@ -61,7 +60,7 @@ void reader_state::read_chunks(reader_t& s)
chunk_coords coord;
s >> coord.x;
s >> coord.y;
- auto& chunk = (*world)[coord];
+ auto& chunk = (*_world)[coord];
for (std::size_t i = 0; i < TILE_COUNT; i++)
{
const tilemeta flags = s.read<tilemeta>();
@@ -111,8 +110,6 @@ void reader_state::deserialize_world(ArrayView<const char> buf)
s.assert_end();
}
-} // namespace
-
} // namespace floormat::Serialize
namespace floormat {
@@ -121,7 +118,11 @@ world world::deserialize(StringView filename)
{
char errbuf[128];
constexpr auto strerror = []<std::size_t N> (char (&buf)[N]) -> const char* {
+#ifndef _WIN32
+ ::strerror_r(errno, buf, std::size(buf));
+#else
::strerror_s(buf, std::size(buf), errno);
+#endif
return buf;
};
fm_assert(filename.flags() & StringViewFlag::NullTerminated);