diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-04-07 11:27:00 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-04-07 11:27:00 -0400 |
| commit | ff63a4b2bf9f096f8cf8c6824e826b3b4d79e747 (patch) | |
| tree | bc5834ffecfa87ad70aac530a14acf38245c515b /src/serialization-component.cpp | |
| parent | 2f57eefb01c478ffe62845b8051bc82036cbb819 (diff) | |
pke: saving and loading scenes works
Diffstat (limited to 'src/serialization-component.cpp')
| -rw-r--r-- | src/serialization-component.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/serialization-component.cpp b/src/serialization-component.cpp index 34eb758..9a29e67 100644 --- a/src/serialization-component.cpp +++ b/src/serialization-component.cpp @@ -47,7 +47,7 @@ bool pke_deserialize_inst_pos(srlztn_deserialize_helper *h, glm::vec3 &pos, glm: long index = 0; do { assert(index < 3); - stn_res = pk_stn_float_e(&pos[index], starting_char, &pEnd); + stn_res = pk_stn(&pos[index], starting_char, &pEnd); if (stn_res != PK_STN_RES_SUCCESS) return false; starting_char = pEnd + 1; ++index; @@ -62,7 +62,7 @@ bool pke_deserialize_inst_pos(srlztn_deserialize_helper *h, glm::vec3 &pos, glm: long index = 0; do { assert(index < 4); - stn_res = pk_stn_float_e(&quat_rot[index], starting_char, &pEnd); + stn_res = pk_stn(&quat_rot[index], starting_char, &pEnd); if (stn_res != PK_STN_RES_SUCCESS) return false; starting_char = pEnd + 1; ++index; @@ -77,7 +77,7 @@ bool pke_deserialize_inst_pos(srlztn_deserialize_helper *h, glm::vec3 &pos, glm: long index = 0; do { assert(index < 3); - stn_res = pk_stn_float_e(&scale[index], starting_char, &pEnd); + stn_res = pk_stn(&scale[index], starting_char, &pEnd); if (stn_res != PK_STN_RES_SUCCESS) return false; starting_char = pEnd + 1; ++index; @@ -156,11 +156,11 @@ bool pke_deserialize_instance(srlztn_deserialize_helper *h) { float mass; InstPos inst_pos; CompInstance comp{}; - glm::vec3 pos; - glm::quat quat_rot; - glm::vec3 scale; + glm::vec3 pos = glm::vec3(0); + glm::quat quat_rot = glm::quat(0, 0, 0, 1); + glm::vec3 scale = glm::vec3(1); comp.collisionCallback.name[0] = '\0'; - while (h->i.getline(h->read_line, h->read_line_len)) { + while (h->i->getline(h->read_line, h->read_line_len)) { if (strstr(SRLZTN_OBJ_END, h->read_line)) { if (et_ptr == nullptr) { fprintf(stdout, "[Game::DeserializeInstance] Unknown EntityTypeCode, skipping instance.\n"); @@ -198,18 +198,18 @@ bool pke_deserialize_instance(srlztn_deserialize_helper *h) { if (strstr(h->read_line, SRLZTN_INSTANCE_COMPONENT_ENTITY_HANDLE)) { prefix_len = strlen(SRLZTN_INSTANCE_COMPONENT_ENTITY_HANDLE); sprintf(handle_str, "%.10s%c%s", h->read_line + prefix_len, '\0', h->read_line + prefix_len + 10); - stn_res = pk_stn(&comp.entHandle.bucketIndex, handle_str, 16); + stn_res = pk_stn(&comp.entHandle.bucketIndex, handle_str, nullptr, 16); if (stn_res != PK_STN_RES_SUCCESS) return false; - stn_res = pk_stn(&comp.entHandle.itemIndex, handle_str + 11, 16); + stn_res = pk_stn(&comp.entHandle.itemIndex, handle_str + 11, nullptr, 16); if (stn_res != PK_STN_RES_SUCCESS) return false; continue; } if (strstr(h->read_line, SRLZTN_INSTANCE_COMPONENT_HANDLE)) { prefix_len = strlen(SRLZTN_INSTANCE_COMPONENT_HANDLE); sprintf(handle_str, "%.10s%c%s", h->read_line + prefix_len, '\0', h->read_line + prefix_len + 10); - stn_res = pk_stn(&comp.instanceHandle.bucketIndex, handle_str, 16); + stn_res = pk_stn(&comp.instanceHandle.bucketIndex, handle_str, nullptr, 16); if (stn_res != PK_STN_RES_SUCCESS) return false; - stn_res = pk_stn(&comp.instanceHandle.itemIndex, handle_str + 11, 16); + stn_res = pk_stn(&comp.instanceHandle.itemIndex, handle_str + 11, nullptr, 16); if (stn_res != PK_STN_RES_SUCCESS) return false; continue; } @@ -227,19 +227,19 @@ bool pke_deserialize_instance(srlztn_deserialize_helper *h) { } if (strstr(h->read_line, SRLZTN_INSTANCE_COMPONENT_MASS)) { prefix_len = strlen(SRLZTN_INSTANCE_COMPONENT_MASS); - stn_res = pk_stn(&mass, h->read_line + prefix_len); + stn_res = pk_stn(&mass, h->read_line + prefix_len, nullptr); if (stn_res != PK_STN_RES_SUCCESS) return false; continue; } if (strstr(h->read_line, SRLZTN_INSTANCE_COMPONENT_COLLISION_LAYER)) { prefix_len = strlen(SRLZTN_INSTANCE_COMPONENT_COLLISION_LAYER); - stn_res = pk_stn(&comp.physicsLayer, h->read_line + prefix_len, 10); + stn_res = pk_stn(&comp.physicsLayer, h->read_line + prefix_len, nullptr, 10); if (stn_res != PK_STN_RES_SUCCESS) return false; continue; } if (strstr(h->read_line, SRLZTN_INSTANCE_COMPONENT_COLLISION_MASK)) { prefix_len = strlen(SRLZTN_INSTANCE_COMPONENT_COLLISION_MASK); - stn_res = pk_stn(&comp.physicsMask, h->read_line + prefix_len, 10); + stn_res = pk_stn(&comp.physicsMask, h->read_line + prefix_len, nullptr, 10); if (stn_res != PK_STN_RES_SUCCESS) return false; continue; } |
