From 2a053d3a681f8f4789bba567bd0dfaa76fa0a80d Mon Sep 17 00:00:00 2001 From: rozlette Date: Wed, 2 Feb 2022 21:28:29 -0600 Subject: [PATCH] Fixed OTRExporter exporting the wrong amount of actors in some circumstances --- OTRExporter/OTRExporter/RoomExporter.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OTRExporter/OTRExporter/RoomExporter.cpp b/OTRExporter/OTRExporter/RoomExporter.cpp index 63f9f6b5b1a..ac770f4cd3e 100644 --- a/OTRExporter/OTRExporter/RoomExporter.cpp +++ b/OTRExporter/OTRExporter/RoomExporter.cpp @@ -76,10 +76,14 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite { SetActorList* cmdSetActorList = (SetActorList*)cmd; - writer->Write((uint32_t)cmdSetActorList->actors.size()); + // There are instance of the amount of actors in the file differing from the size listed in the command. + // This can cause issues if we export actors with garbage data, so let's trust the command size + writer->Write((uint32_t)cmdSetActorList->numActors); - for (const ActorSpawnEntry& entry : cmdSetActorList->actors) + for (int i = 0; i < cmdSetActorList->numActors; i++) { + const ActorSpawnEntry& entry = cmdSetActorList->actors[i]; + writer->Write(entry.actorNum); writer->Write(entry.posX); writer->Write(entry.posY);