Various fixes

Add MLVL blend support (needs some minor refactoring)
Add MP2 MAPA Support
This commit is contained in:
Phillip Stephens 2015-11-24 16:21:58 -08:00
parent 855337e8ca
commit 6f0c7851ea
5 changed files with 59 additions and 21 deletions

View File

@ -219,12 +219,12 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& ent
return {nullptr, CMDL::Extract, {_S(".blend")}, 1}; return {nullptr, CMDL::Extract, {_S(".blend")}, 1};
case SBIG('ANCS'): case SBIG('ANCS'):
return {nullptr, ANCS::Extract, {_S(".yaml"), _S(".blend")}, 2}; return {nullptr, ANCS::Extract, {_S(".yaml"), _S(".blend")}, 2};
case SBIG('MREA'):
return {nullptr, MREA::Extract, {_S(".blend")}, 3};
case SBIG('MLVL'): case SBIG('MLVL'):
return {MLVL::Extract, nullptr, {_S(".yaml")}}; return {nullptr, MLVL::Extract, {_S(".blend")}, 3};
// case SBIG('MAPA'): case SBIG('MREA'):
// return {nullptr, MAPA::Extract, {_S(".blend")}, 4}; return {nullptr, MREA::Extract, {_S(".blend")}, 4};
case SBIG('MAPA'):
return {nullptr, MAPA::Extract, {_S(".blend")}, 4};
} }
return {}; return {};
} }

View File

@ -1,14 +1,30 @@
#ifndef __DNAMP2_MAPA_HPP__ #ifndef __DNAMP2_MAPA_HPP__
#define __DNAMP2_MAPA_HPP__ #define __DNAMP2_MAPA_HPP__
#include "../DNACommon/PAK.hpp"
#include "../DNAMP1/MAPA.hpp" #include "../DNAMP1/MAPA.hpp"
#include "DNAMP2.hpp"
namespace Retro namespace Retro
{ {
namespace DNAMP2 namespace DNAMP2
{ {
struct MAPA : DNAMP1::MAPA struct MAPA : DNAMP1::MAPA
{}; {
static bool Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
const HECL::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const DNAMP1::PAK::Entry& entry,
bool force,
std::function<void(const HECL::SystemChar*)> fileChanged)
{
MAPA mapa;
mapa.read(rs);
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
return DNAMAPA::ReadMAPAToBlender(conn, mapa, outPath, pakRouter, entry, force);
}
};
} }
} }

View File

@ -2,6 +2,8 @@
#define __DNAMP2_MLVL_HPP__ #define __DNAMP2_MLVL_HPP__
#include "../DNACommon/PAK.hpp" #include "../DNACommon/PAK.hpp"
#include "../DNACommon/MLVL.hpp"
#include "DNAMP2.hpp"
namespace Retro namespace Retro
{ {
@ -91,14 +93,23 @@ struct MLVL : BigYAML
Value<atUint32> layerNameOffsetCount; Value<atUint32> layerNameOffsetCount;
Vector<atUint32, DNA_COUNT(layerNameOffsetCount)> layerNameOffsets; Vector<atUint32, DNA_COUNT(layerNameOffsetCount)> layerNameOffsets;
static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
static bool Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
const HECL::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const DNAMP1::PAK::Entry& entry,
bool force,
std::function<void(const HECL::SystemChar*)> fileChanged)
{ {
MLVL mlvl; MLVL mlvl;
mlvl.read(rs); mlvl.read(rs);
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
mlvl.toYAMLFile(fp); mlvl.toYAMLFile(fp);
fclose(fp); fclose(fp);
return true; HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter,
entry, force, fileChanged);
} }
}; };

View File

@ -154,16 +154,16 @@ void PAKBridge::build()
HECL::SNPrintf(num, 16, _S("%02u "), ai); HECL::SNPrintf(num, 16, _S("%02u "), ai);
areaDeps.name = num + areaDeps.name; areaDeps.name = num + areaDeps.name;
const MLVL::LayerFlags& areaLayers = *layerFlagsIt++; const MLVL::LayerFlags& layerFlags = *layerFlagsIt++;
if (areaLayers.layerCount) if (layerFlags.layerCount)
{ {
areaDeps.layers.reserve(areaLayers.layerCount); areaDeps.layers.reserve(layerFlags.layerCount);
for (unsigned l=0 ; l<areaLayers.layerCount ; ++l) for (unsigned l=1 ; l<layerFlags.layerCount ; ++l)
{ {
areaDeps.layers.emplace_back(); areaDeps.layers.emplace_back();
Level::Area::Layer& layer = areaDeps.layers.back(); Level::Area::Layer& layer = areaDeps.layers.back();
layer.name = LayerName(mlvl.layerNames[layerIdx++]); layer.name = LayerName(mlvl.layerNames[layerIdx++]);
layer.active = areaLayers.flags >> l & 0x1; layer.active = layerFlags.flags >> (l-1) & 0x1;
/* Trim possible trailing whitespace */ /* Trim possible trailing whitespace */
#if HECL_UCS2 #if HECL_UCS2
while (layer.name.size() && iswspace(layer.name.back())) while (layer.name.size() && iswspace(layer.name.back()))
@ -229,10 +229,10 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
return {nullptr, CMDL::Extract, {_S(".blend")}, 1}; return {nullptr, CMDL::Extract, {_S(".blend")}, 1};
case SBIG('CHAR'): case SBIG('CHAR'):
return {nullptr, CHAR::Extract, {_S(".yaml"), _S(".blend")}, 2}; return {nullptr, CHAR::Extract, {_S(".yaml"), _S(".blend")}, 2};
case SBIG('MREA'):
return {nullptr, MREA::Extract, {_S(".blend")}, 3};
case SBIG('MLVL'): case SBIG('MLVL'):
return {MLVL::Extract, nullptr, {_S(".yaml")}}; return {nullptr, MLVL::Extract, {_S(".blend")}, 3};
case SBIG('MREA'):
return {nullptr, MREA::Extract, {_S(".blend")}, 4};
} }
return {}; return {};
} }

View File

@ -2,6 +2,8 @@
#define __DNAMP3_MLVL_HPP__ #define __DNAMP3_MLVL_HPP__
#include "../DNACommon/PAK.hpp" #include "../DNACommon/PAK.hpp"
#include "../DNACommon/MLVL.hpp"
#include "DNAMP3.hpp"
namespace Retro namespace Retro
{ {
@ -75,14 +77,23 @@ struct MLVL : BigYAML
Value<atUint32> layerNameOffsetCount; Value<atUint32> layerNameOffsetCount;
Vector<atUint32, DNA_COUNT(layerNameOffsetCount)> layerNameOffsets; Vector<atUint32, DNA_COUNT(layerNameOffsetCount)> layerNameOffsets;
static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
static bool Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
const HECL::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const PAK::Entry& entry,
bool force,
std::function<void(const HECL::SystemChar*)> fileChanged)
{ {
MLVL mlvl; MLVL mlvl;
mlvl.read(rs); mlvl.read(rs);
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
mlvl.toYAMLFile(fp); mlvl.toYAMLFile(fp);
fclose(fp); fclose(fp);
return true; HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter,
entry, force, fileChanged);
} }
}; };