2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-01 22:47:26 +00:00

refactor: streamline rawfile dumping

This commit is contained in:
Jan Laupetin
2025-07-30 19:55:57 +01:00
parent 24c9e08046
commit bcb52391dc
20 changed files with 374 additions and 358 deletions

View File

@@ -7,7 +7,7 @@
#include "Localize/LocalizeDumperIW3.h"
#include "Maps/MapEntsDumperIW3.h"
#include "ObjWriting.h"
#include "RawFile/AssetDumperRawFile.h"
#include "RawFile/RawFileDumperIW3.h"
#include "Sound/AssetDumperLoadedSound.h"
#include "StringTable/AssetDumperStringTable.h"
#include "Weapon/AssetDumperWeapon.h"
@@ -49,7 +49,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
return true;

View File

@@ -1,20 +0,0 @@
#include "AssetDumperRawFile.h"
using namespace IW3;
bool AssetDumperRawFile::ShouldDump(XAssetInfo<RawFile>* asset)
{
return true;
}
void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(rawFile->buffer, rawFile->len);
}

View File

@@ -0,0 +1,23 @@
#include "RawFileDumperIW3.h"
using namespace IW3;
namespace IW3::raw_file
{
bool Dumper::ShouldDump(XAssetInfo<RawFile>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(rawFile->buffer, rawFile->len);
}
} // namespace IW3::raw_file

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3
namespace IW3::raw_file
{
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
class Dumper final : public AbstractAssetDumper<RawFile>
{
protected:
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset) override;
};
} // namespace IW3
} // namespace IW3::raw_file