mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-09-09 23:47:07 +00:00
feat: t6 flametables (#845)
* feat: add flametable loading and dumping for T6 * chore: add additional validation logic of game for t6 weapon loading
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "WeaponDumperT6.h"
|
||||
|
||||
#include "Dumping/SubAssetDeduplicationDumperState.h"
|
||||
#include "Game/T6/InfoString/InfoStringFromStructConverter.h"
|
||||
#include "Game/T6/ObjConstantsT6.h"
|
||||
#include "Game/T6/Weapon/FlameTableFields.h"
|
||||
#include "Game/T6/Weapon/WeaponFields.h"
|
||||
#include "Game/T6/Weapon/WeaponStrings.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
@@ -267,6 +269,24 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
class InfoStringFromFlameTableConverter final : public InfoStringFromStructConverter
|
||||
{
|
||||
protected:
|
||||
void FillFromExtensionField(const cspField_t& field) override
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringFromFlameTableConverter(const FlameTable* structure,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount,
|
||||
std::function<std::string(scr_string_t)> scriptStringValueCallback)
|
||||
: InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
GenericGraph2D ConvertAccuracyGraph(const char* graphName, const vec2_t* originalKnots, const unsigned originalKnotCount)
|
||||
{
|
||||
GenericGraph2D graph;
|
||||
@@ -457,6 +477,47 @@ namespace
|
||||
weapDef->originalAiVsPlayerAccuracyGraphKnotCount));
|
||||
}
|
||||
}
|
||||
|
||||
void DumpFlameTable(const AssetDumpingContext& context,
|
||||
SubAssetDeduplicationDumperState<FlameTable>& deduplicator,
|
||||
const char* flameTableName,
|
||||
const FlameTable* flameTable)
|
||||
{
|
||||
if (!flameTable || !flameTableName || flameTableName[0] == '\0')
|
||||
return;
|
||||
|
||||
if (!deduplicator.ShouldDumpSubAsset(flameTable))
|
||||
return;
|
||||
|
||||
const auto assetFile = context.OpenAssetFile(weapon::GetFileNameForFlameTable(flameTableName));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
auto& stream = *assetFile;
|
||||
InfoStringFromFlameTableConverter converter(flameTable,
|
||||
flameTableFields,
|
||||
std::extent_v<decltype(flameTableFields)>,
|
||||
[](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(false);
|
||||
return "";
|
||||
});
|
||||
|
||||
const auto infoString = converter.Convert();
|
||||
|
||||
const auto stringValue = infoString.ToString(INFO_STRING_PREFIX_FLAME_TABLE);
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
}
|
||||
|
||||
void DumpFlameTables(AssetDumpingContext& context, const XAssetInfo<WeaponVariantDef>& asset)
|
||||
{
|
||||
auto* deduplicator = context.GetZoneAssetDumperState<SubAssetDeduplicationDumperState<FlameTable>>();
|
||||
const auto weapon = asset.Asset();
|
||||
|
||||
DumpFlameTable(context, *deduplicator, weapon->weapDef->flameTableFirstPerson, weapon->weapDef->flameTableFirstPersonPtr);
|
||||
DumpFlameTable(context, *deduplicator, weapon->weapDef->flameTableThirdPerson, weapon->weapDef->flameTableThirdPersonPtr);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace weapon
|
||||
@@ -485,5 +546,6 @@ namespace weapon
|
||||
}
|
||||
|
||||
DumpAccuracyGraphs(context, asset);
|
||||
DumpFlameTables(context, asset);
|
||||
}
|
||||
} // namespace weapon
|
||||
|
||||
Reference in New Issue
Block a user