From 2dcd9fa7892154f38fb2b62ced2744c9f1676d81 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 5 Dec 2015 23:28:29 -0800 Subject: [PATCH] Add forgotten MP3 MAPA DNA Fix crash when trying to add a seam to a missing edge --- DataSpec/DNACommon/MAPA.hpp | 13 +++++++++++++ DataSpec/DNAMP3/MAPA.hpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 DataSpec/DNAMP3/MAPA.hpp diff --git a/DataSpec/DNACommon/MAPA.hpp b/DataSpec/DNACommon/MAPA.hpp index 182615e5b..3a9ac219a 100644 --- a/DataSpec/DNACommon/MAPA.hpp +++ b/DataSpec/DNACommon/MAPA.hpp @@ -78,6 +78,11 @@ struct MAPA : BigDNA { /* magic */ magic = __dna_reader.readUint32Big(); + if (magic != 0xDEADD00D) + { + LogDNACommon.report(LogVisor::Error, "invalid MAPA magic"); + return; + } /* version */ version = __dna_reader.readUint32Big(); if (version == 2) @@ -86,6 +91,12 @@ struct MAPA : BigDNA header.reset(new HeaderMP2); else if (version == 5) header.reset(new HeaderMP3); + else + { + LogDNACommon.report(LogVisor::Error, "invalid MAPA version"); + return; + } + header->read(__dna_reader); for (int i = 0; i < header->mappableObjectCount(); i++) @@ -282,6 +293,8 @@ bool ReadMAPAToBlender(HECL::BlenderConnection& conn, "def add_border(bm, verts):\n" " verts = [bm.verts[vi] for vi in verts]\n" " edge = bm.edges.get(verts)\n" + " if not edge:\n" + " edge = bm.edges.new(verts)\n" " edge.seam = True\n" "\n"; diff --git a/DataSpec/DNAMP3/MAPA.hpp b/DataSpec/DNAMP3/MAPA.hpp new file mode 100644 index 000000000..fef725591 --- /dev/null +++ b/DataSpec/DNAMP3/MAPA.hpp @@ -0,0 +1,32 @@ +#ifndef __DNAMP3_MAPA_HPP__ +#define __DNAMP3_MAPA_HPP__ + +#include "../DNACommon/PAK.hpp" +#include "../DNACommon/MAPA.hpp" +#include "DNAMP3.hpp" + +namespace Retro +{ +namespace DNAMP3 +{ +struct MAPA : DNAMAPA::MAPA +{ + static bool Extract(const SpecBase& dataSpec, + PAKEntryReadStream& rs, + const HECL::ProjectPath& outPath, + PAKRouter& pakRouter, + const PAK::Entry& entry, + bool force, + std::function fileChanged) + { + MAPA mapa; + mapa.read(rs); + HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); + return DNAMAPA::ReadMAPAToBlender(conn, mapa, outPath, pakRouter, entry, force); + } +}; + +} +} + +#endif