From fbc1cee1f99db90b729db7c8560a5c550ae35cdd Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Mon, 2 Oct 2023 01:33:54 -0400 Subject: [PATCH] Added validation for serialization --- Nuake/src/Scene/Components/NativeScriptComponent.h | 12 +----------- .../Scene/Components/ParticleEmitterComponent.cpp | 5 ++++- Nuake/src/Scene/Components/WrenScriptComponent.h | 8 ++++++++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Nuake/src/Scene/Components/NativeScriptComponent.h b/Nuake/src/Scene/Components/NativeScriptComponent.h index 0a7e17c1..a6850ff1 100644 --- a/Nuake/src/Scene/Components/NativeScriptComponent.h +++ b/Nuake/src/Scene/Components/NativeScriptComponent.h @@ -5,15 +5,5 @@ struct NativeScriptComponent { - //ScriptableEntity* Instance = nullptr; - // - //ScriptableEntity *(*InstantiateScript)(); - //void (*DestroyScript)(NativeScriptComponent*); - // - //template - //void Bind() - //{ - // InstantiateScript = []() { return static_cast(new T()); }; - // DestroyScript = [](NativeScriptComponent* nsc) { delete nsc->Instance; nsc->Instance = nullptr; }; - //} + }; \ No newline at end of file diff --git a/Nuake/src/Scene/Components/ParticleEmitterComponent.cpp b/Nuake/src/Scene/Components/ParticleEmitterComponent.cpp index bb061562..80297e15 100644 --- a/Nuake/src/Scene/Components/ParticleEmitterComponent.cpp +++ b/Nuake/src/Scene/Components/ParticleEmitterComponent.cpp @@ -14,7 +14,10 @@ namespace Nuake SERIALIZE_VAL(GravityRandom); SERIALIZE_VAL(Radius); SERIALIZE_VAL(GlobalSpace); - SERIALIZE_OBJECT(ParticleMaterial); + if (ParticleMaterial) + { + SERIALIZE_OBJECT(ParticleMaterial); + } SERIALIZE_VAL(LifeRandomness); SERIALIZE_VAL(ScaleRandomness); END_SERIALIZE(); diff --git a/Nuake/src/Scene/Components/WrenScriptComponent.h b/Nuake/src/Scene/Components/WrenScriptComponent.h index 754a9537..609a962b 100644 --- a/Nuake/src/Scene/Components/WrenScriptComponent.h +++ b/Nuake/src/Scene/Components/WrenScriptComponent.h @@ -2,6 +2,7 @@ #include "src/Scripting/WrenScript.h" #include "src/Resource/Serializable.h" #include "src/Core/FileSystem.h" +#include "src/Core/Logger.h" namespace Nuake { @@ -17,6 +18,13 @@ namespace Nuake { Script = path; Ref nuakeFile = Nuake::FileSystem::GetFile(path); + + if (!nuakeFile) + { + Logger::Log("Failed to load script: " + path, "script", CRITICAL); + return; + } + mWrenScript = CreateRef(nuakeFile, true); auto modules = mWrenScript->GetModules(); if (modules.size() > 0)