2017-01-20 08:36:52 -05:00
|
|
|
#include "STDInclude.hpp"
|
2016-08-16 07:58:45 -04:00
|
|
|
|
|
|
|
namespace Assets
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
void IStringTable::saveStringTableCellArray(Components::ZoneBuilder::Zone* builder, Game::StringTableCell* values, int count)
|
2016-08-16 07:58:45 -04:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StringTableCell, 8);
|
2016-08-16 07:58:45 -04:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2016-08-16 07:58:45 -04:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StringTableCell* destValues = buffer->dest<Game::StringTableCell>();
|
|
|
|
buffer->saveArray(destValues, count);
|
2016-08-16 07:58:45 -04:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
Game::StringTableCell* destValue = &destValues[i];
|
|
|
|
Game::StringTableCell* value = &values[i];
|
|
|
|
|
|
|
|
buffer->saveString(value->string);
|
|
|
|
Utils::Stream::ClearPointer(&destValue->string);
|
2016-08-16 07:58:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
void IStringTable::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
2016-08-16 07:58:45 -04:00
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
AssertSize(Game::StringTable, 16);
|
2016-08-16 07:58:45 -04:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
Utils::Stream* buffer = builder->getBuffer();
|
2016-08-16 07:58:45 -04:00
|
|
|
Game::StringTable* asset = header.stringTable;
|
2016-11-20 08:09:07 -05:00
|
|
|
Game::StringTable* dest = buffer->dest<Game::StringTable>();
|
|
|
|
buffer->save(asset, sizeof(Game::StringTable));
|
2016-08-16 07:58:45 -04:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
2016-08-16 07:58:45 -04:00
|
|
|
|
|
|
|
if (asset->name)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
|
2016-08-16 07:58:45 -04:00
|
|
|
Utils::Stream::ClearPointer(&dest->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asset->values)
|
|
|
|
{
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->align(Utils::Stream::ALIGN_4);
|
2016-08-16 07:58:45 -04:00
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
this->saveStringTableCellArray(builder, asset->values, asset->columnCount * asset->rowCount);
|
2016-08-16 07:58:45 -04:00
|
|
|
Utils::Stream::ClearPointer(&dest->values);
|
|
|
|
}
|
|
|
|
|
2016-11-20 08:09:07 -05:00
|
|
|
buffer->popBlock();
|
2016-08-16 07:58:45 -04:00
|
|
|
}
|
|
|
|
}
|