iw4x-client/src/Components/Modules/AssetInterfaces/IStringTable.cpp

52 lines
1.4 KiB
C++
Raw Normal View History

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