mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-26 18:00:38 +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:
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
inline cspField_t tracer_fields[]{
|
||||
{"material", offsetof(TracerDef, material), CSPFT_MATERIAL},
|
||||
{"drawInterval", offsetof(TracerDef, drawInterval), CSPFT_INT },
|
||||
{"speed", offsetof(TracerDef, speed), CSPFT_FLOAT },
|
||||
{"beamLength", offsetof(TracerDef, beamLength), CSPFT_FLOAT },
|
||||
{"beamWidth", offsetof(TracerDef, beamWidth), CSPFT_FLOAT },
|
||||
{"screwRadius", offsetof(TracerDef, screwRadius), CSPFT_FLOAT },
|
||||
{"screwDist", offsetof(TracerDef, screwDist), CSPFT_FLOAT },
|
||||
{"colorR0", offsetof(TracerDef, colors[0][0]), CSPFT_FLOAT },
|
||||
{"colorG0", offsetof(TracerDef, colors[0][1]), CSPFT_FLOAT },
|
||||
{"colorB0", offsetof(TracerDef, colors[0][2]), CSPFT_FLOAT },
|
||||
{"colorA0", offsetof(TracerDef, colors[0][3]), CSPFT_FLOAT },
|
||||
{"colorR1", offsetof(TracerDef, colors[1][0]), CSPFT_FLOAT },
|
||||
{"colorG1", offsetof(TracerDef, colors[1][1]), CSPFT_FLOAT },
|
||||
{"colorB1", offsetof(TracerDef, colors[1][2]), CSPFT_FLOAT },
|
||||
{"colorA1", offsetof(TracerDef, colors[1][3]), CSPFT_FLOAT },
|
||||
{"colorR2", offsetof(TracerDef, colors[2][0]), CSPFT_FLOAT },
|
||||
{"colorG2", offsetof(TracerDef, colors[2][1]), CSPFT_FLOAT },
|
||||
{"colorB2", offsetof(TracerDef, colors[2][2]), CSPFT_FLOAT },
|
||||
{"colorA2", offsetof(TracerDef, colors[2][3]), CSPFT_FLOAT },
|
||||
{"colorR3", offsetof(TracerDef, colors[3][0]), CSPFT_FLOAT },
|
||||
{"colorG3", offsetof(TracerDef, colors[3][1]), CSPFT_FLOAT },
|
||||
{"colorB3", offsetof(TracerDef, colors[3][2]), CSPFT_FLOAT },
|
||||
{"colorA3", offsetof(TracerDef, colors[3][3]), CSPFT_FLOAT },
|
||||
{"colorR4", offsetof(TracerDef, colors[4][0]), CSPFT_FLOAT },
|
||||
{"colorG4", offsetof(TracerDef, colors[4][1]), CSPFT_FLOAT },
|
||||
{"colorB4", offsetof(TracerDef, colors[4][2]), CSPFT_FLOAT },
|
||||
{"colorA4", offsetof(TracerDef, colors[4][3]), CSPFT_FLOAT },
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Game/IW4/Image/ImageLoaderExternalIW4.h"
|
||||
#include "Game/IW4/Techset/PixelShaderLoaderIW4.h"
|
||||
#include "Game/IW4/Techset/VertexShaderLoaderIW4.h"
|
||||
#include "Game/IW4/Tracer/GdtLoaderTracerIW4.h"
|
||||
#include "Game/IW4/Tracer/RawLoaderTracerIW4.h"
|
||||
#include "Game/IW4/Weapon/AccuracyGraphLoaderIW4.h"
|
||||
#include "Game/IW4/XAnim/XAnimLoaderIW4.h"
|
||||
#include "Game/IW4/XModel/LoaderXModelIW4.h"
|
||||
@@ -159,7 +161,8 @@ namespace
|
||||
collection.AddAssetCreator(string_table::CreateLoaderIW4(memory, searchPath));
|
||||
collection.AddAssetCreator(leaderboard::CreateLoaderIW4(memory, searchPath));
|
||||
collection.AddAssetCreator(structured_data_def::CreateLoaderIW4(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTracer>(memory));
|
||||
collection.AddAssetCreator(tracer::CreateRawLoaderIW4(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(tracer::CreateGdtLoaderIW4(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAddonMapEnts>(memory));
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Game/IW5/Image/ImageLoaderExternalIW5.h"
|
||||
#include "Game/IW5/Techset/PixelShaderLoaderIW5.h"
|
||||
#include "Game/IW5/Techset/VertexShaderLoaderIW5.h"
|
||||
#include "Game/IW5/Tracer/GdtLoaderTracerIW5.h"
|
||||
#include "Game/IW5/Tracer/RawLoaderTracerIW5.h"
|
||||
#include "Game/IW5/Weapon/AccuracyGraphLoaderIW5.h"
|
||||
#include "Game/IW5/XAnim/XAnimLoaderIW5.h"
|
||||
#include "Game/IW5/XModel/LoaderXModelIW5.h"
|
||||
@@ -170,7 +172,8 @@ namespace
|
||||
collection.AddAssetCreator(string_table::CreateLoaderIW5(memory, searchPath));
|
||||
collection.AddAssetCreator(leaderboard::CreateLoaderIW5(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderStructuredDataDef>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTracer>(memory));
|
||||
collection.AddAssetCreator(tracer::CreateRawLoaderIW5(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(tracer::CreateGdtLoaderIW5(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAddonMapEnts>(memory));
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/GdtLoaderTracer" + GAME + ".cpp"
|
||||
|
||||
#set LOADER_HEADER "\"GdtLoaderTracer" + GAME + ".h\""
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set OBJ_CONSTANTS_HEADER "\"Game/" + GAME + "/ObjConstants" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_HEADER "\"InfoStringLoaderTracer" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_CLASS "InfoStringLoader" + GAME
|
||||
#set FACTORY_NAME "CreateGdtLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See GdtLoaderTracer.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include LOADER_HEADER
|
||||
|
||||
#include GAME_HEADER
|
||||
#include OBJ_CONSTANTS_HEADER
|
||||
#include "InfoString/InfoString.h"
|
||||
#include INFO_STRING_LOADER_HEADER
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
class GdtLoaderTracer final : public AssetCreator<AssetTracer>
|
||||
{
|
||||
public:
|
||||
GdtLoaderTracer(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
: m_gdt(gdt),
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(GDF_FILENAME_TRACER, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||
{
|
||||
con::error("Failed to read tracer gdt entry: \"{}\"", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return m_info_string_loader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
tracer::INFO_STRING_LOADER_CLASS m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> FACTORY_NAME(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderTracer>(memory, gdt, zone);
|
||||
}
|
||||
} // namespace tracer
|
||||
@@ -0,0 +1,24 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/GdtLoaderTracer" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set FACTORY_NAME "CreateGdtLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See GdtLoaderTracer.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include GAME_HEADER
|
||||
#include "Gdt/IGdtQueryable.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<GAME::AssetTracer>> FACTORY_NAME(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace tracer
|
||||
@@ -0,0 +1,77 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/InfoStringLoaderTracer" + GAME + ".cpp"
|
||||
|
||||
#set LOADER_HEADER "\"InfoStringLoaderTracer" + GAME + ".h\""
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set INFO_STRING_CONVERTER_HEADER "\"Game/" + GAME + "/InfoString/InfoStringToStructConverter.h\""
|
||||
#set TRACER_FIELDS_HEADER "\"Game/" + GAME + "/Tracer/TracerFields.h\""
|
||||
#set CLASS_NAME "InfoStringLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See InfoStringLoaderTracer.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include LOADER_HEADER
|
||||
|
||||
#include GAME_HEADER
|
||||
#include INFO_STRING_CONVERTER_HEADER
|
||||
#include TRACER_FIELDS_HEADER
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
class InfoStringToTracerConverter final : public InfoStringToStructConverter
|
||||
{
|
||||
protected:
|
||||
bool ConvertExtensionField(const cspField_t& field, const std::string& value) override
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToTracerConverter(const InfoString& infoString,
|
||||
TracerDef& tracer,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager& memory,
|
||||
AssetCreationContext& context,
|
||||
AssetRegistration<AssetTracer>& registration,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, &tracer, zoneScriptStrings, memory, context, registration, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
CLASS_NAME::CLASS_NAME(MemoryManager& memory, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_zone(zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CLASS_NAME::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* tracer = m_memory.Alloc<TracerDef>();
|
||||
tracer->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetTracer> registration(assetName, tracer);
|
||||
InfoStringToTracerConverter converter(
|
||||
infoString, *tracer, m_zone.m_script_strings, m_memory, context, registration, tracer_fields, std::extent_v<decltype(tracer_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
con::error("Failed to parse tracer: \"{}\"", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace tracer
|
||||
@@ -0,0 +1,30 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/InfoStringLoaderTracer" + GAME + ".h"
|
||||
|
||||
#set CLASS_NAME "InfoStringLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See InfoStringLoaderTracer.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
class CLASS_NAME
|
||||
{
|
||||
public:
|
||||
CLASS_NAME(MemoryManager& memory, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace tracer
|
||||
@@ -0,0 +1,67 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/RawLoaderTracer" + GAME + ".cpp"
|
||||
|
||||
#set LOADER_HEADER "\"RawLoaderTracer" + GAME + ".h\""
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set OBJ_CONSTANTS_HEADER "\"Game/" + GAME + "/ObjConstants" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_HEADER "\"InfoStringLoaderTracer" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_CLASS "InfoStringLoader" + GAME
|
||||
#set FACTORY_NAME "CreateRawLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See RawLoaderTracer.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include LOADER_HEADER
|
||||
|
||||
#include GAME_HEADER
|
||||
#include OBJ_CONSTANTS_HEADER
|
||||
#include "InfoString/InfoString.h"
|
||||
#include INFO_STRING_LOADER_HEADER
|
||||
#include "Tracer/TracerCommon.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
class RawLoaderTracer final : public AssetCreator<AssetTracer>
|
||||
{
|
||||
public:
|
||||
RawLoaderTracer(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_search_path(searchPath),
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = tracer::GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromStream(INFO_STRING_PREFIX_TRACER, *file.m_stream))
|
||||
{
|
||||
con::error("Could not parse as info string file: \"{}\"", fileName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return m_info_string_loader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
tracer::INFO_STRING_LOADER_CLASS m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> FACTORY_NAME(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderTracer>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace tracer
|
||||
@@ -0,0 +1,24 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Tracer/RawLoaderTracer" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set FACTORY_NAME "CreateRawLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See RawLoaderTracer.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include GAME_HEADER
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<GAME::AssetTracer>> FACTORY_NAME(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace tracer
|
||||
@@ -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