2017-01-20 08:36:52 -05:00
|
|
|
#include "STDInclude.hpp"
|
2016-03-04 11:02:00 -05:00
|
|
|
|
|
|
|
namespace Assets
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
void IStructuredDataDefSet::saveStructuredDataEnumArray(Game::StructuredDataEnum* enums, int numEnums, Components::ZoneBuilder::Zone* builder)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StructuredDataEnum* destEnums = buffer->dest<Game::StructuredDataEnum>();
|
|
|
|
buffer->saveArray(enums, numEnums);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < numEnums; ++i)
|
|
|
|
{
|
|
|
|
Game::StructuredDataEnum* destEnum = &destEnums[i];
|
|
|
|
Game::StructuredDataEnum* enum_ = &enums[i];
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
if (enum_->entries)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataEnumEntry, 8);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StructuredDataEnumEntry* destIndices = buffer->dest<Game::StructuredDataEnumEntry>();
|
2017-02-20 13:18:07 -05:00
|
|
|
buffer->saveArray(enum_->entries, enum_->entryCount);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
for (int j = 0; j < enum_->entryCount; ++j)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
|
|
|
Game::StructuredDataEnumEntry* destIndex = &destIndices[j];
|
2017-02-20 13:18:07 -05:00
|
|
|
Game::StructuredDataEnumEntry* index = &enum_->entries[j];
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2018-05-09 08:33:52 -04:00
|
|
|
if (index->string)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
buffer->saveString(index->string);
|
|
|
|
Utils::Stream::ClearPointer(&destIndex->string);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
Utils::Stream::ClearPointer(&destEnum->entries);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
void IStructuredDataDefSet::saveStructuredDataStructArray(Game::StructuredDataStruct* structs, int numStructs, Components::ZoneBuilder::Zone* builder)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StructuredDataStruct* destStructs = buffer->dest<Game::StructuredDataStruct>();
|
|
|
|
buffer->saveArray(structs, numStructs);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < numStructs; ++i)
|
|
|
|
{
|
|
|
|
Game::StructuredDataStruct* destStruct = &destStructs[i];
|
|
|
|
Game::StructuredDataStruct* struct_ = &structs[i];
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
if (struct_->properties)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataStructProperty, 16);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StructuredDataStructProperty* destProperties = buffer->dest<Game::StructuredDataStructProperty>();
|
2017-02-20 13:18:07 -05:00
|
|
|
buffer->saveArray(struct_->properties, struct_->propertyCount);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
for (int j = 0; j < struct_->propertyCount; ++j)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
|
|
|
Game::StructuredDataStructProperty* destProperty = &destProperties[j];
|
2017-02-20 13:18:07 -05:00
|
|
|
Game::StructuredDataStructProperty* property = &struct_->properties[j];
|
2016-03-04 11:02:00 -05:00
|
|
|
|
|
|
|
if (property->name)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->saveString(property->name);
|
2016-06-10 07:52:55 -04:00
|
|
|
Utils::Stream::ClearPointer(&destProperty->name);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
Utils::Stream::ClearPointer(&destStruct->properties);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
void IStructuredDataDefSet::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataDefSet, 12);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2018-05-09 08:33:52 -04:00
|
|
|
Game::StructuredDataDefSet* asset = header.structuredDataDefSet;
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StructuredDataDefSet* dest = buffer->dest<Game::StructuredDataDefSet>();
|
|
|
|
buffer->save(asset);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
|
|
|
if (asset->name)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
|
2016-06-10 07:52:55 -04:00
|
|
|
Utils::Stream::ClearPointer(&dest->name);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
if (asset->defs)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataDef, 52);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StructuredDataDef* destDataArray = buffer->dest<Game::StructuredDataDef>();
|
2017-02-20 13:18:07 -05:00
|
|
|
buffer->saveArray(asset->defs, asset->defCount);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
for (unsigned int i = 0; i < asset->defCount; ++i)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
|
|
|
Game::StructuredDataDef* destData = &destDataArray[i];
|
2017-02-20 13:18:07 -05:00
|
|
|
Game::StructuredDataDef* data = &asset->defs[i];
|
2016-03-04 11:02:00 -05:00
|
|
|
|
|
|
|
if (data->enums)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataEnum, 12);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
this->saveStructuredDataEnumArray(data->enums, data->enumCount, builder);
|
2016-06-10 07:52:55 -04:00
|
|
|
Utils::Stream::ClearPointer(&destData->enums);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data->structs)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataStruct, 16);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
this->saveStructuredDataStructArray(data->structs, data->structCount, builder);
|
2016-06-10 07:52:55 -04:00
|
|
|
Utils::Stream::ClearPointer(&destData->structs);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data->indexedArrays)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataIndexedArray, 16);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
buffer->saveArray(data->indexedArrays, data->indexedArrayCount);
|
2016-06-10 07:52:55 -04:00
|
|
|
Utils::Stream::ClearPointer(&destData->indexedArrays);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
if (data->enumedArrays)
|
2016-03-04 11:02:00 -05:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StructuredDataEnumedArray, 16);
|
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-03-04 11:02:00 -05:00
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
buffer->saveArray(data->enumedArrays, data->enumedArrayCount);
|
|
|
|
Utils::Stream::ClearPointer(&destData->enumedArrays);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 13:18:07 -05:00
|
|
|
Utils::Stream::ClearPointer(&dest->defs);
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->popBlock();
|
2016-03-04 11:02:00 -05:00
|
|
|
}
|
|
|
|
}
|