diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-24 13:35:31 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-24 13:35:31 +0100 |
commit | 27c303a2012995a7a7d4ee1df2ff91dfc427946b (patch) | |
tree | 1608ef0eadd8f70e82ff8d7373b89fd5b230c717 /serialize | |
parent | 1524db15d4e89ad2e7462710c9b1de388fce6ba1 (diff) |
serialize: include scenery offset in save files
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/world-impl.hpp | 4 | ||||
-rw-r--r-- | serialize/world-reader.cpp | 5 | ||||
-rw-r--r-- | serialize/world-writer.cpp | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/serialize/world-impl.hpp b/serialize/world-impl.hpp index 59c57e78..3403631d 100644 --- a/serialize/world-impl.hpp +++ b/serialize/world-impl.hpp @@ -15,6 +15,8 @@ * 2) Tile atlas variant now always a uint8_t. Was uint16_t or uint8_t * depending on value of the tile flag (1 << 6) which is now removed. * 3) Serialize scenery. Tile flag (1 << 6) added. + * 4) Scenery dt now stored as fixed-point uint16_t. + * 5) Serialize scenery pixel offset. */ namespace floormat::Serialize { @@ -33,7 +35,7 @@ template<typename T> constexpr inline T int_max = std::numeric_limits<T>::max(); constexpr inline std::size_t atlas_name_max = 128; constexpr inline auto null_atlas = (atlasid)-1LL; -constexpr inline proto_t proto_version = 4; +constexpr inline proto_t proto_version = 5; constexpr inline proto_t min_proto_version = 1; constexpr inline auto chunk_magic = (std::uint16_t)~0xc0d3; constexpr inline auto scenery_magic = (std::uint16_t)~0xb00b; diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index 34e9e711..e108747e 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -172,6 +172,11 @@ void reader_state::read_chunks(reader_t& s) sc.frame.frame = s.read<std::uint8_t>(); else sc.frame.frame << s; + if (PROTO >= 5) [[likely]] + { + sc.frame.offset[0] << s; + sc.frame.offset[1] << s; + } if (sc.frame.active) { if (PROTO >= 4) [[likely]] diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp index 21fba2b3..f326d90c 100644 --- a/serialize/world-writer.cpp +++ b/serialize/world-writer.cpp @@ -359,6 +359,9 @@ void writer_state::serialize_chunk(const chunk& c, chunk_coords coord) s << (std::uint8_t)scenery.frame; else s << scenery.frame; + s << scenery.offset[0]; + s << scenery.offset[1]; + if (scenery.active) s << scenery.delta; } |