summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2026-03-05 21:15:59 -0700
committerGitHub <noreply@github.com>2026-03-05 21:15:59 -0700
commitba0a24e28fc652aaaa272581831ced8a69614a19 (patch)
tree825bc6cf904d0b99e534b2448cbcecd6a45ea73e /src/engine
parent2564e0b7a3f1e1c290e0b9331c5052af64f366b2 (diff)
Fix editor loading and finishline duplication (#653)
* Fix editor loading and finishline duplication * Update SceneManager.cpp
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/RaceManager.cpp7
-rw-r--r--src/engine/actors/Finishline.h2
-rw-r--r--src/engine/editor/SceneManager.cpp24
3 files changed, 20 insertions, 13 deletions
diff --git a/src/engine/RaceManager.cpp b/src/engine/RaceManager.cpp
index cecda6ced..de8ed6984 100644
--- a/src/engine/RaceManager.cpp
+++ b/src/engine/RaceManager.cpp
@@ -81,11 +81,12 @@ void RaceManager::BeginPlay() {
if ((gGamestate != CREDITS_SEQUENCE) && (gModeSelection != BATTLE)) {
if (track->bSpawnFinishline) {
if (track->FinishlineSpawnPoint.has_value()) {
- AFinishline::Spawn(track->FinishlineSpawnPoint.value(), IRotator(0, 0, 0));
+ AFinishline* finishline = AFinishline::Spawn(track->FinishlineSpawnPoint.value(), IRotator(0, 0, 0));
+ finishline->bIsFinishline = true;
} else {
- AFinishline::Spawn();
+ AFinishline* finishline = AFinishline::Spawn();
+ finishline->bIsFinishline = true;
}
-
}
}
gEditor.AddLight("Sun", nullptr, D_800DC610[1].l->l.dir);
diff --git a/src/engine/actors/Finishline.h b/src/engine/actors/Finishline.h
index 192aca6a4..eefac2f41 100644
--- a/src/engine/actors/Finishline.h
+++ b/src/engine/actors/Finishline.h
@@ -46,6 +46,8 @@ public:
virtual void Collision(Player* player, AActor* actor) override;
virtual bool IsMod() override;
+ bool bIsFinishline = false;
+
static size_t _count;
bool PickedUp = false;
uint32_t Timer = 0;
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());
}
}