2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-10-25 07:45:52 +00:00

refactor: streamline IW4 asset loading

This commit is contained in:
Jan Laupetin
2025-08-05 01:13:58 +02:00
parent 81a67151b5
commit 6806337f46
49 changed files with 398 additions and 397 deletions

View File

@@ -52,7 +52,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
DUMP_ASSET_POOL(sound::SndCurveDumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
DUMP_ASSET_POOL(sound_curve::Dumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)

View File

@@ -1,40 +1,30 @@
#include "SndCurveDumperIW4.h"
#include "Dumping/SndCurve/SndCurveDumper.h"
#include "Sound/SndCurveDumper.h"
#include "Sound/SoundCurveCommon.h"
#include <sstream>
using namespace IW4;
using namespace ::sound_curve;
namespace
namespace IW4::sound_curve
{
std::string GetAssetFilename(const std::string& assetName)
{
std::ostringstream ss;
ss << "soundaliases/" << assetName << ".vfcurve";
return ss.str();
}
} // namespace
namespace IW4::sound
{
bool SndCurveDumper::ShouldDump(XAssetInfo<SndCurve>* asset)
bool Dumper::ShouldDump(XAssetInfo<SndCurve>* asset)
{
return true;
}
void SndCurveDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset)
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset)
{
const auto* sndCurve = asset->Asset();
const auto assetFile = context.OpenAssetFile(GetAssetFilename(sndCurve->filename));
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(sndCurve->filename));
if (!assetFile)
return;
::SndCurveDumper dumper(*assetFile);
SndCurveDumper dumper(*assetFile);
const auto knotCount = std::min(static_cast<size_t>(sndCurve->knotCount), std::extent_v<decltype(SndCurve::knots)>);
dumper.Init(knotCount);
@@ -42,4 +32,4 @@ namespace IW4::sound
for (auto i = 0u; i < knotCount; i++)
dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]);
}
} // namespace IW4::sound
} // namespace IW4::sound_curve

View File

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