diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2026-03-05 21:15:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-05 21:15:59 -0700 |
| commit | ba0a24e28fc652aaaa272581831ced8a69614a19 (patch) | |
| tree | 825bc6cf904d0b99e534b2448cbcecd6a45ea73e /src/engine/editor/SceneManager.cpp | |
| parent | 2564e0b7a3f1e1c290e0b9331c5052af64f366b2 (diff) | |
Fix editor loading and finishline duplication (#653)
* Fix editor loading and finishline duplication
* Update SceneManager.cpp
Diffstat (limited to 'src/engine/editor/SceneManager.cpp')
| -rw-r--r-- | src/engine/editor/SceneManager.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/engine/editor/SceneManager.cpp b/src/engine/editor/SceneManager.cpp index af1b1cc2b..f4b582bc5 100644 --- a/src/engine/editor/SceneManager.cpp +++ b/src/engine/editor/SceneManager.cpp @@ -18,6 +18,7 @@ #include "engine/vehicles/Train.h" +#include "engine/actors/Finishline.h" #include "engine/objects/Object.h" #include "engine/objects/Thwomp.h" #include "engine/objects/Snowman.h" @@ -86,15 +87,11 @@ namespace TrackEditor { std::string sceneFile = info->Path + "/scene.json"; + Ship::ResourceIdentifier id(sceneFile, 0, track->Archive); // Write file to disk - bool wrote = GameEngine::Instance->context->GetResourceManager()->GetArchiveManager()->WriteFile(track->Archive, sceneFile, bytes); - if (wrote) { - // Tell the cache this file needs to be reloaded - auto resource = GameEngine::Instance->context->GetResourceManager()->GetCachedResource(sceneFile); - if (resource) { - resource->Dirty(); - } - } else { + auto rm = GameEngine::Instance->context->GetResourceManager(); + bool wrote = rm->WriteResource(id, bytes, true); + if (!wrote) { SPDLOG_INFO("[SceneManager] [SaveLevel] Failed to write scene file!"); } } catch (const nlohmann::json::exception& e) { @@ -129,8 +126,9 @@ namespace TrackEditor { initData->ResourceVersion = 0; // Load the scene file and return the json data + Ship::ResourceIdentifier id(sceneFile, 0, track->Archive); nlohmann::json data = std::static_pointer_cast<Ship::Json>( - GameEngine::Instance->context->GetResourceManager()->LoadResource(sceneFile, true, initData))->Data; + GameEngine::Instance->context->GetResourceManager()->LoadResource(id, true, initData))->Data; // Check that the data is valid if (data.is_null() || !data.is_object() || data.empty()) { @@ -169,8 +167,9 @@ namespace TrackEditor { initData->ResourceVersion = 0; // Load the scene file and return the json data + Ship::ResourceIdentifier id(sceneFile, 0, archive); nlohmann::json data = std::static_pointer_cast<Ship::Json>( - GameEngine::Instance->context->GetResourceManager()->LoadResource(sceneFile, true, initData))->Data; + GameEngine::Instance->context->GetResourceManager()->LoadResource(id, true, initData))->Data; // Check that the data is valid if (data.is_null() || !data.is_object() || data.empty()) { @@ -279,6 +278,11 @@ namespace TrackEditor { if (!alreadyProcessed) { actor->SetSpawnParams(params); if (!params.Name.empty()) { + if (AFinishline* finishline = dynamic_cast<AFinishline*>(actor.get())) { + if (finishline->bIsFinishline == true) { + continue; // Do not add the default spawn finishline + } + } actorList.push_back(params.to_json()); } } |
