summaryrefslogtreecommitdiff
path: root/src/serialization.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/serialization.cpp')
-rw-r--r--src/serialization.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/serialization.cpp b/src/serialization.cpp
index b7691fd..e7e1d4c 100644
--- a/src/serialization.cpp
+++ b/src/serialization.cpp
@@ -65,7 +65,10 @@ void pke_deserialize_project_from_stream(std::istream &i, srlztn_deserialize_hel
void pke_serialize_scene(srlztn_serialize_helper *h) {
using CamIterFn = pk_tmpln_1<void, PkeCamera*, void*>;
+ using InstIterFn = pk_tmpln_1<void, CompInstance*, void*>;
CamIterFn cam_iter_cb{};
+ InstIterFn inst_iter_cb{};
+
FontTypeIndex font_type_count;
FontType *fonts = FontType_GetFonts(font_type_count);
for (FontTypeIndex_T b = 0; b < (FontTypeIndex_T)font_type_count; ++b) {
@@ -84,18 +87,14 @@ void pke_serialize_scene(srlztn_serialize_helper *h) {
pke_serialize_ui_box(h, ui_boxes[i]);
}
- pk_handle_bucket_index_T instanceBucketCount = ECS_GetInstances_BucketCount();
- for (pk_handle_bucket_index_T b = 0; b < instanceBucketCount; ++b) {
- pk_handle_item_index_T count;
- auto *instances = ECS_GetInstances(b, count);
- for (pk_handle_item_index_T i = 0; i < count; ++i) {
- const auto &instance = instances[i];
- if (PK_HAS_FLAG(instance.comp_instance_flags, COMPONENT_INSTANCE_FLAG_DO_NOT_SERIALIZE)) {
- continue;
- }
- pke_serialize_instance(h, &instance);
+ inst_iter_cb.func = [&h](CompInstance *instance_ptr) {
+ const auto &instance = *instance_ptr;
+ if (PK_HAS_FLAG(instance.comp_instance_flags, COMPONENT_INSTANCE_FLAG_DO_NOT_SERIALIZE)) {
+ return;
}
- }
+ pke_serialize_instance(h, &instance);
+ };
+ pk_bkt_arr_iterate(ECS_GetInstances(), &InstIterFn::invoke, &inst_iter_cb);
cam_iter_cb.func = [&h](PkeCamera *cam_ptr) {
if (cam_ptr->camHandle == CameraHandle_MAX) {