From b2f3d9d1b53c476c537d28dd74c19ece536b565d Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Thu, 3 Oct 2024 16:02:22 -0600 Subject: Fixed some sm64 bugs --- src/factories/sm64/PaintingFactory.cpp | 4 ++++ src/factories/sm64/PaintingMapFactory.cpp | 6 ++++-- src/factories/sm64/geo/GeoUtils.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/factories/sm64/PaintingFactory.cpp b/src/factories/sm64/PaintingFactory.cpp index 5f3f4a0..d9b40a4 100644 --- a/src/factories/sm64/PaintingFactory.cpp +++ b/src/factories/sm64/PaintingFactory.cpp @@ -165,6 +165,7 @@ ExportResult SM64::PaintingBinaryExporter::Export(std::ostream &write, std::shar writer.Write(hash); } else { SPDLOG_WARN("Could not find DisplayList at 0x{:X}", ptr); + writer.Write((uint64_t) 0); } } @@ -177,6 +178,7 @@ ExportResult SM64::PaintingBinaryExporter::Export(std::ostream &write, std::shar writer.Write(hash); } else { SPDLOG_WARN("Could not find Texture Maps at 0x{:X}", ptr); + writer.Write((uint64_t) 0); } } @@ -189,6 +191,7 @@ ExportResult SM64::PaintingBinaryExporter::Export(std::ostream &write, std::shar writer.Write(hash); } else { SPDLOG_WARN("Could not find Texture Arrays at 0x{:X}", ptr); + writer.Write((uint64_t) 0); } } @@ -204,6 +207,7 @@ ExportResult SM64::PaintingBinaryExporter::Export(std::ostream &write, std::shar writer.Write(hash); } else { SPDLOG_WARN("Could not find DisplayList at 0x{:X}", ptr); + writer.Write((uint64_t) 0); } } diff --git a/src/factories/sm64/PaintingMapFactory.cpp b/src/factories/sm64/PaintingMapFactory.cpp index 61bf7e7..677906d 100644 --- a/src/factories/sm64/PaintingMapFactory.cpp +++ b/src/factories/sm64/PaintingMapFactory.cpp @@ -55,7 +55,9 @@ ExportResult SM64::PaintingMapBinaryExporter::Export(std::ostream &write, std::s WriteHeader(writer, Torch::ResourceType::PaintingData, 0); - writer.Write((int16_t)paintingData->mPaintingMappings.size()); + writer.Write((uint32_t) (paintingData->mPaintingMappings.size() + paintingData->mPaintingGroups.size()) + 2 ); + + writer.Write((int16_t) paintingData->mPaintingMappings.size()); for (auto &mapping : paintingData->mPaintingMappings) { writer.Write(mapping.vtxId); @@ -63,7 +65,7 @@ ExportResult SM64::PaintingMapBinaryExporter::Export(std::ostream &write, std::s writer.Write(mapping.texY); } - writer.Write((int16_t)paintingData->mPaintingGroups.size()); + writer.Write((int16_t) paintingData->mPaintingGroups.size()); for (auto &group : paintingData->mPaintingGroups) { writer.Write(group.x); diff --git a/src/factories/sm64/geo/GeoUtils.cpp b/src/factories/sm64/geo/GeoUtils.cpp index 91f4158..540122f 100644 --- a/src/factories/sm64/geo/GeoUtils.cpp +++ b/src/factories/sm64/geo/GeoUtils.cpp @@ -1,6 +1,6 @@ #include "GeoUtils.h" -#define next_s16_in_geo_script(src) BSWAP16((*(*src)++)) +#define next_s16_in_geo_script(src) (int16_t) BSWAP16((*(*src)++)) int16_t* read_vec3s_to_vec3f(Vec3f& dst, int16_t *src) { dst.x = next_s16_in_geo_script(&src); -- cgit v1.2.3