mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-09-09 15:37:05 +00:00
feat: templated tracer loading and dumping for IW4 and IW5 (#921)
Relates to https://github.com/Laupetin/OpenAssetTools/issues/626
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "Game/IW4/Techset/PixelShaderDumperIW4.h"
|
||||
#include "Game/IW4/Techset/TechsetDumperIW4.h"
|
||||
#include "Game/IW4/Techset/VertexShaderDumperIW4.h"
|
||||
#include "Game/IW4/Tracer/TracerDumperIW4.h"
|
||||
#include "Game/IW4/XAnim/XAnimDumperIW4.h"
|
||||
#include "Game/IW4/XModel/XModelDumperIW4.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
|
||||
@@ -22,7 +23,6 @@
|
||||
#include "Sound/SndCurveDumperIW4.h"
|
||||
#include "StringTable/StringTableDumperIW4.h"
|
||||
#include "StructuredDataDef/StructuredDataDefDumperIW4.h"
|
||||
#include "Tracer/TracerDumperIW4.h"
|
||||
#include "Vehicle/VehicleDumperIW4.h"
|
||||
#include "Weapon/WeaponDumperIW4.h"
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetTracer>
|
||||
{
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetTracer::Type>& asset) override;
|
||||
};
|
||||
} // namespace tracer
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Game/IW5/Techset/PixelShaderDumperIW5.h"
|
||||
#include "Game/IW5/Techset/TechsetDumperIW5.h"
|
||||
#include "Game/IW5/Techset/VertexShaderDumperIW5.h"
|
||||
#include "Game/IW5/Tracer/TracerDumperIW5.h"
|
||||
#include "Game/IW5/XModel/XModelDumperIW5.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
|
||||
#include "LightDef/LightDefDumperIW5.h"
|
||||
@@ -68,7 +69,7 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
|
||||
RegisterAssetDumper(std::make_unique<string_table::DumperIW5>());
|
||||
RegisterAssetDumper(std::make_unique<leaderboard::JsonDumperIW5>());
|
||||
// REGISTER_DUMPER(AssetDumperStructuredDataDefSet)
|
||||
// REGISTER_DUMPER(AssetDumperTracerDef)
|
||||
RegisterAssetDumper(std::make_unique<tracer::DumperIW5>());
|
||||
// REGISTER_DUMPER(AssetDumperVehicleDef)
|
||||
RegisterAssetDumper(std::make_unique<addon_map_ents::DumperIW5>());
|
||||
}
|
||||
|
||||
+23
-25
@@ -1,16 +1,28 @@
|
||||
#include "TracerDumperIW4.h"
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/InfoString/InfoStringFromStructConverter.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "Game/IW4/Tracer/TracerFields.h"
|
||||
#filename "Game/" + GAME + "/Tracer/TracerDumper" + GAME + ".cpp"
|
||||
|
||||
#set DUMPER_HEADER "\"TracerDumper" + GAME + ".h\""
|
||||
#set INFO_STRING_CONVERTER_HEADER "\"Game/" + GAME + "/InfoString/InfoStringFromStructConverter.h\""
|
||||
#set OBJ_CONSTANTS_HEADER "\"Game/" + GAME + "/ObjConstants" + GAME + ".h\""
|
||||
#set TRACER_FIELDS_HEADER "\"Game/" + GAME + "/Tracer/TracerFields.h\""
|
||||
#set CLASS_NAME "Dumper" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See TracerDumper.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include DUMPER_HEADER
|
||||
|
||||
#include INFO_STRING_CONVERTER_HEADER
|
||||
#include OBJ_CONSTANTS_HEADER
|
||||
#include TRACER_FIELDS_HEADER
|
||||
#include "Tracer/TracerCommon.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -23,36 +35,22 @@ namespace
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringFromTracerConverter(const TracerDef* structure,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount,
|
||||
std::function<std::string(scr_string_t)> scriptStringValueCallback)
|
||||
: InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback))
|
||||
InfoStringFromTracerConverter(const TracerDef* structure, const cspField_t* fields, const size_t fieldCount)
|
||||
: InfoStringFromStructConverter(structure, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
InfoString CreateInfoString(const XAssetInfo<TracerDef>& asset)
|
||||
{
|
||||
InfoStringFromTracerConverter converter(asset.Asset(),
|
||||
tracer_fields,
|
||||
std::extent_v<decltype(tracer_fields)>,
|
||||
[asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(scrStr < asset.m_zone->m_script_strings.Count());
|
||||
if (scrStr >= asset.m_zone->m_script_strings.Count())
|
||||
return "";
|
||||
|
||||
return asset.m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
InfoStringFromTracerConverter converter(asset.Asset(), tracer_fields, std::extent_v<decltype(tracer_fields)>);
|
||||
return converter.Convert();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetTracer::Type>& asset)
|
||||
void CLASS_NAME::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetTracer::Type>& asset)
|
||||
{
|
||||
// Only dump raw when no gdt available
|
||||
if (context.m_gdt)
|
||||
@@ -0,0 +1,24 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/TracerDumper" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set CLASS_NAME "Dumper" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See TracerDumper.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include GAME_HEADER
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
class CLASS_NAME final : public AbstractAssetDumper<GAME::AssetTracer>
|
||||
{
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<GAME::AssetTracer::Type>& asset) override;
|
||||
};
|
||||
} // namespace tracer
|
||||
Reference in New Issue
Block a user