2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-08-30 21:53:15 +00:00

refactor: streamline map assets dumper

This commit is contained in:
Jan Laupetin
2025-07-29 22:51:56 +01:00
parent 934ba7f95a
commit 9885a4ce93
16 changed files with 122 additions and 110 deletions

View File

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

View File

@@ -0,0 +1,23 @@
#include "MapEntsDumperIW3.h"
using namespace IW3;
namespace IW3::map_ents
{
bool Dumper::ShouldDump(XAssetInfo<MapEnts>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
{
const auto* mapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents");
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(mapEnts->entityString, mapEnts->numEntityChars);
}
} // namespace IW3::map_ents

View File

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

View File

@@ -4,7 +4,7 @@
#include "Game/IW3/XModel/XModelDumperIW3.h"
#include "Image/ImageDumperIW3.h"
#include "Localize/LocalizeDumperIW3.h"
#include "Maps/AssetDumperMapEnts.h"
#include "Maps/MapEntsDumperIW3.h"
#include "Material/DumperMaterialIW3.h"
#include "ObjWriting.h"
#include "RawFile/AssetDumperRawFile.h"
@@ -38,7 +38,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)

View File

@@ -0,0 +1,27 @@
#define NOMINMAX
#include "AddonMapEntsDumperIW4.h"
#include <algorithm>
using namespace IW4;
namespace IW4::addon_map_ents
{
bool Dumper::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset)
{
const auto* addonMapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0));
}
} // namespace IW4::addon_map_ents

View File

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

View File

@@ -1,24 +0,0 @@
#define NOMINMAX
#include "AssetDumperAddonMapEnts.h"
#include <algorithm>
using namespace IW4;
bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
{
return true;
}
void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset)
{
const auto* addonMapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0));
}

View File

@@ -6,7 +6,7 @@
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
#include "LightDef/LightDefDumperIW4.h"
#include "Localize/LocalizeDumperIW4.h"
#include "Maps/AssetDumperAddonMapEnts.h"
#include "Maps/AddonMapEntsDumperIW4.h"
#include "Material/DumperMaterialIW4.h"
#include "Menu/AssetDumperMenuDef.h"
#include "Menu/AssetDumperMenuList.h"
@@ -72,7 +72,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER)
DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE)
DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
return true;

View File

@@ -0,0 +1,26 @@
#define NOMINMAX
#include "AddonMapEntsDumperIW5.h"
#include <algorithm>
using namespace IW5;
namespace IW5::addon_map_ents
{
bool Dumper::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset)
{
const auto* addonMapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0));
}
} // namespace IW5::addon_map_ents

View File

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

View File

@@ -1,23 +0,0 @@
#define NOMINMAX
#include "AssetDumperAddonMapEnts.h"
#include <algorithm>
using namespace IW5;
bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
{
return true;
}
void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset)
{
const auto* addonMapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0));
}

View File

@@ -5,7 +5,7 @@
#include "Image/ImageDumperIW5.h"
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
#include "Localize/LocalizeDumperIW5.h"
#include "Maps/AssetDumperAddonMapEnts.h"
#include "Maps/AddonMapEntsDumperIW5.h"
#include "Material/DumperMaterialIW5.h"
#include "Menu/AssetDumperMenuDef.h"
#include "Menu/AssetDumperMenuList.h"
@@ -68,7 +68,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
// DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER)
// DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE)
DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
return true;

View File

@@ -1,23 +0,0 @@
#include "AssetDumperMapEnts.h"
#include <format>
using namespace T6;
bool AssetDumperMapEnts::ShouldDump(XAssetInfo<MapEnts>* asset)
{
return true;
}
void AssetDumperMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
{
const auto* mapEnts = asset->Asset();
const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name));
if (!mapEntsFile)
return;
auto& stream = *mapEntsFile;
stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1);
}

View File

@@ -0,0 +1,26 @@
#include "MapEntsDumperT6.h"
#include <format>
using namespace T6;
namespace T6::map_ents
{
bool Dumper::ShouldDump(XAssetInfo<MapEnts>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
{
const auto* mapEnts = asset->Asset();
const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name));
if (!mapEntsFile)
return;
auto& stream = *mapEntsFile;
stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1);
}
} // namespace T6::map_ents

View File

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

View File

@@ -6,7 +6,7 @@
#include "Image/ImageDumperT6.h"
#include "Leaderboard/LeaderboardJsonDumperT6.h"
#include "Localize/LocalizeDumperT6.h"
#include "Maps/AssetDumperMapEnts.h"
#include "Maps/MapEntsDumperT6.h"
#include "Material/DumperMaterialT6.h"
#include "ObjWriting.h"
#include "PhysConstraints/AssetDumperPhysConstraints.h"
@@ -60,7 +60,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)