Use template function for SAVW

This commit is contained in:
Phillip Stephens 2016-07-23 19:07:36 -07:00
parent b188c4892a
commit 162994ca39
7 changed files with 16 additions and 33 deletions

View File

@ -1,6 +1,7 @@
#ifndef __COMMON_SAVWCOMMON_HPP__
#define __COMMON_SAVWCOMMON_HPP__
#include "DNACommon.hpp"
#include "PAK.hpp"
namespace DataSpec
{
@ -38,6 +39,18 @@ struct Layer : BigYAML
Value<atUint32> areaId;
Value<atUint32> layer;
};
template <class SAVW>
static bool ExtractSAVW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
SAVW savw;
savw.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
savw.toYAMLFile(fp);
fclose(fp);
return true;
}
}
}

View File

@ -279,7 +279,7 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
case SBIG('SCAN'):
return {SCAN::Extract, nullptr, {_S(".yaml")}, 0, SCAN::Name};
case SBIG('SAVW'):
return {DNAMP1::ExtractSAVW, nullptr, {_S(".yaml")}};
return {SAVWCommon::ExtractSAVW<SAVW>, nullptr, {_S(".yaml")}};
case SBIG('TXTR'):
return {TXTR::Extract, nullptr, {_S(".png")}};
case SBIG('AFSM'):

View File

@ -30,16 +30,6 @@ struct SAVW : BigYAML
Value<atUint32> scanCount;
Vector<Scan, DNA_COUNT(scanCount)> scans;
};
static bool ExtractSAVW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
SAVW savw;
savw.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
savw.toYAMLFile(fp);
fclose(fp);
return true;
}
}
}

View File

@ -224,7 +224,7 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& ent
case SBIG('AFSM'):
return {AFSM::Extract, nullptr, {_S(".yaml")}};
case SBIG('SAVW'):
return {DNAMP2::ExtractSAVW, nullptr, {_S(".yaml")}};
return {SAVWCommon::ExtractSAVW<SAVW>, nullptr, {_S(".yaml")}};
case SBIG('CMDL'):
return {nullptr, CMDL::Extract, {_S(".blend")}, 1};
case SBIG('ANCS'):

View File

@ -18,16 +18,6 @@ struct SAVW : DNAMP1::SAVW
Value<atUint32> gameObjectCount;
Vector<atUint32, DNA_COUNT(gameObjectCount)> gameObjects;
};
static bool ExtractSAVW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
SAVW savw;
savw.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
savw.toYAMLFile(fp);
fclose(fp);
return true;
}
}
}

View File

@ -232,7 +232,7 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
case SBIG('TXTR'):
return {TXTR::Extract, nullptr, {_S(".png")}};
case SBIG('SAVW'):
return {DNAMP3::ExtractSAVW, nullptr, {_S(".yaml")}};
return {SAVWCommon::ExtractSAVW<SAVW>, nullptr, {_S(".yaml")}};
case SBIG('CMDL'):
return {nullptr, CMDL::Extract, {_S(".blend")}, 1};
case SBIG('CHAR'):

View File

@ -48,16 +48,6 @@ struct SAVW : BigYAML
Value<atUint32> gameObjectCount;
Vector<SavedState, DNA_COUNT(gameObjectCount)> gameObjects;
};
static bool ExtractSAVW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
SAVW savw;
savw.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
savw.toYAMLFile(fp);
fclose(fp);
return true;
}
}
}