mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
chore: use IObjWriter directly instead of indirection of ObjWriting
This commit is contained in:
parent
4c9a84777f
commit
bb845f68e9
@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "AssetDumpingContext.h"
|
|
||||||
|
|
||||||
class IZoneDumper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IZoneDumper() = default;
|
|
||||||
virtual ~IZoneDumper() = default;
|
|
||||||
IZoneDumper(const IZoneDumper& other) = default;
|
|
||||||
IZoneDumper(IZoneDumper&& other) noexcept = default;
|
|
||||||
IZoneDumper& operator=(const IZoneDumper& other) = default;
|
|
||||||
IZoneDumper& operator=(IZoneDumper&& other) noexcept = default;
|
|
||||||
|
|
||||||
virtual bool CanHandleZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
|
||||||
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
|
||||||
};
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "ZoneDumperIW3.h"
|
#include "ObjWriterIW3.h"
|
||||||
|
|
||||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||||
#include "AssetDumpers/AssetDumperLoadedSound.h"
|
#include "AssetDumpers/AssetDumperLoadedSound.h"
|
||||||
@ -10,17 +10,11 @@
|
|||||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||||
#include "AssetDumpers/AssetDumperXModel.h"
|
#include "AssetDumpers/AssetDumperXModel.h"
|
||||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||||
#include "Game/IW3/GameIW3.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||||
{
|
|
||||||
return context.m_zone->m_game == &g_GameIW3;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
|
||||||
{
|
{
|
||||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
11
src/ObjWriting/Game/IW3/ObjWriterIW3.h
Normal file
11
src/ObjWriting/Game/IW3/ObjWriterIW3.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IObjWriter.h"
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
class ObjWriter final : public IObjWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool DumpZone(AssetDumpingContext& context) const override;
|
||||||
|
};
|
||||||
|
} // namespace IW3
|
@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
|
|
||||||
namespace IW3
|
|
||||||
{
|
|
||||||
class ZoneDumper final : public IZoneDumper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
|
||||||
bool DumpZone(AssetDumpingContext& context) const override;
|
|
||||||
};
|
|
||||||
} // namespace IW3
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "ZoneDumperIW4.h"
|
#include "ObjWriterIW4.h"
|
||||||
|
|
||||||
#include "AssetDumpers/AssetDumperAddonMapEnts.h"
|
#include "AssetDumpers/AssetDumperAddonMapEnts.h"
|
||||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||||
@ -23,17 +23,11 @@
|
|||||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||||
#include "AssetDumpers/AssetDumperXModel.h"
|
#include "AssetDumpers/AssetDumperXModel.h"
|
||||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||||
#include "Game/IW4/GameIW4.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
|
||||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||||
{
|
|
||||||
return context.m_zone->m_game == &g_GameIW4;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
|
||||||
{
|
{
|
||||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
11
src/ObjWriting/Game/IW4/ObjWriterIW4.h
Normal file
11
src/ObjWriting/Game/IW4/ObjWriterIW4.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IObjWriter.h"
|
||||||
|
|
||||||
|
namespace IW4
|
||||||
|
{
|
||||||
|
class ObjWriter final : public IObjWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool DumpZone(AssetDumpingContext& context) const override;
|
||||||
|
};
|
||||||
|
} // namespace IW4
|
@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
|
|
||||||
namespace IW4
|
|
||||||
{
|
|
||||||
class ZoneDumper final : public IZoneDumper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
|
||||||
bool DumpZone(AssetDumpingContext& context) const override;
|
|
||||||
};
|
|
||||||
} // namespace IW4
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "ZoneDumperIW5.h"
|
#include "ObjWriterIW5.h"
|
||||||
|
|
||||||
#include "AssetDumpers/AssetDumperAddonMapEnts.h"
|
#include "AssetDumpers/AssetDumperAddonMapEnts.h"
|
||||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||||
@ -15,17 +15,11 @@
|
|||||||
#include "AssetDumpers/AssetDumperWeaponAttachment.h"
|
#include "AssetDumpers/AssetDumperWeaponAttachment.h"
|
||||||
#include "AssetDumpers/AssetDumperXModel.h"
|
#include "AssetDumpers/AssetDumperXModel.h"
|
||||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||||
#include "Game/IW5/GameIW5.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
|
|
||||||
using namespace IW5;
|
using namespace IW5;
|
||||||
|
|
||||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||||
{
|
|
||||||
return context.m_zone->m_game == &g_GameIW5;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
|
||||||
{
|
{
|
||||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
11
src/ObjWriting/Game/IW5/ObjWriterIW5.h
Normal file
11
src/ObjWriting/Game/IW5/ObjWriterIW5.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IObjWriter.h"
|
||||||
|
|
||||||
|
namespace IW5
|
||||||
|
{
|
||||||
|
class ObjWriter final : public IObjWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool DumpZone(AssetDumpingContext& context) const override;
|
||||||
|
};
|
||||||
|
} // namespace IW5
|
@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
|
|
||||||
namespace IW5
|
|
||||||
{
|
|
||||||
class ZoneDumper final : public IZoneDumper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
|
||||||
bool DumpZone(AssetDumpingContext& context) const override;
|
|
||||||
};
|
|
||||||
} // namespace IW5
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "ZoneDumperT5.h"
|
#include "ObjWriterT5.h"
|
||||||
|
|
||||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||||
@ -10,17 +10,11 @@
|
|||||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||||
#include "AssetDumpers/AssetDumperXModel.h"
|
#include "AssetDumpers/AssetDumperXModel.h"
|
||||||
#include "Game/T5/GameAssetPoolT5.h"
|
#include "Game/T5/GameAssetPoolT5.h"
|
||||||
#include "Game/T5/GameT5.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
|
|
||||||
using namespace T5;
|
using namespace T5;
|
||||||
|
|
||||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||||
{
|
|
||||||
return context.m_zone->m_game == &g_GameT5;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
|
||||||
{
|
{
|
||||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
11
src/ObjWriting/Game/T5/ObjWriterT5.h
Normal file
11
src/ObjWriting/Game/T5/ObjWriterT5.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IObjWriter.h"
|
||||||
|
|
||||||
|
namespace T5
|
||||||
|
{
|
||||||
|
class ObjWriter final : public IObjWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool DumpZone(AssetDumpingContext& context) const override;
|
||||||
|
};
|
||||||
|
} // namespace T5
|
@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
|
|
||||||
namespace T5
|
|
||||||
{
|
|
||||||
class ZoneDumper final : public IZoneDumper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
|
||||||
bool DumpZone(AssetDumpingContext& context) const override;
|
|
||||||
};
|
|
||||||
} // namespace T5
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "ZoneDumperT6.h"
|
#include "ObjWriterT6.h"
|
||||||
|
|
||||||
#include "AssetDumpers/AssetDumperFontIcon.h"
|
#include "AssetDumpers/AssetDumperFontIcon.h"
|
||||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||||
@ -24,17 +24,11 @@
|
|||||||
#include "AssetDumpers/AssetDumperXModel.h"
|
#include "AssetDumpers/AssetDumperXModel.h"
|
||||||
#include "AssetDumpers/AssetDumperZBarrier.h"
|
#include "AssetDumpers/AssetDumperZBarrier.h"
|
||||||
#include "Game/T6/GameAssetPoolT6.h"
|
#include "Game/T6/GameAssetPoolT6.h"
|
||||||
#include "Game/T6/GameT6.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
|
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
|
|
||||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||||
{
|
|
||||||
return context.m_zone->m_game == &g_GameT6;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
|
||||||
{
|
{
|
||||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
11
src/ObjWriting/Game/T6/ObjWriterT6.h
Normal file
11
src/ObjWriting/Game/T6/ObjWriterT6.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IObjWriter.h"
|
||||||
|
|
||||||
|
namespace T6
|
||||||
|
{
|
||||||
|
class ObjWriter final : public IObjWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool DumpZone(AssetDumpingContext& context) const override;
|
||||||
|
};
|
||||||
|
} // namespace T6
|
@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
|
|
||||||
namespace T6
|
|
||||||
{
|
|
||||||
class ZoneDumper final : public IZoneDumper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
|
||||||
bool DumpZone(AssetDumpingContext& context) const override;
|
|
||||||
};
|
|
||||||
} // namespace T6
|
|
27
src/ObjWriting/IObjWriter.cpp
Normal file
27
src/ObjWriting/IObjWriter.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "IObjWriter.h"
|
||||||
|
|
||||||
|
#include "Game/IW3/ObjWriterIW3.h"
|
||||||
|
#include "Game/IW4/ObjWriterIW4.h"
|
||||||
|
#include "Game/IW5/ObjWriterIW5.h"
|
||||||
|
#include "Game/T5/ObjWriterT5.h"
|
||||||
|
#include "Game/T6/ObjWriterT6.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
const IObjWriter* IObjWriter::GetObjWriterForGame(GameId game)
|
||||||
|
{
|
||||||
|
static const IObjWriter* zoneCreators[static_cast<unsigned>(GameId::COUNT)]{
|
||||||
|
new IW3::ObjWriter(),
|
||||||
|
new IW4::ObjWriter(),
|
||||||
|
new IW5::ObjWriter(),
|
||||||
|
new T5::ObjWriter(),
|
||||||
|
new T6::ObjWriter(),
|
||||||
|
};
|
||||||
|
static_assert(std::extent_v<decltype(zoneCreators)> == static_cast<unsigned>(GameId::COUNT));
|
||||||
|
|
||||||
|
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
|
||||||
|
const auto* result = zoneCreators[static_cast<unsigned>(game)];
|
||||||
|
assert(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
18
src/ObjWriting/IObjWriter.h
Normal file
18
src/ObjWriting/IObjWriter.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Dumping/AssetDumpingContext.h"
|
||||||
|
|
||||||
|
class IObjWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IObjWriter() = default;
|
||||||
|
virtual ~IObjWriter() = default;
|
||||||
|
IObjWriter(const IObjWriter& other) = default;
|
||||||
|
IObjWriter(IObjWriter&& other) noexcept = default;
|
||||||
|
IObjWriter& operator=(const IObjWriter& other) = default;
|
||||||
|
IObjWriter& operator=(IObjWriter&& other) noexcept = default;
|
||||||
|
|
||||||
|
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
||||||
|
|
||||||
|
static const IObjWriter* GetObjWriterForGame(GameId game);
|
||||||
|
};
|
@ -1,41 +1,7 @@
|
|||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
|
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
#include "Game/IW3/ZoneDumperIW3.h"
|
|
||||||
#include "Game/IW4/ZoneDumperIW4.h"
|
|
||||||
#include "Game/IW5/ZoneDumperIW5.h"
|
|
||||||
#include "Game/T5/ZoneDumperT5.h"
|
|
||||||
#include "Game/T6/ZoneDumperT6.h"
|
|
||||||
|
|
||||||
ObjWriting::Configuration_t ObjWriting::Configuration;
|
ObjWriting::Configuration_t ObjWriting::Configuration;
|
||||||
|
|
||||||
const IZoneDumper* const ZONE_DUMPER[]{
|
|
||||||
new IW3::ZoneDumper(),
|
|
||||||
new IW4::ZoneDumper(),
|
|
||||||
new IW5::ZoneDumper(),
|
|
||||||
new T5::ZoneDumper(),
|
|
||||||
new T6::ZoneDumper(),
|
|
||||||
};
|
|
||||||
|
|
||||||
bool ObjWriting::DumpZone(AssetDumpingContext& context)
|
|
||||||
{
|
|
||||||
for (const auto* dumper : ZONE_DUMPER)
|
|
||||||
{
|
|
||||||
if (dumper->CanHandleZone(context))
|
|
||||||
{
|
|
||||||
if (dumper->DumpZone(context))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Dumper for zone '%s' failed!\n", context.m_zone->m_name.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ObjWriting::ShouldHandleAssetType(const asset_type_t assetType)
|
bool ObjWriting::ShouldHandleAssetType(const asset_type_t assetType)
|
||||||
{
|
{
|
||||||
if (assetType < 0)
|
if (assetType < 0)
|
||||||
|
@ -34,6 +34,5 @@ public:
|
|||||||
|
|
||||||
} Configuration;
|
} Configuration;
|
||||||
|
|
||||||
static bool DumpZone(AssetDumpingContext& context);
|
|
||||||
static bool ShouldHandleAssetType(asset_type_t assetType);
|
static bool ShouldHandleAssetType(asset_type_t assetType);
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "ContentLister/ContentPrinter.h"
|
#include "ContentLister/ContentPrinter.h"
|
||||||
#include "ContentLister/ZoneDefWriter.h"
|
#include "ContentLister/ZoneDefWriter.h"
|
||||||
#include "IObjLoader.h"
|
#include "IObjLoader.h"
|
||||||
|
#include "IObjWriter.h"
|
||||||
#include "ObjContainer/IWD/IWD.h"
|
#include "ObjContainer/IWD/IWD.h"
|
||||||
#include "ObjLoading.h"
|
#include "ObjLoading.h"
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
@ -288,13 +289,22 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateAssetIncludesAndExcludes(context);
|
UpdateAssetIncludesAndExcludes(context);
|
||||||
ObjWriting::DumpZone(context);
|
|
||||||
|
const auto* objWriter = IObjWriter::GetObjWriterForGame(zone.m_game->GetId());
|
||||||
|
|
||||||
|
auto result = objWriter->DumpZone(context);
|
||||||
|
|
||||||
if (m_args.m_use_gdt)
|
if (m_args.m_use_gdt)
|
||||||
{
|
{
|
||||||
context.m_gdt->EndStream();
|
context.m_gdt->EndStream();
|
||||||
gdtStream.close();
|
gdtStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
std::cerr << "Dumping zone failed!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user