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

43 lines
1.0 KiB
C++
Raw Normal View History

2022-02-27 07:53:44 -05:00
#include <STDInclude.hpp>
#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)
{
header->loadSnd = builder->getIW4OfApi()->read<Game::LoadedSound>(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, name);
}
2017-01-19 16:23:59 -05:00
void ILoadedSound::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
AssertSize(Game::LoadedSound, 44);
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);
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();
}
}