Finish iw3 zone code generation

This commit is contained in:
Jan
2021-04-14 18:39:54 +02:00
parent adae75a7a6
commit 6b72ac080f
20 changed files with 542 additions and 76 deletions

View File

@ -0,0 +1,31 @@
#include "gfximage_actions.h"
#include <cassert>
#include <cstring>
using namespace IW3;
Actions_GfxImage::Actions_GfxImage(Zone* zone)
: AssetLoadingActions(zone)
{
}
void Actions_GfxImage::OnImageLoaded(GfxImage* image) const
{
image->cardMemory.platform[0] = 0;
}
void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const
{
if (loadDef->resourceSize > 0)
{
const size_t loadDefSize = offsetof(IW3::GfxImageLoadDef, data) + loadDef->resourceSize;
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->Alloc(loadDefSize));
memcpy(image->texture.loadDef, loadDef, loadDefSize);
}
else
{
image->texture.loadDef = nullptr;
}
}

View File

@ -0,0 +1,16 @@
#pragma once
#include "Loading/AssetLoadingActions.h"
#include "Game/IW3/IW3.h"
namespace IW3
{
class Actions_GfxImage final : public AssetLoadingActions
{
public:
explicit Actions_GfxImage(Zone* zone);
void OnImageLoaded(GfxImage* image) const;
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
};
}

View File

@ -0,0 +1,24 @@
#include "loadedsound_actions.h"
#include <cstring>
using namespace IW3;
Actions_LoadedSound::Actions_LoadedSound(Zone* zone)
: AssetLoadingActions(zone)
{
}
void Actions_LoadedSound::SetSoundData(MssSound* sound) const
{
if (sound->info.data_len > 0)
{
char* tempData = sound->data;
sound->data = static_cast<char*>(m_zone->GetMemory()->Alloc(sound->info.data_len));
memcpy(sound->data, tempData, sound->info.data_len);
}
else
{
sound->data = nullptr;
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "Loading/AssetLoadingActions.h"
#include "Game/IW3/IW3.h"
namespace IW3
{
class Actions_LoadedSound final : public AssetLoadingActions
{
public:
explicit Actions_LoadedSound(Zone* zone);
void SetSoundData(MssSound* sound) const;
};
}