mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-27 12:31:50 +00:00
chore: expose marker classes as asset specializations
This commit is contained in:
@@ -145,7 +145,7 @@ namespace
|
||||
LINE("")
|
||||
LINEF("#include \"{0}_load_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
||||
LINE("")
|
||||
LINEF("#include \"{0}_mark_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
|
||||
LINEF("#include \"Game/{0}/AssetMarker{0}.h\"", m_env.m_game)
|
||||
LINE("")
|
||||
LINE("#include \"Loading/AssetInfoCollector.h\"")
|
||||
|
||||
@@ -238,11 +238,6 @@ namespace
|
||||
return std::format("Loader_{0}", asset->m_definition->m_name);
|
||||
}
|
||||
|
||||
static std::string MarkerClassName(const StructureInformation* asset)
|
||||
{
|
||||
return std::format("Marker_{0}", asset->m_definition->m_name);
|
||||
}
|
||||
|
||||
static std::string VariableDecl(const DataDefinition* def)
|
||||
{
|
||||
return std::format("{0}* var{1};", def->GetFullName(), MakeSafeTypeName(def));
|
||||
@@ -2158,7 +2153,7 @@ namespace
|
||||
LINE("assert(pAsset != nullptr);")
|
||||
LINE("")
|
||||
LINE("AssetInfoCollector assetInfo(m_zone);")
|
||||
LINEF("{0} marker(assetInfo);", MarkerClassName(m_env.m_asset))
|
||||
LINEF("AssetMarker<{0}> marker(assetInfo);", m_env.m_asset->m_asset_name)
|
||||
LINE("marker.Mark(*pAsset);")
|
||||
LINE("")
|
||||
LINEF("auto* reallocatedAsset = m_zone.Memory().Alloc<{0}>();", info->m_definition->GetFullName())
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace
|
||||
LINE("#pragma once")
|
||||
LINE("")
|
||||
LINEF("#include \"Game/{0}/{0}.h\"", m_env.m_game)
|
||||
LINE("#include \"Marking/AssetMarker.h\"")
|
||||
LINE("#include \"Marking/BaseAssetMarker.h\"")
|
||||
LINE("#include \"Marking/AssetVisitor.h\"")
|
||||
LINE("")
|
||||
LINE("#include <string>")
|
||||
@@ -40,7 +40,7 @@ namespace
|
||||
LINEF("namespace {0}", m_env.m_game)
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINEF("class {0} final : public AssetMarker", MarkerClassName(m_env.m_asset))
|
||||
LINEF("class {0} final : public BaseAssetMarker", MarkerClassName(m_env.m_asset))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
@@ -107,6 +107,8 @@ namespace
|
||||
LINE("};")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
LINE("")
|
||||
LINEF("DEFINE_MARKER_CLASS_FOR_ASSET({0}::{1}, {0}::{2})", m_env.m_game, m_env.m_asset->m_asset_name, MarkerClassName(m_env.m_asset))
|
||||
}
|
||||
|
||||
void Source()
|
||||
@@ -233,7 +235,7 @@ namespace
|
||||
LINEF("{0}::{0}(AssetVisitor& visitor)", MarkerClassName(m_env.m_asset))
|
||||
|
||||
m_intendation++;
|
||||
LINE(": AssetMarker(visitor)")
|
||||
LINE(": BaseAssetMarker(visitor)")
|
||||
m_intendation--;
|
||||
|
||||
LINE("{")
|
||||
|
||||
27
src/ZoneCommon/Game/IW3/AssetMarkerIW3.h
Normal file
27
src/ZoneCommon/Game/IW3/AssetMarkerIW3.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW3/XAssets/clipmap_t/clipmap_t_mark_db.h"
|
||||
#include "Game/IW3/XAssets/comworld/comworld_mark_db.h"
|
||||
#include "Game/IW3/XAssets/font_s/font_s_mark_db.h"
|
||||
#include "Game/IW3/XAssets/fxeffectdef/fxeffectdef_mark_db.h"
|
||||
#include "Game/IW3/XAssets/fximpacttable/fximpacttable_mark_db.h"
|
||||
#include "Game/IW3/XAssets/gameworldmp/gameworldmp_mark_db.h"
|
||||
#include "Game/IW3/XAssets/gameworldsp/gameworldsp_mark_db.h"
|
||||
#include "Game/IW3/XAssets/gfximage/gfximage_mark_db.h"
|
||||
#include "Game/IW3/XAssets/gfxlightdef/gfxlightdef_mark_db.h"
|
||||
#include "Game/IW3/XAssets/gfxworld/gfxworld_mark_db.h"
|
||||
#include "Game/IW3/XAssets/loadedsound/loadedsound_mark_db.h"
|
||||
#include "Game/IW3/XAssets/localizeentry/localizeentry_mark_db.h"
|
||||
#include "Game/IW3/XAssets/mapents/mapents_mark_db.h"
|
||||
#include "Game/IW3/XAssets/material/material_mark_db.h"
|
||||
#include "Game/IW3/XAssets/materialtechniqueset/materialtechniqueset_mark_db.h"
|
||||
#include "Game/IW3/XAssets/menudef_t/menudef_t_mark_db.h"
|
||||
#include "Game/IW3/XAssets/menulist/menulist_mark_db.h"
|
||||
#include "Game/IW3/XAssets/physpreset/physpreset_mark_db.h"
|
||||
#include "Game/IW3/XAssets/rawfile/rawfile_mark_db.h"
|
||||
#include "Game/IW3/XAssets/snd_alias_list_t/snd_alias_list_t_mark_db.h"
|
||||
#include "Game/IW3/XAssets/sndcurve/sndcurve_mark_db.h"
|
||||
#include "Game/IW3/XAssets/stringtable/stringtable_mark_db.h"
|
||||
#include "Game/IW3/XAssets/weapondef/weapondef_mark_db.h"
|
||||
#include "Game/IW3/XAssets/xanimparts/xanimparts_mark_db.h"
|
||||
#include "Game/IW3/XAssets/xmodel/xmodel_mark_db.h"
|
||||
37
src/ZoneCommon/Game/IW4/AssetMarkerIW4.h
Normal file
37
src/ZoneCommon/Game/IW4/AssetMarkerIW4.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/XAssets/addonmapents/addonmapents_mark_db.h"
|
||||
#include "Game/IW4/XAssets/clipmap_t/clipmap_t_mark_db.h"
|
||||
#include "Game/IW4/XAssets/comworld/comworld_mark_db.h"
|
||||
#include "Game/IW4/XAssets/font_s/font_s_mark_db.h"
|
||||
#include "Game/IW4/XAssets/fxeffectdef/fxeffectdef_mark_db.h"
|
||||
#include "Game/IW4/XAssets/fximpacttable/fximpacttable_mark_db.h"
|
||||
#include "Game/IW4/XAssets/fxworld/fxworld_mark_db.h"
|
||||
#include "Game/IW4/XAssets/gameworldmp/gameworldmp_mark_db.h"
|
||||
#include "Game/IW4/XAssets/gameworldsp/gameworldsp_mark_db.h"
|
||||
#include "Game/IW4/XAssets/gfximage/gfximage_mark_db.h"
|
||||
#include "Game/IW4/XAssets/gfxlightdef/gfxlightdef_mark_db.h"
|
||||
#include "Game/IW4/XAssets/gfxworld/gfxworld_mark_db.h"
|
||||
#include "Game/IW4/XAssets/leaderboarddef/leaderboarddef_mark_db.h"
|
||||
#include "Game/IW4/XAssets/loadedsound/loadedsound_mark_db.h"
|
||||
#include "Game/IW4/XAssets/localizeentry/localizeentry_mark_db.h"
|
||||
#include "Game/IW4/XAssets/mapents/mapents_mark_db.h"
|
||||
#include "Game/IW4/XAssets/material/material_mark_db.h"
|
||||
#include "Game/IW4/XAssets/materialpixelshader/materialpixelshader_mark_db.h"
|
||||
#include "Game/IW4/XAssets/materialtechniqueset/materialtechniqueset_mark_db.h"
|
||||
#include "Game/IW4/XAssets/materialvertexdeclaration/materialvertexdeclaration_mark_db.h"
|
||||
#include "Game/IW4/XAssets/materialvertexshader/materialvertexshader_mark_db.h"
|
||||
#include "Game/IW4/XAssets/menudef_t/menudef_t_mark_db.h"
|
||||
#include "Game/IW4/XAssets/menulist/menulist_mark_db.h"
|
||||
#include "Game/IW4/XAssets/physcollmap/physcollmap_mark_db.h"
|
||||
#include "Game/IW4/XAssets/physpreset/physpreset_mark_db.h"
|
||||
#include "Game/IW4/XAssets/rawfile/rawfile_mark_db.h"
|
||||
#include "Game/IW4/XAssets/snd_alias_list_t/snd_alias_list_t_mark_db.h"
|
||||
#include "Game/IW4/XAssets/sndcurve/sndcurve_mark_db.h"
|
||||
#include "Game/IW4/XAssets/stringtable/stringtable_mark_db.h"
|
||||
#include "Game/IW4/XAssets/structureddatadefset/structureddatadefset_mark_db.h"
|
||||
#include "Game/IW4/XAssets/tracerdef/tracerdef_mark_db.h"
|
||||
#include "Game/IW4/XAssets/vehicledef/vehicledef_mark_db.h"
|
||||
#include "Game/IW4/XAssets/weaponcompletedef/weaponcompletedef_mark_db.h"
|
||||
#include "Game/IW4/XAssets/xanimparts/xanimparts_mark_db.h"
|
||||
#include "Game/IW4/XAssets/xmodel/xmodel_mark_db.h"
|
||||
42
src/ZoneCommon/Game/IW5/AssetMarkerIW5.h
Normal file
42
src/ZoneCommon/Game/IW5/AssetMarkerIW5.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW5/XAssets/addonmapents/addonmapents_mark_db.h"
|
||||
#include "Game/IW5/XAssets/clipmap_t/clipmap_t_mark_db.h"
|
||||
#include "Game/IW5/XAssets/comworld/comworld_mark_db.h"
|
||||
#include "Game/IW5/XAssets/font_s/font_s_mark_db.h"
|
||||
#include "Game/IW5/XAssets/fxeffectdef/fxeffectdef_mark_db.h"
|
||||
#include "Game/IW5/XAssets/fximpacttable/fximpacttable_mark_db.h"
|
||||
#include "Game/IW5/XAssets/fxworld/fxworld_mark_db.h"
|
||||
#include "Game/IW5/XAssets/gfximage/gfximage_mark_db.h"
|
||||
#include "Game/IW5/XAssets/gfxlightdef/gfxlightdef_mark_db.h"
|
||||
#include "Game/IW5/XAssets/gfxworld/gfxworld_mark_db.h"
|
||||
#include "Game/IW5/XAssets/glassworld/glassworld_mark_db.h"
|
||||
#include "Game/IW5/XAssets/leaderboarddef/leaderboarddef_mark_db.h"
|
||||
#include "Game/IW5/XAssets/loadedsound/loadedsound_mark_db.h"
|
||||
#include "Game/IW5/XAssets/localizeentry/localizeentry_mark_db.h"
|
||||
#include "Game/IW5/XAssets/mapents/mapents_mark_db.h"
|
||||
#include "Game/IW5/XAssets/material/material_mark_db.h"
|
||||
#include "Game/IW5/XAssets/materialpixelshader/materialpixelshader_mark_db.h"
|
||||
#include "Game/IW5/XAssets/materialtechniqueset/materialtechniqueset_mark_db.h"
|
||||
#include "Game/IW5/XAssets/materialvertexdeclaration/materialvertexdeclaration_mark_db.h"
|
||||
#include "Game/IW5/XAssets/materialvertexshader/materialvertexshader_mark_db.h"
|
||||
#include "Game/IW5/XAssets/menudef_t/menudef_t_mark_db.h"
|
||||
#include "Game/IW5/XAssets/menulist/menulist_mark_db.h"
|
||||
#include "Game/IW5/XAssets/pathdata/pathdata_mark_db.h"
|
||||
#include "Game/IW5/XAssets/physcollmap/physcollmap_mark_db.h"
|
||||
#include "Game/IW5/XAssets/physpreset/physpreset_mark_db.h"
|
||||
#include "Game/IW5/XAssets/rawfile/rawfile_mark_db.h"
|
||||
#include "Game/IW5/XAssets/scriptfile/scriptfile_mark_db.h"
|
||||
#include "Game/IW5/XAssets/snd_alias_list_t/snd_alias_list_t_mark_db.h"
|
||||
#include "Game/IW5/XAssets/sndcurve/sndcurve_mark_db.h"
|
||||
#include "Game/IW5/XAssets/stringtable/stringtable_mark_db.h"
|
||||
#include "Game/IW5/XAssets/structureddatadefset/structureddatadefset_mark_db.h"
|
||||
#include "Game/IW5/XAssets/surfacefxtable/surfacefxtable_mark_db.h"
|
||||
#include "Game/IW5/XAssets/tracerdef/tracerdef_mark_db.h"
|
||||
#include "Game/IW5/XAssets/vehicledef/vehicledef_mark_db.h"
|
||||
#include "Game/IW5/XAssets/vehicletrack/vehicletrack_mark_db.h"
|
||||
#include "Game/IW5/XAssets/weaponattachment/weaponattachment_mark_db.h"
|
||||
#include "Game/IW5/XAssets/weaponcompletedef/weaponcompletedef_mark_db.h"
|
||||
#include "Game/IW5/XAssets/xanimparts/xanimparts_mark_db.h"
|
||||
#include "Game/IW5/XAssets/xmodel/xmodel_mark_db.h"
|
||||
#include "Game/IW5/XAssets/xmodelsurfs/xmodelsurfs_mark_db.h"
|
||||
34
src/ZoneCommon/Game/T5/AssetMarkerT5.h
Normal file
34
src/ZoneCommon/Game/T5/AssetMarkerT5.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T5/XAssets/clipmap_t/clipmap_t_mark_db.h"
|
||||
#include "Game/T5/XAssets/comworld/comworld_mark_db.h"
|
||||
#include "Game/T5/XAssets/ddlroot_t/ddlroot_t_mark_db.h"
|
||||
#include "Game/T5/XAssets/destructibledef/destructibledef_mark_db.h"
|
||||
#include "Game/T5/XAssets/emblemset/emblemset_mark_db.h"
|
||||
#include "Game/T5/XAssets/font_s/font_s_mark_db.h"
|
||||
#include "Game/T5/XAssets/fxeffectdef/fxeffectdef_mark_db.h"
|
||||
#include "Game/T5/XAssets/fximpacttable/fximpacttable_mark_db.h"
|
||||
#include "Game/T5/XAssets/gameworldmp/gameworldmp_mark_db.h"
|
||||
#include "Game/T5/XAssets/gameworldsp/gameworldsp_mark_db.h"
|
||||
#include "Game/T5/XAssets/gfximage/gfximage_mark_db.h"
|
||||
#include "Game/T5/XAssets/gfxlightdef/gfxlightdef_mark_db.h"
|
||||
#include "Game/T5/XAssets/gfxworld/gfxworld_mark_db.h"
|
||||
#include "Game/T5/XAssets/glasses/glasses_mark_db.h"
|
||||
#include "Game/T5/XAssets/localizeentry/localizeentry_mark_db.h"
|
||||
#include "Game/T5/XAssets/mapents/mapents_mark_db.h"
|
||||
#include "Game/T5/XAssets/material/material_mark_db.h"
|
||||
#include "Game/T5/XAssets/materialtechniqueset/materialtechniqueset_mark_db.h"
|
||||
#include "Game/T5/XAssets/menudef_t/menudef_t_mark_db.h"
|
||||
#include "Game/T5/XAssets/menulist/menulist_mark_db.h"
|
||||
#include "Game/T5/XAssets/packindex/packindex_mark_db.h"
|
||||
#include "Game/T5/XAssets/physconstraints/physconstraints_mark_db.h"
|
||||
#include "Game/T5/XAssets/physpreset/physpreset_mark_db.h"
|
||||
#include "Game/T5/XAssets/rawfile/rawfile_mark_db.h"
|
||||
#include "Game/T5/XAssets/sndbank/sndbank_mark_db.h"
|
||||
#include "Game/T5/XAssets/snddriverglobals/snddriverglobals_mark_db.h"
|
||||
#include "Game/T5/XAssets/sndpatch/sndpatch_mark_db.h"
|
||||
#include "Game/T5/XAssets/stringtable/stringtable_mark_db.h"
|
||||
#include "Game/T5/XAssets/weaponvariantdef/weaponvariantdef_mark_db.h"
|
||||
#include "Game/T5/XAssets/xanimparts/xanimparts_mark_db.h"
|
||||
#include "Game/T5/XAssets/xglobals/xglobals_mark_db.h"
|
||||
#include "Game/T5/XAssets/xmodel/xmodel_mark_db.h"
|
||||
50
src/ZoneCommon/Game/T6/AssetMarkerT6.h
Normal file
50
src/ZoneCommon/Game/T6/AssetMarkerT6.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T6/XAssets/addonmapents/addonmapents_mark_db.h"
|
||||
#include "Game/T6/XAssets/clipmap_t/clipmap_t_mark_db.h"
|
||||
#include "Game/T6/XAssets/comworld/comworld_mark_db.h"
|
||||
#include "Game/T6/XAssets/ddlroot_t/ddlroot_t_mark_db.h"
|
||||
#include "Game/T6/XAssets/destructibledef/destructibledef_mark_db.h"
|
||||
#include "Game/T6/XAssets/emblemset/emblemset_mark_db.h"
|
||||
#include "Game/T6/XAssets/font_s/font_s_mark_db.h"
|
||||
#include "Game/T6/XAssets/fonticon/fonticon_mark_db.h"
|
||||
#include "Game/T6/XAssets/footstepfxtabledef/footstepfxtabledef_mark_db.h"
|
||||
#include "Game/T6/XAssets/footsteptabledef/footsteptabledef_mark_db.h"
|
||||
#include "Game/T6/XAssets/fxeffectdef/fxeffectdef_mark_db.h"
|
||||
#include "Game/T6/XAssets/fximpacttable/fximpacttable_mark_db.h"
|
||||
#include "Game/T6/XAssets/gameworldmp/gameworldmp_mark_db.h"
|
||||
#include "Game/T6/XAssets/gameworldsp/gameworldsp_mark_db.h"
|
||||
#include "Game/T6/XAssets/gfximage/gfximage_mark_db.h"
|
||||
#include "Game/T6/XAssets/gfxlightdef/gfxlightdef_mark_db.h"
|
||||
#include "Game/T6/XAssets/gfxworld/gfxworld_mark_db.h"
|
||||
#include "Game/T6/XAssets/glasses/glasses_mark_db.h"
|
||||
#include "Game/T6/XAssets/keyvaluepairs/keyvaluepairs_mark_db.h"
|
||||
#include "Game/T6/XAssets/leaderboarddef/leaderboarddef_mark_db.h"
|
||||
#include "Game/T6/XAssets/localizeentry/localizeentry_mark_db.h"
|
||||
#include "Game/T6/XAssets/mapents/mapents_mark_db.h"
|
||||
#include "Game/T6/XAssets/material/material_mark_db.h"
|
||||
#include "Game/T6/XAssets/materialtechniqueset/materialtechniqueset_mark_db.h"
|
||||
#include "Game/T6/XAssets/memoryblock/memoryblock_mark_db.h"
|
||||
#include "Game/T6/XAssets/menudef_t/menudef_t_mark_db.h"
|
||||
#include "Game/T6/XAssets/menulist/menulist_mark_db.h"
|
||||
#include "Game/T6/XAssets/physconstraints/physconstraints_mark_db.h"
|
||||
#include "Game/T6/XAssets/physpreset/physpreset_mark_db.h"
|
||||
#include "Game/T6/XAssets/qdb/qdb_mark_db.h"
|
||||
#include "Game/T6/XAssets/rawfile/rawfile_mark_db.h"
|
||||
#include "Game/T6/XAssets/scriptparsetree/scriptparsetree_mark_db.h"
|
||||
#include "Game/T6/XAssets/skinnedvertsdef/skinnedvertsdef_mark_db.h"
|
||||
#include "Game/T6/XAssets/slug/slug_mark_db.h"
|
||||
#include "Game/T6/XAssets/sndbank/sndbank_mark_db.h"
|
||||
#include "Game/T6/XAssets/snddriverglobals/snddriverglobals_mark_db.h"
|
||||
#include "Game/T6/XAssets/sndpatch/sndpatch_mark_db.h"
|
||||
#include "Game/T6/XAssets/stringtable/stringtable_mark_db.h"
|
||||
#include "Game/T6/XAssets/tracerdef/tracerdef_mark_db.h"
|
||||
#include "Game/T6/XAssets/vehicledef/vehicledef_mark_db.h"
|
||||
#include "Game/T6/XAssets/weaponattachment/weaponattachment_mark_db.h"
|
||||
#include "Game/T6/XAssets/weaponattachmentunique/weaponattachmentunique_mark_db.h"
|
||||
#include "Game/T6/XAssets/weaponcamo/weaponcamo_mark_db.h"
|
||||
#include "Game/T6/XAssets/weaponvariantdef/weaponvariantdef_mark_db.h"
|
||||
#include "Game/T6/XAssets/xanimparts/xanimparts_mark_db.h"
|
||||
#include "Game/T6/XAssets/xglobals/xglobals_mark_db.h"
|
||||
#include "Game/T6/XAssets/xmodel/xmodel_mark_db.h"
|
||||
#include "Game/T6/XAssets/zbarrierdef/zbarrierdef_mark_db.h"
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IAsset.h"
|
||||
#include "Marking/AssetVisitor.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
class AssetMarker
|
||||
{
|
||||
protected:
|
||||
explicit AssetMarker(AssetVisitor& visitor);
|
||||
|
||||
template<typename AssetType> void Mark_Dependency(std::add_lvalue_reference_t<std::add_pointer_t<typename AssetType::Type>> asset)
|
||||
{
|
||||
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||
|
||||
const auto result = m_visitor.Visit_Dependency(AssetType::EnumEntry, AssetNameAccessor<AssetType>()(*asset));
|
||||
if (result.has_value())
|
||||
asset = static_cast<std::add_pointer_t<typename AssetType::Type>>(result->m_ptr);
|
||||
}
|
||||
|
||||
void Mark_ScriptString(scr_string_t& scriptString) const;
|
||||
void MarkArray_ScriptString(scr_string_t* scriptStringArray, size_t count) const;
|
||||
|
||||
void Mark_IndirectAssetRef(asset_type_t assetType, const char* assetName) const;
|
||||
void MarkArray_IndirectAssetRef(asset_type_t assetType, const char** assetNames, size_t count) const;
|
||||
|
||||
AssetVisitor& m_visitor;
|
||||
};
|
||||
@@ -1,21 +1,21 @@
|
||||
#include "AssetMarker.h"
|
||||
#include "BaseAssetMarker.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
AssetMarker::AssetMarker(AssetVisitor& visitor)
|
||||
BaseAssetMarker::BaseAssetMarker(AssetVisitor& visitor)
|
||||
: m_visitor(visitor)
|
||||
{
|
||||
}
|
||||
|
||||
void AssetMarker::Mark_ScriptString(scr_string_t& scriptString) const
|
||||
void BaseAssetMarker::Mark_ScriptString(scr_string_t& scriptString) const
|
||||
{
|
||||
const auto result = m_visitor.Visit_ScriptString(scriptString);
|
||||
if (result.has_value())
|
||||
scriptString = *result;
|
||||
}
|
||||
|
||||
void AssetMarker::MarkArray_ScriptString(scr_string_t* scriptStringArray, const size_t count) const
|
||||
void BaseAssetMarker::MarkArray_ScriptString(scr_string_t* scriptStringArray, const size_t count) const
|
||||
{
|
||||
assert(scriptStringArray != nullptr);
|
||||
|
||||
@@ -23,12 +23,12 @@ void AssetMarker::MarkArray_ScriptString(scr_string_t* scriptStringArray, const
|
||||
Mark_ScriptString(scriptStringArray[index]);
|
||||
}
|
||||
|
||||
void AssetMarker::Mark_IndirectAssetRef(const asset_type_t assetType, const char* assetName) const
|
||||
void BaseAssetMarker::Mark_IndirectAssetRef(const asset_type_t assetType, const char* assetName) const
|
||||
{
|
||||
m_visitor.Visit_IndirectAssetRef(assetType, assetName);
|
||||
}
|
||||
|
||||
void AssetMarker::MarkArray_IndirectAssetRef(const asset_type_t assetType, const char** assetNames, const size_t count) const
|
||||
void BaseAssetMarker::MarkArray_IndirectAssetRef(const asset_type_t assetType, const char** assetNames, const size_t count) const
|
||||
{
|
||||
assert(assetNames != nullptr);
|
||||
|
||||
45
src/ZoneCommon/Marking/BaseAssetMarker.h
Normal file
45
src/ZoneCommon/Marking/BaseAssetMarker.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IAsset.h"
|
||||
#include "Marking/AssetVisitor.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
class BaseAssetMarker
|
||||
{
|
||||
protected:
|
||||
explicit BaseAssetMarker(AssetVisitor& visitor);
|
||||
|
||||
template<typename AssetType> void Mark_Dependency(std::add_lvalue_reference_t<std::add_pointer_t<typename AssetType::Type>> asset)
|
||||
{
|
||||
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||
|
||||
const auto result = m_visitor.Visit_Dependency(AssetType::EnumEntry, AssetNameAccessor<AssetType>()(*asset));
|
||||
if (result.has_value())
|
||||
asset = static_cast<std::add_pointer_t<typename AssetType::Type>>(result->m_ptr);
|
||||
}
|
||||
|
||||
void Mark_ScriptString(scr_string_t& scriptString) const;
|
||||
void MarkArray_ScriptString(scr_string_t* scriptStringArray, size_t count) const;
|
||||
|
||||
void Mark_IndirectAssetRef(asset_type_t assetType, const char* assetName) const;
|
||||
void MarkArray_IndirectAssetRef(asset_type_t assetType, const char** assetNames, size_t count) const;
|
||||
|
||||
AssetVisitor& m_visitor;
|
||||
};
|
||||
|
||||
template<typename AssetType> struct AssetMarkerWrapper
|
||||
{
|
||||
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||
// using WrapperClass = WrapperClass;
|
||||
};
|
||||
|
||||
template<typename AssetType> using AssetMarker = AssetMarkerWrapper<AssetType>::WrapperClass;
|
||||
|
||||
#define DEFINE_MARKER_CLASS_FOR_ASSET(asset, markerClass) \
|
||||
template<> struct AssetMarkerWrapper<asset> \
|
||||
{ \
|
||||
static_assert(std::is_base_of_v<IAssetBase, asset>); \
|
||||
using WrapperClass = markerClass; \
|
||||
};
|
||||
Reference in New Issue
Block a user