mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Write StructuredDataDef data with additional comments stating debugging details for the format
This commit is contained in:
parent
96ef7a46fb
commit
ec8e58e0f1
@ -53,6 +53,12 @@ void StructuredDataDefDumper::EndVersion()
|
|||||||
m_flags.m_empty_line_before_block = false;
|
m_flags.m_empty_line_before_block = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StructuredDataDefDumper::WriteLineComment(const std::string& comment) const
|
||||||
|
{
|
||||||
|
Indent();
|
||||||
|
m_stream << "// " << comment << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
void StructuredDataDefDumper::BeginEnum(const std::string& enumName, const size_t enumEntryCount, size_t enumReservedEntryCount)
|
void StructuredDataDefDumper::BeginEnum(const std::string& enumName, const size_t enumEntryCount, size_t enumReservedEntryCount)
|
||||||
{
|
{
|
||||||
assert(m_flags.m_in_version);
|
assert(m_flags.m_in_version);
|
||||||
@ -214,6 +220,12 @@ void StructuredDataDefDumper::EndProperty()
|
|||||||
ss << "[" << arraySpecifierName << "]";
|
ss << "[" << arraySpecifierName << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ss << " /* Offset: " << m_current_property_offset / 8;
|
||||||
|
|
||||||
|
if (m_current_property_offset % 8 > 0)
|
||||||
|
ss << " + " << m_current_property_offset % 8 << "bit";
|
||||||
|
|
||||||
|
ss << " */ ";
|
||||||
m_struct_properties.emplace_back(ss.str(), m_current_property_offset);
|
m_struct_properties.emplace_back(ss.str(), m_current_property_offset);
|
||||||
|
|
||||||
m_block = Block::BLOCK_STRUCT;
|
m_block = Block::BLOCK_STRUCT;
|
||||||
|
@ -45,6 +45,8 @@ public:
|
|||||||
void BeginVersion(int version);
|
void BeginVersion(int version);
|
||||||
void EndVersion();
|
void EndVersion();
|
||||||
|
|
||||||
|
void WriteLineComment(const std::string& comment) const;
|
||||||
|
|
||||||
void BeginEnum(const std::string& enumName, size_t enumEntryCount, size_t enumReservedEntryCount);
|
void BeginEnum(const std::string& enumName, size_t enumEntryCount, size_t enumReservedEntryCount);
|
||||||
void EndEnum();
|
void EndEnum();
|
||||||
void WriteEnumEntry(const std::string& entryName, size_t entryValue);
|
void WriteEnumEntry(const std::string& entryName, size_t entryValue);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "Dumping/StructuredDataDef/StructuredDataDefDumper.h"
|
#include "Dumping/StructuredDataDef/StructuredDataDefDumper.h"
|
||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
bool AssetDumperStructuredDataDefSet::GetNextHeadValue(const StructuredDataDef* def, const bool isFirstStruct, const std::vector<bool>& structsIncludedInOrder, size_t& nextHeadValue)
|
bool AssetDumperStructuredDataDefSet::GetNextHeadValue(const StructuredDataDef* def, const bool isFirstStruct, const std::vector<bool>& structsIncludedInOrder, size_t& nextHeadValue)
|
||||||
{
|
{
|
||||||
@ -134,7 +135,7 @@ void AssetDumperStructuredDataDefSet::DumpEnum(StructuredDataDefDumper& dumper,
|
|||||||
|
|
||||||
void AssetDumperStructuredDataDefSet::DumpProperty(StructuredDataDefDumper& dumper, const StructuredDataStructProperty& property, const StructuredDataDef* def, const int rootStructIndex)
|
void AssetDumperStructuredDataDefSet::DumpProperty(StructuredDataDefDumper& dumper, const StructuredDataStructProperty& property, const StructuredDataDef* def, const int rootStructIndex)
|
||||||
{
|
{
|
||||||
dumper.BeginProperty(property.name, property.offset);
|
dumper.BeginProperty(property.name, property.type.type == DATA_BOOL ? property.offset : property.offset * 8);
|
||||||
|
|
||||||
auto currentType = property.type;
|
auto currentType = property.type;
|
||||||
auto stopTypeIteration = false;
|
auto stopTypeIteration = false;
|
||||||
@ -258,6 +259,8 @@ void AssetDumperStructuredDataDefSet::DumpStruct(StructuredDataDefDumper& dumper
|
|||||||
structName = ss.str();
|
structName = ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dumper.WriteLineComment("BitOffset: "s + std::to_string(_struct->bitOffset));
|
||||||
|
dumper.WriteLineComment("Size: "s + std::to_string(_struct->size));
|
||||||
dumper.BeginStruct(structName, static_cast<size_t>(_struct->propertyCount));
|
dumper.BeginStruct(structName, static_cast<size_t>(_struct->propertyCount));
|
||||||
|
|
||||||
for (auto i = 0; i < _struct->propertyCount; i++)
|
for (auto i = 0; i < _struct->propertyCount; i++)
|
||||||
@ -284,6 +287,8 @@ void AssetDumperStructuredDataDefSet::DumpAsset(AssetDumpingContext& context, XA
|
|||||||
{
|
{
|
||||||
const auto& def = set->defs[defIndex];
|
const auto& def = set->defs[defIndex];
|
||||||
|
|
||||||
|
dumper.WriteLineComment("Size: "s + std::to_string(def.size));
|
||||||
|
dumper.WriteLineComment("Checksum: "s + std::to_string(def.formatChecksum));
|
||||||
dumper.BeginVersion(def.version);
|
dumper.BeginVersion(def.version);
|
||||||
|
|
||||||
for (auto enumIndex = 0; enumIndex < def.enumCount; enumIndex++)
|
for (auto enumIndex = 0; enumIndex < def.enumCount; enumIndex++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user