From 14f293e15a36ed7a4f32e0d3d08335a6600995ad Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Tue, 14 May 2024 11:05:50 -0500 Subject: [PATCH] Fix file not loaded spam (#385) --- .../importer/scenecommand/SetMeshFactory.cpp | 56 +++++++++++++------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp index d83b551f9..925f744bc 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp @@ -41,10 +41,16 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, s std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); - dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; - dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + dlist.opa = 0; + dlist.xlu = 0; + if (meshOpa != "") { + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); + } + if (meshXlu != "") { + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); + } setMesh->dlists.push_back(dlist); } else if (setMesh->meshHeader.base.type == 1) { @@ -54,10 +60,16 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, s std::string imgOpa = reader->ReadString(); std::string imgXlu = reader->ReadString(); - auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); - auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); - pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; - pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + pType.opa = 0; + pType.xlu = 0; + if (imgOpa != "") { + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); + pType.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); + } + if (imgXlu != "") { + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); + pType.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); + } int32_t bgImageCount = reader->ReadUInt32(); setMesh->images.reserve(bgImageCount); @@ -103,10 +115,16 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, s std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); - pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; - pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + pType.opa = 0; + pType.xlu = 0; + if (meshOpa != "") { + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + pType.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); + } + if (meshXlu != "") { + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + pType.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); + } setMesh->dlists.push_back(pType); } else if (setMesh->meshHeader.base.type == 2) { @@ -121,10 +139,16 @@ SetMeshFactory::ReadResource(std::shared_ptr initData, s std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); - dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; - dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + dlist.opa = 0; + dlist.xlu = 0; + if (meshOpa != "") { + auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); + } + if (meshXlu != "") { + auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); + } setMesh->dlists2.push_back(dlist); } else {