2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2022-06-22 11:36:06 -04:00
|
|
|
#include "ILoadedSound.hpp"
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
namespace Assets
|
|
|
|
{
|
2018-12-17 08:29:18 -05:00
|
|
|
void ILoadedSound::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
|
2017-02-12 15:19:04 -05:00
|
|
|
{
|
2023-02-15 06:58:31 -05:00
|
|
|
header->loadSnd = builder->getIW4OfApi()->read<Game::LoadedSound>(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, name);
|
2017-02-12 15:19:04 -05:00
|
|
|
}
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
void ILoadedSound::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
|
|
|
{
|
|
|
|
AssertSize(Game::LoadedSound, 44);
|
|
|
|
|
2023-02-15 06:58:31 -05:00
|
|
|
auto* buffer = builder->getBuffer();
|
|
|
|
auto* asset = header.loadSnd;
|
|
|
|
auto* dest = buffer->dest<Game::LoadedSound>();
|
2017-01-19 16:23:59 -05:00
|
|
|
buffer->save(asset);
|
|
|
|
|
|
|
|
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
|
|
|
|
|
|
|
if (asset->name)
|
|
|
|
{
|
|
|
|
buffer->saveString(builder->getAssetName(this->getType(), asset->name));
|
|
|
|
Utils::Stream::ClearPointer(&dest->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
buffer->pushBlock(Game::XFILE_BLOCK_TEMP);
|
|
|
|
|
2017-02-12 15:19:04 -05:00
|
|
|
if (asset->sound.data)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2022-12-14 03:40:15 -05:00
|
|
|
buffer->saveArray(asset->sound.data, asset->sound.info.data_len);
|
|
|
|
Utils::Stream::ClearPointer(&dest->sound.data);
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer->popBlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer->popBlock();
|
|
|
|
}
|
|
|
|
}
|