iw4x-client/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp
Louve f409b881e2
IW4OF integration (#772)
Co-authored-by: Louvenarde <louve@louve.systems>
Co-authored-by: Roxanne <roxanne@thegamebakers.com>
Co-authored-by: FutureRave <edoardo.sanguineti222@gmail.com>
2023-02-15 11:58:31 +00:00

43 lines
1.0 KiB
C++

#include <STDInclude.hpp>
#include "ILoadedSound.hpp"
namespace Assets
{
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);
}
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>();
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)
{
buffer->saveArray(asset->sound.data, asset->sound.info.data_len);
Utils::Stream::ClearPointer(&dest->sound.data);
}
buffer->popBlock();
}
buffer->popBlock();
}
}