diff options
Diffstat (limited to 'src/game.cpp')
| -rw-r--r-- | src/game.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/game.cpp b/src/game.cpp index 2edea8c..630495a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -54,6 +54,7 @@ const char *PKE_FILE_OBJ_CAMERA = "Camera:"; const char *PKE_FILE_INSTANCE_HANDLE = "Inst::InstHandle: "; const char *PKE_FILE_INSTANCE_ENTITY_HANDLE = "EntityHandle: "; const char *PKE_FILE_INSTANCE_ENTITY_TYPE_CODE = "EntityTypeCode: "; +const char *PKE_FILE_INSTANCE_UUID = "UUID: "; const char *PKE_FILE_INSTANCE_POS_POS = "InstPos::Pos: "; const char *PKE_FILE_INSTANCE_POS_ROT = "InstPos::Rot: "; const char *PKE_FILE_INSTANCE_POS_SCALE = "InstPos::Scale: "; @@ -68,6 +69,7 @@ const char *PKE_FILE_CAMERA_POS = "Cam::Pos: "; const char *PKE_FILE_CAMERA_ROT = "Cam::Rot: "; const char *PKE_FILE_CAMERA_TARGET = "Cam::Target: "; const char *PKE_FILE_CAMERA_TYPE = "Cam::Type: "; +const char *PKE_FILE_CAMERA_UUID = "Cam::UUID: "; const char *PKE_FILE_CAMERA_ORIENTATION = "Cam::Orientation: "; const char *PKE_FILE_CAMERA_INSTANCE_HANDLE = "Cam::InstanceHandle: "; const char *PKE_FILE_CAMERA_TARGET_INSTANCE_HANDLE = "Cam::TargetInstanceHandle: "; @@ -76,6 +78,9 @@ const char *PKE_FILE_CAMERA_IS_PRIMARY = "Cam::IsPrimary: "; void SerializeCamera(std::ostream &stream, const PkeCamera &cam) { NULL_CHAR_ARR(handleStr, 23); PkeCamera c{}; + if (cam.uuid != pk_uuid_zed && cam.uuid != pk_uuid_max) { + stream << PKE_FILE_CAMERA_UUID << cam.uuid << std::endl; + } if (cam.type != c.type) { stream << PKE_FILE_CAMERA_TYPE << int(static_cast<PkeCameraType_T>(cam.type)) << std::endl; } @@ -115,6 +120,9 @@ void SerializeInstance(std::ostream &stream, const CompInstance &comp) { snprintf(handleStr, 22, "0x%08X 0x%08X", comp.instanceHandle.bucketIndex, comp.instanceHandle.itemIndex); stream << PKE_FILE_INSTANCE_HANDLE << handleStr << std::endl; } + if (comp.uuid != pk_uuid_zed && comp.uuid != pk_uuid_max) { + stream << PKE_FILE_INSTANCE_UUID << comp.uuid << std::endl; + } if (et != nullptr) { stream << PKE_FILE_INSTANCE_ENTITY_TYPE_CODE << et->entityTypeCode.val << std::endl; } else if (PkeCamera_Get(comp.entHandle)) { @@ -286,8 +294,17 @@ void DeserializeInstance(Entity_Base *parentEntity, std::istream &stream) { if (skipEntCreate == false) { if (etPtr != nullptr && etPtr->createInstanceCallback.func != nullptr) { - typedef Entity_Base *CreateInst(); - entity = reinterpret_cast<CreateInst*>(etPtr->createInstanceCallback.func)(); + /* TODO 2025-03-27 JCB + * We have not yet defined what the appropriate callback signature + * for creating an entity instance is. + * What should be passed as arguments? What would need to be passed + * that couldn't be accessed globally? + * Consider changing this callback to trigger after creating a + * generic instance, rather than *creating* it. + */ + // typedef Entity_Base *CreateInst(); + // entity = reinterpret_cast<CreateInst*>(etPtr->createInstanceCallback.func)(); + fprintf(stderr, "[%s] Attempted to call EntityType::createInstanceCallback and we have not yet defined a valid function signature", __FILE__); } else { entity = EntityType_CreateGenericInstance(etPtr, parentEntity, &comp, &mapping.newInstance); fprintf(stdout ,"[Game::DeserializeInstance] Debug: entTypeCode '%s' does not have a registered callback func to handle instance creation.\n", entTypeCode); @@ -444,21 +461,23 @@ void Game_SaveSceneFile(const char *sceneFilePath) { } stream << PKE_FILE_END << std::endl; - } - catch (...) { - failed = true; + } catch (std::exception e) { + fprintf(stderr, "[%s][Game_SaveSceneFile] Failed to serialize scene file: %s\n", __FILE__, e.what()); + failed = false; + } catch (...) { + fprintf(stderr, "[%s][Game_SaveSceneFile] Failed to serialize scene file, uncaught exception.\n", __FILE__); + failed = false; } if (failed == false) { std::ofstream f(sceneFilePath); - if (f.is_open()) { - f << stream.str(); - - f.flush(); - f.close(); - } else { + if (!f.is_open()) { failed = true; + } else { + f << stream.str(); } + f.flush(); + f.close(); } if (failed) { |
