From db46dbdfdb70ba423dcf2a627950cf4473951b13 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 8 Aug 2015 18:12:52 -0700 Subject: [PATCH] Fix dlist input --- DataSpec/DNAMP1/CMDL.cpp | 9 +++++++-- DataSpec/DNAMP1/MAPA.hpp | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/DataSpec/DNAMP1/CMDL.cpp b/DataSpec/DNAMP1/CMDL.cpp index 462a9ac1f..0b4d2f949 100644 --- a/DataSpec/DNAMP1/CMDL.cpp +++ b/DataSpec/DNAMP1/CMDL.cpp @@ -270,6 +270,7 @@ bool CMDL::ReadToBlender(HECL::BlenderConnection& conn, } /* GX Display List (surface) */ + atUint64 start = reader.position(); SurfaceHeader sHead; sHead.read(reader); unsigned matUVCount = matUVCounts[0][sHead.matIdx]; @@ -282,14 +283,18 @@ bool CMDL::ReadToBlender(HECL::BlenderConnection& conn, createdUVLayers = matUVCount; } - std::unique_ptr dlBuf = reader.readUBytes(sHead.dlSize); + atUint32 realDlSize = head.secSizes[s] - (reader.position() - secStart); + std::unique_ptr dlBuf = reader.readUBytes(realDlSize); atUint8* origDl = dlBuf.get(); atUint8* dl = origDl; - while (*dl && (dl-origDl) < sHead.dlSize) + while (*dl && (dl-origDl) < realDlSize) { GX::Primitive ptype = GX::Primitive(*dl & 0xf8); + if (ptype == 0) + break; + atUint16 vert_count = HECL::SBig(*(atUint16*)(dl + 1)); os.format("# VAT Type: %u\n", *dl&7); diff --git a/DataSpec/DNAMP1/MAPA.hpp b/DataSpec/DNAMP1/MAPA.hpp index 915edd48d..85fc3f237 100644 --- a/DataSpec/DNAMP1/MAPA.hpp +++ b/DataSpec/DNAMP1/MAPA.hpp @@ -41,8 +41,8 @@ struct MAPA : BigDNA struct SurfaceHeader : BigDNA { DECL_DNA - Value unkFloats1; - Value unkFloats2; + Value normal; + Value center; Value start; Value end; };