mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-26 06:11:53 +00:00
refactor: use zone reference in AssetLoader
This commit is contained in:
@ -32,8 +32,9 @@
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
ContentLoader::ContentLoader()
|
||||
: varXAsset(nullptr),
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
@ -54,12 +55,12 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
if (varScriptStringList->strings && varScriptStringList->count > 0)
|
||||
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
|
||||
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
@ -133,9 +134,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
|
||||
void ContentLoader::Load(IZoneInputStream* stream)
|
||||
{
|
||||
m_zone = zone;
|
||||
m_stream = stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
@ -7,17 +8,18 @@ namespace IW3
|
||||
{
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
} // namespace IW3
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
Actions_GfxImage::Actions_GfxImage(Zone* zone)
|
||||
Actions_GfxImage::Actions_GfxImage(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
||||
{
|
||||
const size_t loadDefSize = offsetof(IW3::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->AllocRaw(loadDefSize));
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace IW3
|
||||
class Actions_GfxImage final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_GfxImage(Zone* zone);
|
||||
explicit Actions_GfxImage(Zone& zone);
|
||||
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone* zone)
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -14,7 +14,7 @@ void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
||||
if (sound->info.data_len > 0)
|
||||
{
|
||||
const auto* tempData = sound->data;
|
||||
sound->data = m_zone->GetMemory()->Alloc<char>(sound->info.data_len);
|
||||
sound->data = m_zone.GetMemory()->Alloc<char>(sound->info.data_len);
|
||||
memcpy(sound->data, tempData, sound->info.data_len);
|
||||
}
|
||||
else
|
||||
|
@ -8,7 +8,7 @@ namespace IW3
|
||||
class Actions_LoadedSound final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_LoadedSound(Zone* zone);
|
||||
explicit Actions_LoadedSound(Zone& zone);
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
|
@ -85,8 +85,8 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(
|
||||
std::make_unique<ContentLoader>(*zonePtr), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -42,8 +42,9 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
ContentLoader::ContentLoader()
|
||||
: varXAsset(nullptr),
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
@ -64,12 +65,12 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
if (varScriptStringList->strings && varScriptStringList->count > 0)
|
||||
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
|
||||
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
@ -153,9 +154,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
|
||||
void ContentLoader::Load(IZoneInputStream* stream)
|
||||
{
|
||||
m_zone = zone;
|
||||
m_stream = stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
@ -9,9 +9,9 @@ namespace IW4
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
public:
|
||||
ContentLoader();
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
void Load(IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
Actions_GfxImage::Actions_GfxImage(Zone* zone)
|
||||
Actions_GfxImage::Actions_GfxImage(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
||||
{
|
||||
const size_t loadDefSize = offsetof(IW4::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->AllocRaw(loadDefSize));
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace IW4
|
||||
class Actions_GfxImage final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_GfxImage(Zone* zone);
|
||||
explicit Actions_GfxImage(Zone& zone);
|
||||
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone* zone)
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -14,7 +14,7 @@ void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
||||
if (sound->info.data_len > 0)
|
||||
{
|
||||
const auto* tempData = sound->data;
|
||||
sound->data = m_zone->GetMemory()->Alloc<char>(sound->info.data_len);
|
||||
sound->data = m_zone.GetMemory()->Alloc<char>(sound->info.data_len);
|
||||
memcpy(sound->data, tempData, sound->info.data_len);
|
||||
}
|
||||
else
|
||||
|
@ -8,7 +8,7 @@ namespace IW4
|
||||
class Actions_LoadedSound final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_LoadedSound(Zone* zone);
|
||||
explicit Actions_LoadedSound(Zone& zone);
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
Actions_XModel::Actions_XModel(Zone* zone)
|
||||
Actions_XModel::Actions_XModel(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -13,7 +13,7 @@ void Actions_XModel::SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSur
|
||||
{
|
||||
if (modelSurfs)
|
||||
{
|
||||
lodInfo->modelSurfs = m_zone->GetMemory()->Alloc<XModelSurfs>();
|
||||
lodInfo->modelSurfs = m_zone.GetMemory()->Alloc<XModelSurfs>();
|
||||
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace IW4
|
||||
class Actions_XModel final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_XModel(Zone* zone);
|
||||
explicit Actions_XModel(Zone& zone);
|
||||
|
||||
void SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSurfs) const;
|
||||
};
|
||||
|
@ -207,8 +207,8 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(
|
||||
std::make_unique<ContentLoader>(*zonePtr), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -47,8 +47,9 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
ContentLoader::ContentLoader()
|
||||
: varXAsset(nullptr),
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
@ -69,12 +70,12 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
if (varScriptStringList->strings && varScriptStringList->count > 0)
|
||||
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
|
||||
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
@ -162,9 +163,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
|
||||
void ContentLoader::Load(IZoneInputStream* stream)
|
||||
{
|
||||
m_zone = zone;
|
||||
m_stream = stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
@ -7,17 +8,18 @@ namespace IW5
|
||||
{
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
} // namespace IW5
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
Actions_clipMap_t::Actions_clipMap_t(Zone* zone)
|
||||
Actions_clipMap_t::Actions_clipMap_t(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
|
||||
void Actions_clipMap_t::ReallocClipInfo(const ClipInfo* clipInfo, clipMap_t* clipMap) const
|
||||
{
|
||||
clipMap->pInfo = m_zone->GetMemory()->Alloc<ClipInfo>();
|
||||
clipMap->pInfo = m_zone.GetMemory()->Alloc<ClipInfo>();
|
||||
memcpy(clipMap->pInfo, clipInfo, sizeof(ClipInfo));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace IW5
|
||||
class Actions_clipMap_t final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_clipMap_t(Zone* zone);
|
||||
explicit Actions_clipMap_t(Zone& zone);
|
||||
|
||||
void ReallocClipInfo(const ClipInfo* clipInfo, clipMap_t* clipMap) const;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
Actions_GfxImage::Actions_GfxImage(Zone* zone)
|
||||
Actions_GfxImage::Actions_GfxImage(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
||||
{
|
||||
const size_t loadDefSize = offsetof(IW5::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->AllocRaw(loadDefSize));
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace IW5
|
||||
class Actions_GfxImage final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_GfxImage(Zone* zone);
|
||||
explicit Actions_GfxImage(Zone& zone);
|
||||
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone* zone)
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -14,7 +14,7 @@ void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
||||
if (sound->info.data_len > 0)
|
||||
{
|
||||
char* tempData = sound->data;
|
||||
sound->data = m_zone->GetMemory()->Alloc<char>(sound->info.data_len);
|
||||
sound->data = m_zone.GetMemory()->Alloc<char>(sound->info.data_len);
|
||||
memcpy(sound->data, tempData, sound->info.data_len);
|
||||
}
|
||||
else
|
||||
|
@ -8,7 +8,7 @@ namespace IW5
|
||||
class Actions_LoadedSound final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_LoadedSound(Zone* zone);
|
||||
explicit Actions_LoadedSound(Zone& zone);
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
Actions_XModel::Actions_XModel(Zone* zone)
|
||||
Actions_XModel::Actions_XModel(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -13,7 +13,7 @@ void Actions_XModel::SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSur
|
||||
{
|
||||
if (modelSurfs)
|
||||
{
|
||||
lodInfo->modelSurfs = m_zone->GetMemory()->Alloc<XModelSurfs>();
|
||||
lodInfo->modelSurfs = m_zone.GetMemory()->Alloc<XModelSurfs>();
|
||||
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace IW5
|
||||
class Actions_XModel final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_XModel(Zone* zone);
|
||||
explicit Actions_XModel(Zone& zone);
|
||||
|
||||
void SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSurfs) const;
|
||||
};
|
||||
|
@ -184,8 +184,8 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(
|
||||
std::make_unique<ContentLoader>(*zonePtr), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -39,8 +39,9 @@
|
||||
|
||||
using namespace T5;
|
||||
|
||||
ContentLoader::ContentLoader()
|
||||
: varXAsset(nullptr),
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
@ -61,12 +62,12 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
if (varScriptStringList->strings && varScriptStringList->count > 0)
|
||||
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
|
||||
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
@ -146,9 +147,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
|
||||
void ContentLoader::Load(IZoneInputStream* stream)
|
||||
{
|
||||
m_zone = zone;
|
||||
m_stream = stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T5/T5.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
@ -7,17 +8,18 @@ namespace T5
|
||||
{
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
} // namespace T5
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using namespace T5;
|
||||
|
||||
Actions_GfxImage::Actions_GfxImage(Zone* zone)
|
||||
Actions_GfxImage::Actions_GfxImage(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
||||
{
|
||||
const size_t loadDefSize = offsetof(GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->AllocRaw(loadDefSize));
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace T5
|
||||
class Actions_GfxImage final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_GfxImage(Zone* zone);
|
||||
explicit Actions_GfxImage(Zone& zone);
|
||||
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
|
@ -85,8 +85,8 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(
|
||||
std::make_unique<ContentLoader>(*zonePtr), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
return zoneLoader;
|
||||
}
|
||||
|
@ -55,8 +55,9 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
ContentLoader::ContentLoader()
|
||||
: varXAsset(nullptr),
|
||||
ContentLoader::ContentLoader(Zone& zone)
|
||||
: ContentLoaderBase(zone),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
@ -77,12 +78,12 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
if (varScriptStringList->strings && varScriptStringList->count > 0)
|
||||
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
m_stream->PopBlock();
|
||||
|
||||
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
@ -175,9 +176,8 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
|
||||
void ContentLoader::Load(IZoneInputStream* stream)
|
||||
{
|
||||
m_zone = zone;
|
||||
m_stream = stream;
|
||||
|
||||
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
@ -7,17 +8,18 @@ namespace T6
|
||||
{
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
public:
|
||||
explicit ContentLoader(Zone& zone);
|
||||
|
||||
void Load(IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
} // namespace T6
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
Actions_GfxImage::Actions_GfxImage(Zone* zone)
|
||||
Actions_GfxImage::Actions_GfxImage(Zone& zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
@ -19,6 +19,6 @@ void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image)
|
||||
{
|
||||
const size_t loadDefSize = offsetof(T6::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->AllocRaw(loadDefSize));
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone.GetMemory()->AllocRaw(loadDefSize));
|
||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace T6
|
||||
class Actions_GfxImage final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_GfxImage(Zone* zone);
|
||||
explicit Actions_GfxImage(Zone& zone);
|
||||
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
|
@ -203,8 +203,8 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(
|
||||
std::make_unique<ContentLoader>(*zonePtr), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
if (isSecure)
|
||||
{
|
||||
|
Reference in New Issue
Block a user