[ZoneBuilder] Add LoadedSound interface

This commit is contained in:
momo5502 2016-11-29 19:32:46 +01:00
parent 1b12886229
commit 3551d0c0eb
6 changed files with 75 additions and 2 deletions

View File

@ -393,6 +393,7 @@ namespace Components
AssetHandler::RegisterInterface(new Assets::IPhysPreset()); AssetHandler::RegisterInterface(new Assets::IPhysPreset());
AssetHandler::RegisterInterface(new Assets::IXAnimParts()); AssetHandler::RegisterInterface(new Assets::IXAnimParts());
AssetHandler::RegisterInterface(new Assets::IFxEffectDef()); AssetHandler::RegisterInterface(new Assets::IFxEffectDef());
AssetHandler::RegisterInterface(new Assets::ILoadedSound());
AssetHandler::RegisterInterface(new Assets::IPhysCollmap()); AssetHandler::RegisterInterface(new Assets::IPhysCollmap());
AssetHandler::RegisterInterface(new Assets::IStringTable()); AssetHandler::RegisterInterface(new Assets::IStringTable());
//AssetHandler::RegisterInterface(new Assets::IXModelSurfs()); //AssetHandler::RegisterInterface(new Assets::IXModelSurfs());

View File

@ -77,6 +77,7 @@ namespace Components
#include "AssetInterfaces\IPhysPreset.hpp" #include "AssetInterfaces\IPhysPreset.hpp"
#include "AssetInterfaces\IXAnimParts.hpp" #include "AssetInterfaces\IXAnimParts.hpp"
#include "AssetInterfaces\IFxEffectDef.hpp" #include "AssetInterfaces\IFxEffectDef.hpp"
#include "AssetInterfaces\ILoadedSound.hpp"
#include "AssetInterfaces\IPhysCollmap.hpp" #include "AssetInterfaces\IPhysCollmap.hpp"
#include "AssetInterfaces\IStringTable.hpp" #include "AssetInterfaces\IStringTable.hpp"
#include "AssetInterfaces\IXModelSurfs.hpp" #include "AssetInterfaces\IXModelSurfs.hpp"

View File

@ -0,0 +1,45 @@
#include <STDInclude.hpp>
namespace Assets
{
void ILoadedSound::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
AssertSize(Game::LoadedSound, 44);
Utils::Stream* buffer = builder->getBuffer();
Game::LoadedSound* asset = header.sound;
Game::LoadedSound* 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->mssSound.data)
{
if (builder->hasPointer(asset->mssSound.data))
{
dest->mssSound.data = builder->getPointer(asset->mssSound.data);
}
else
{
builder->storePointer(asset->mssSound.data);
buffer->saveArray(asset->mssSound.data, asset->mssSound.size);
Utils::Stream::ClearPointer(&dest->mssSound.data);
}
}
buffer->popBlock();
}
buffer->popBlock();
}
}

View File

@ -0,0 +1,10 @@
namespace Assets
{
class ILoadedSound : public Components::AssetHandler::IAsset
{
public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOADED_SOUND; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
};
}

View File

@ -514,6 +514,9 @@ namespace Components
// Don't create default assets // Don't create default assets
Utils::Hook::Set<BYTE>(0x407BAA, 0xEB); Utils::Hook::Set<BYTE>(0x407BAA, 0xEB);
// Don't load sounds
Utils::Hook::Set<BYTE>(0x334D41, 0xC3);
// Don't display errors when assets are missing (we might manually build those) // Don't display errors when assets are missing (we might manually build those)
Utils::Hook::Nop(0x5BB3F2, 5); Utils::Hook::Nop(0x5BB3F2, 5);
Utils::Hook::Nop(0x5BB422, 5); Utils::Hook::Nop(0x5BB422, 5);

View File

@ -1215,14 +1215,26 @@ namespace Game
char * compressedData; char * compressedData;
}; };
#pragma pack(push, 4)
struct SndCurve struct SndCurve
{ {
const char *filename; const char *filename;
unsigned __int16 knotCount; unsigned __int16 knotCount;
vec2_t knots[16]; vec2_t knots[16];
}; };
#pragma pack(pop)
struct MssSound
{
char unknown1[8];
int size;
char unknown2[22];
char *data; // size = soundSize
};
struct LoadedSound
{
const char *name;
MssSound mssSound;
};
struct FontEntry struct FontEntry
{ {
@ -2898,6 +2910,7 @@ namespace Game
VehicleDef* vehicle; VehicleDef* vehicle;
GfxWorld* gfxMap; GfxWorld* gfxMap;
SndCurve* sndCurve; SndCurve* sndCurve;
LoadedSound* sound;
}; };
struct XAsset struct XAsset