4#include "unordered_dense.h"
12 return sizeof(
uint32_t) +
sizeof(
T) * vec.size();
18 memcpy(ptr_in, &length,
sizeof(
uint32_t));
19 memcpy(ptr_in +
sizeof(
uint32_t), vec.data(),
sizeof(
T) * vec.size());
20 return ptr_in +
sizeof(
uint32_t) +
sizeof(
T) * vec.size();
26 memcpy(&length, ptr_in,
sizeof(
uint32_t));
28 memcpy(vec.data(), ptr_in +
sizeof(
uint32_t),
sizeof(
T) * length);
29 return ptr_in +
sizeof(
uint32_t) +
sizeof(
T) * length;
34 memcpy(ptr_in, &obj,
sizeof(
T));
35 return ptr_in +
sizeof(
T);
40 memcpy(&obj, ptr_in,
sizeof(
T));
41 return ptr_in +
sizeof(
T);
44template<
typename T,
typename tag_type>
49template<
typename T,
typename tag_type>
52 memcpy(ptr_in, &length,
sizeof(
uint32_t));
57template<
typename T,
typename tag_type>
60 memcpy(&length, ptr_in,
sizeof(
uint32_t));
62 memcpy(vec.
data(), ptr_in +
sizeof(
uint32_t),
sizeof(
T) * length);
63 return ptr_in +
sizeof(
uint32_t) +
sizeof(
T) * length;
67 ankerl::unordered_dense::map<dcon::text_key, uint32_t, text::vector_backed_ci_hash, text::vector_backed_ci_eq>
const&
73 ankerl::unordered_dense::set<dcon::text_key, text::vector_backed_ci_hash, text::vector_backed_ci_eq>
const&
79 ankerl::unordered_dense::map<dcon::text_key, uint32_t, text::vector_backed_ci_hash, text::vector_backed_ci_eq>
const&
84 ankerl::unordered_dense::set<dcon::text_key, text::vector_backed_ci_hash, text::vector_backed_ci_eq>
const&
89 ankerl::unordered_dense::map<dcon::text_key, uint32_t, text::vector_backed_ci_hash, text::vector_backed_ci_eq>& vec) {
91 memcpy(&length, ptr_in,
sizeof(
uint32_t));
93 std::remove_cvref_t<
decltype(vec.values())> new_vec;
94 new_vec.resize(length);
95 memcpy(new_vec.data(), ptr_in +
sizeof(
uint32_t),
sizeof(vec.values()[0]) * length);
96 vec.replace(std::move(new_vec));
98 return ptr_in +
sizeof(
uint32_t) +
sizeof(vec.values()[0]) * length;
101 ankerl::unordered_dense::set<dcon::text_key, text::vector_backed_ci_hash, text::vector_backed_ci_eq>& vec) {
103 memcpy(&length, ptr_in,
sizeof(
uint32_t));
105 std::remove_cvref_t<
decltype(vec.values())> new_vec;
106 new_vec.resize(length);
107 memcpy(new_vec.data(), ptr_in +
sizeof(
uint32_t),
sizeof(vec.values()[0]) * length);
108 vec.replace(std::move(new_vec));
110 return ptr_in +
sizeof(
uint32_t) +
sizeof(vec.values()[0]) * length;
114 ankerl::unordered_dense::map<dcon::modifier_id, dcon::gfx_object_id, sys::modifier_hash>
const& vec) {
119 ankerl::unordered_dense::map<dcon::modifier_id, dcon::gfx_object_id, sys::modifier_hash>
const& vec) {
123 ankerl::unordered_dense::map<dcon::modifier_id, dcon::gfx_object_id, sys::modifier_hash>& vec) {
125 memcpy(&length, ptr_in,
sizeof(
uint32_t));
127 std::remove_cvref_t<
decltype(vec.values())> new_vec;
128 new_vec.resize(length);
129 memcpy(new_vec.data(), ptr_in +
sizeof(
uint32_t),
sizeof(vec.values()[0]) * length);
130 vec.replace(std::move(new_vec));
132 return ptr_in +
sizeof(
uint32_t) +
sizeof(vec.values()[0]) * length;
135inline size_t serialize_size(ankerl::unordered_dense::map<uint16_t, dcon::text_key>
const& vec) {
144 memcpy(&length, ptr_in,
sizeof(
uint32_t));
146 std::remove_cvref_t<
decltype(vec.values())> new_vec;
147 new_vec.resize(length);
148 memcpy(new_vec.data(), ptr_in +
sizeof(
uint32_t),
sizeof(vec.values()[0]) * length);
149 vec.replace(std::move(new_vec));
151 return ptr_in +
sizeof(
uint32_t) +
sizeof(vec.values()[0]) * length;
169 dcon::national_identity_id
tag;
uint8_t * write_mod_path(uint8_t *ptr_in, native_string const &path_in)
uint8_t * write_scenario_section(uint8_t *ptr_in, sys::state &state)
bool try_read_scenario_as_save_file(sys::state &state, native_string_view name)
size_t sizeof_save_section(sys::state &state)
uint8_t const * read_save_header(uint8_t const *ptr_in, save_header &header_out)
mod_identifier extract_mod_information(uint8_t const *ptr_in, uint64_t file_size)
constexpr uint32_t scenario_file_version
size_t sizeof_mod_path(native_string const &path_in)
uint8_t const * memcpy_deserialize(uint8_t const *ptr_in, T &obj)
uint8_t * write_scenario_header(uint8_t *ptr_in, scenario_header const &header_in)
void write_scenario_file(sys::state &state, native_string_view name, uint32_t count)
uint8_t const * deserialize(uint8_t const *ptr_in, std::vector< T > &vec)
uint8_t * write_save_section(uint8_t *ptr_in, sys::state &state)
scenario_size sizeof_scenario_section(sys::state &state)
uint8_t const * read_scenario_header(uint8_t const *ptr_in, scenario_header &header_out)
void read_mod_path(uint8_t const *ptr_in, uint8_t const *lim, native_string &path_out)
uint8_t * write_save_header(uint8_t *ptr_in, save_header const &header_in)
uint8_t * memcpy_serialize(uint8_t *ptr_in, T const &obj)
bool try_read_scenario_file(sys::state &state, native_string_view name)
size_t serialize_size(std::vector< T > const &vec)
uint8_t * serialize(uint8_t *ptr_in, std::vector< T > const &vec)
uint8_t const * read_save_section(uint8_t const *ptr_in, uint8_t const *section_end, sys::state &state)
size_t sizeof_save_header(save_header const &header_in)
uint8_t * write_compressed_section(uint8_t *ptr_out, uint8_t const *ptr_in, uint32_t uncompressed_size)
bool try_read_save_file(sys::state &state, native_string_view name)
void write_save_file(sys::state &state, save_type type, std::string const &name)
uint8_t const * load_mod_path(uint8_t const *ptr_in, sys::state &state)
size_t sizeof_scenario_header(scenario_header const &header_in)
constexpr uint32_t save_file_version
uint8_t const * read_scenario_section(uint8_t const *ptr_in, uint8_t const *section_end, sys::state &state)
bool try_read_scenario_and_save_file(sys::state &state, native_string_view name)
std::string_view native_string_view
std::string native_string