MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / deserialize_type

Method deserialize_type

modules/engine/runtime/src/ecs/serialize.cpp:148–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148sugoi_entity_type_t sugoi_storage_t::deserialize_type(sugoi::fixed_stack_t& stack, skr_binary_reader_t* s, bool keepMeta)
149{
150 using namespace sugoi;
151 namespace bin = skr::binary;
152 // deserialize type, and get/create group from it
153 sugoi_entity_type_t type = {};
154 bin::Archive(s, type.type.length);
155 auto guids = stack.allocate<guid_t>(type.type.length);
156 ArchiveBuffer(s, guids, type.type.length);
157 type.type.data = stack.allocate<sugoi_type_index_t>(type.type.length);
158 auto& reg = type_registry_t::get();
159 forloop (i, 0, type.type.length) // todo: check type existence
160 ((sugoi_type_index_t*)type.type.data)[i] = reg.guid2type[guids[i]];
161 std::sort((sugoi_type_index_t*)type.type.data, (sugoi_type_index_t*)type.type.data + type.type.length);
162 if(keepMeta)
163 {
164 bin::Archive(s, type.meta.length);
165 if (type.meta.length > 0)
166 {
167 // todo: how to patch meta? guid?
168 type.meta.data = stack.allocate<sugoi_entity_t>(type.meta.length);
169 ArchiveBuffer(s, type.meta.data, type.meta.length);
170 std::sort((sugoi_entity_t*)type.meta.data, (sugoi_entity_t*)type.meta.data + type.meta.length);
171 }
172 }
173 return type;
174}
175
176void sugoi_storage_t::serialize_single(sugoi_entity_t e, skr_binary_writer_t* s)
177{

Callers

nothing calls this directly

Calls 4

ArchiveFunction · 0.85
ArchiveBufferFunction · 0.85
getFunction · 0.50
sortFunction · 0.50

Tested by

no test coverage detected