feat: T5 map ents dumper (#878)

* feat: T5 map ents dumper

* chore: adjust map ents dumper code style to each other

---------

Co-authored-by: Jan Laupetin <[email protected]>
This commit is contained in:
Ash
2026-07-12 01:03:53 +02:00
committed by GitHub
co-authored by Jan Laupetin
parent 0123595305
commit 28e27409f5
7 changed files with 40 additions and 6 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ using `Linker`):
| ComWorld | ❌ | ❌ | | | ComWorld | ❌ | ❌ | |
| GameWorldSp | ❌ | ❌ | | | GameWorldSp | ❌ | ❌ | |
| GameWorldMp | ❌ | ❌ | | | GameWorldMp | ❌ | ❌ | |
| MapEnts | | ❌ | | | MapEnts | | ❌ | |
| GfxWorld | ❌ | ❌ | | | GfxWorld | ❌ | ❌ | |
| GfxLightDef | ✅ | ✅ | | | GfxLightDef | ✅ | ✅ | |
| Font_s | ✅ | ✅ | | | Font_s | ✅ | ✅ | |
@@ -6,7 +6,7 @@ using namespace IW3;
namespace map_ents namespace map_ents
{ {
void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<MapEnts>& asset) void DumperIW3::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMapEnts::Type>& asset)
{ {
const auto* mapEnts = asset.Asset(); const auto* mapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(GetEntsFileNameForAssetName(asset.m_name)); const auto assetFile = context.OpenAssetFile(GetEntsFileNameForAssetName(asset.m_name));
@@ -15,6 +15,6 @@ namespace map_ents
return; return;
auto& stream = *assetFile; auto& stream = *assetFile;
stream.write(mapEnts->entityString, mapEnts->numEntityChars); stream.write(mapEnts->entityString, std::max(mapEnts->numEntityChars - 1, 0));
} }
} // namespace map_ents } // namespace map_ents
@@ -6,7 +6,7 @@ using namespace T4;
namespace map_ents namespace map_ents
{ {
void DumperT4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<MapEnts>& asset) void DumperT4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMapEnts::Type>& asset)
{ {
const auto* mapEnts = asset.Asset(); const auto* mapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(GetEntsFileNameForAssetName(asset.m_name)); const auto assetFile = context.OpenAssetFile(GetEntsFileNameForAssetName(asset.m_name));
@@ -0,0 +1,20 @@
#include "MapEntsDumperT5.h"
#include "Maps/MapEntsCommon.h"
using namespace T5;
namespace map_ents
{
void DumperT5::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetMapEnts::Type>& asset)
{
const auto* mapEnts = asset.Asset();
const auto assetFile = context.OpenAssetFile(GetEntsFileNameForAssetName(asset.m_name));
if (!assetFile)
return;
auto& stream = *assetFile;
stream.write(mapEnts->entityString, std::max(mapEnts->numEntityChars - 1, 0));
}
} // namespace map_ents
@@ -0,0 +1,13 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T5/T5.h"
namespace map_ents
{
class DumperT5 final : public AbstractAssetDumper<T5::AssetMapEnts>
{
protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetMapEnts::Type>& asset) override;
};
} // namespace map_ents
+2 -1
View File
@@ -8,6 +8,7 @@
#include "Game/T5/XModel/XModelDumperT5.h" #include "Game/T5/XModel/XModelDumperT5.h"
#include "LightDef/LightDefDumperT5.h" #include "LightDef/LightDefDumperT5.h"
#include "Localize/LocalizeDumperT5.h" #include "Localize/LocalizeDumperT5.h"
#include "Maps/MapEntsDumperT5.h"
#include "PhysPreset/PhysPresetInfoStringDumperT5.h" #include "PhysPreset/PhysPresetInfoStringDumperT5.h"
#include "RawFile/RawFileDumperT5.h" #include "RawFile/RawFileDumperT5.h"
#include "StringTable/StringTableDumperT5.h" #include "StringTable/StringTableDumperT5.h"
@@ -37,7 +38,7 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
// REGISTER_DUMPER(AssetDumperComWorld, m_com_world) // REGISTER_DUMPER(AssetDumperComWorld, m_com_world)
// REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp) // REGISTER_DUMPER(AssetDumperGameWorldSp, m_game_world_sp)
// REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp) // REGISTER_DUMPER(AssetDumperGameWorldMp, m_game_world_mp)
// REGISTER_DUMPER(AssetDumperMapEnts, m_map_ents) RegisterAssetDumper(std::make_unique<map_ents::DumperT5>());
// REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world) // REGISTER_DUMPER(AssetDumperGfxWorld, m_gfx_world)
RegisterAssetDumper(std::make_unique<light_def::DumperT5>()); RegisterAssetDumper(std::make_unique<light_def::DumperT5>());
RegisterAssetDumper(std::make_unique<font::JsonDumperT5>()); RegisterAssetDumper(std::make_unique<font::JsonDumperT5>());
@@ -15,6 +15,6 @@ namespace map_ents
return; return;
auto& stream = *assetFile; auto& stream = *assetFile;
stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1); stream.write(mapEnts->entityString, std::max(mapEnts->numEntityChars - 1, 0));
} }
} // namespace map_ents } // namespace map_ents