mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
Reformat code with clang format
This commit is contained in:
@ -1,9 +1,6 @@
|
||||
#include "ContentLoaderIW3.h"
|
||||
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/IW3/XAssets/clipmap_t/clipmap_t_load_db.h"
|
||||
#include "Game/IW3/XAssets/comworld/comworld_load_db.h"
|
||||
#include "Game/IW3/XAssets/font_s/font_s_load_db.h"
|
||||
@ -29,6 +26,9 @@
|
||||
#include "Game/IW3/XAssets/weapondef/weapondef_load_db.h"
|
||||
#include "Game/IW3/XAssets/xanimparts/xanimparts_load_db.h"
|
||||
#include "Game/IW3/XAssets/xmodel/xmodel_load_db.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
@ -64,15 +64,15 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
{
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
break;
|
||||
|
||||
assert(varXAsset != nullptr);
|
||||
@ -82,38 +82,38 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
|
||||
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponDef, weapon)
|
||||
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
|
||||
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponDef, weapon)
|
||||
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
|
||||
default:
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOAD_ASSET
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
@ -20,4 +20,4 @@ namespace IW3
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace IW3
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
@ -12,4 +12,4 @@ namespace IW3
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,23 +1,22 @@
|
||||
#include "ZoneLoaderFactoryIW3.h"
|
||||
|
||||
#include "ContentLoaderIW3.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Game/IW3/ZoneConstantsIW3.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Game/IW3/IW3.h"
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ContentLoaderIW3.h"
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/IW3/ZoneConstantsIW3.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
class ZoneLoaderFactory::Impl
|
||||
@ -93,7 +92,8 @@ public:
|
||||
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, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
// Return the fully setup zoneloader
|
||||
return zoneLoader;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/IZoneLoaderFactory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace IW3
|
||||
@ -12,4 +13,4 @@ namespace IW3
|
||||
public:
|
||||
ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,9 +1,6 @@
|
||||
#include "ContentLoaderIW4.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/IW4/XAssets/addonmapents/addonmapents_load_db.h"
|
||||
#include "Game/IW4/XAssets/clipmap_t/clipmap_t_load_db.h"
|
||||
#include "Game/IW4/XAssets/comworld/comworld_load_db.h"
|
||||
@ -39,6 +36,9 @@
|
||||
#include "Game/IW4/XAssets/weaponcompletedef/weaponcompletedef_load_db.h"
|
||||
#include "Game/IW4/XAssets/xanimparts/xanimparts_load_db.h"
|
||||
#include "Game/IW4/XAssets/xmodel/xmodel_load_db.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
@ -74,15 +74,15 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
{
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
break;
|
||||
|
||||
assert(varXAsset != nullptr);
|
||||
@ -92,48 +92,48 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
|
||||
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon)
|
||||
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef)
|
||||
LOAD_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet)
|
||||
LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLE, VehicleDef, vehDef)
|
||||
LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
|
||||
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon)
|
||||
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef)
|
||||
LOAD_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet)
|
||||
LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLE, VehicleDef, vehDef)
|
||||
LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts)
|
||||
|
||||
default:
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOAD_ASSET
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
@ -20,4 +20,4 @@ namespace IW4
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace IW4
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
@ -12,4 +12,4 @@ namespace IW4
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -11,7 +11,7 @@ Actions_XModel::Actions_XModel(Zone* zone)
|
||||
|
||||
void Actions_XModel::SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSurfs) const
|
||||
{
|
||||
if(modelSurfs)
|
||||
if (modelSurfs)
|
||||
{
|
||||
lodInfo->modelSurfs = m_zone->GetMemory()->Create<XModelSurfs>();
|
||||
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
@ -12,4 +12,4 @@ namespace IW4
|
||||
|
||||
void SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSurfs) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,33 +1,32 @@
|
||||
#include "ZoneLoaderFactoryIW4.h"
|
||||
|
||||
#include "ContentLoaderIW4.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/ZoneConstantsIW4.h"
|
||||
#include "Loading/Processor/ProcessorAuthedBlocks.h"
|
||||
#include "Loading/Processor/ProcessorCaptureData.h"
|
||||
#include "Loading/Processor/ProcessorIW4xDecryption.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadHash.h"
|
||||
#include "Loading/Steps/StepLoadSignature.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepRemoveProcessor.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepVerifyFileName.h"
|
||||
#include "Loading/Steps/StepVerifyHash.h"
|
||||
#include "Loading/Steps/StepVerifyMagic.h"
|
||||
#include "Loading/Steps/StepVerifySignature.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ContentLoaderIW4.h"
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/IW4/ZoneConstantsIW4.h"
|
||||
#include "Loading/Processor/ProcessorAuthedBlocks.h"
|
||||
#include "Loading/Processor/ProcessorCaptureData.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Processor/ProcessorIW4xDecryption.h"
|
||||
#include "Loading/Steps/StepVerifyMagic.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepVerifyFileName.h"
|
||||
#include "Loading/Steps/StepLoadSignature.h"
|
||||
#include "Loading/Steps/StepVerifySignature.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepLoadHash.h"
|
||||
#include "Loading/Steps/StepRemoveProcessor.h"
|
||||
#include "Loading/Steps/StepVerifyHash.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
class ZoneLoaderFactory::Impl
|
||||
@ -50,7 +49,7 @@ class ZoneLoaderFactory::Impl
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_IW4X, std::char_traits<char>::length(ZoneConstants::MAGIC_IW4X)))
|
||||
{
|
||||
if(*reinterpret_cast<uint32_t*>(&header.m_magic[std::char_traits<char>::length(ZoneConstants::MAGIC_IW4X)]) == ZoneConstants::IW4X_ZONE_VERSION)
|
||||
if (*reinterpret_cast<uint32_t*>(&header.m_magic[std::char_traits<char>::length(ZoneConstants::MAGIC_IW4X)]) == ZoneConstants::IW4X_ZONE_VERSION)
|
||||
{
|
||||
*isSecure = false;
|
||||
*isOfficial = false;
|
||||
@ -100,8 +99,7 @@ class ZoneLoaderFactory::Impl
|
||||
{
|
||||
if (isOfficial)
|
||||
{
|
||||
auto rsa = Crypto::CreateRSA(IPublicKeyAlgorithm::HashingAlgorithm::RSA_HASH_SHA256,
|
||||
Crypto::RSAPaddingMode::RSA_PADDING_PSS);
|
||||
auto rsa = Crypto::CreateRSA(IPublicKeyAlgorithm::HashingAlgorithm::RSA_HASH_SHA256, Crypto::RSAPaddingMode::RSA_PADDING_PSS);
|
||||
|
||||
if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD)))
|
||||
{
|
||||
@ -120,8 +118,7 @@ class ZoneLoaderFactory::Impl
|
||||
}
|
||||
}
|
||||
|
||||
static void AddAuthHeaderSteps(const bool isSecure, const bool isOfficial, ZoneLoader* zoneLoader,
|
||||
std::string& fileName)
|
||||
static void AddAuthHeaderSteps(const bool isSecure, const bool isOfficial, ZoneLoader* zoneLoader, std::string& fileName)
|
||||
{
|
||||
// Unsigned zones do not have an auth header
|
||||
if (!isSecure)
|
||||
@ -154,15 +151,19 @@ class ZoneLoaderFactory::Impl
|
||||
auto* masterBlockHashesPtr = masterBlockHashes.get();
|
||||
zoneLoader->AddLoadingStep(std::move(masterBlockHashes));
|
||||
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepVerifyHash>(std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), 0, subHeaderHashPtr, subHeaderCapturePtr));
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepVerifyHash>(std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), 0, subHeaderHashPtr, subHeaderCapturePtr));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepRemoveProcessor>(subHeaderCapturePtr));
|
||||
|
||||
// Skip the rest of the first chunk
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepSkipBytes>(ZoneConstants::AUTHED_CHUNK_SIZE - sizeof(DB_AuthHeader)));
|
||||
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorAuthedBlocks>(
|
||||
ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP, ZoneConstants::AUTHED_CHUNK_SIZE, std::extent<decltype(DB_AuthSubHeader::masterBlockHashes)>::value,
|
||||
std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), masterBlockHashesPtr)));
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepAddProcessor>(std::make_unique<ProcessorAuthedBlocks>(ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP,
|
||||
ZoneConstants::AUTHED_CHUNK_SIZE,
|
||||
std::extent<decltype(DB_AuthSubHeader::masterBlockHashes)>::value,
|
||||
std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()),
|
||||
masterBlockHashesPtr)));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -210,7 +211,8 @@ public:
|
||||
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, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
// Return the fully setup zoneloader
|
||||
return zoneLoader;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/IZoneLoaderFactory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace IW4
|
||||
@ -12,4 +13,4 @@ namespace IW4
|
||||
public:
|
||||
ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,9 +1,6 @@
|
||||
#include "ContentLoaderIW5.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/IW5/XAssets/addonmapents/addonmapents_load_db.h"
|
||||
#include "Game/IW5/XAssets/clipmap_t/clipmap_t_load_db.h"
|
||||
#include "Game/IW5/XAssets/comworld/comworld_load_db.h"
|
||||
@ -44,6 +41,9 @@
|
||||
#include "Game/IW5/XAssets/xanimparts/xanimparts_load_db.h"
|
||||
#include "Game/IW5/XAssets/xmodel/xmodel_load_db.h"
|
||||
#include "Game/IW5/XAssets/xmodelsurfs/xmodelsurfs_load_db.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
@ -79,15 +79,15 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
{
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index) \
|
||||
case type_index: \
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index) \
|
||||
case type_index: \
|
||||
break;
|
||||
|
||||
assert(varXAsset != nullptr);
|
||||
@ -97,52 +97,52 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL_SURFS, XModelSurfs, modelSurfs)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
|
||||
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GLASSWORLD, GlassWorld, glassWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_PATHDATA, PathData, pathData)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLE_TRACK, VehicleTrack, vehicleTrack)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_ATTACHMENT, WeaponAttachment, attachment)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon)
|
||||
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_SURFACE_FX, SurfaceFxTable, surfaceFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_SCRIPTFILE, ScriptFile, scriptfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef)
|
||||
LOAD_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet)
|
||||
LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLE, VehicleDef, vehDef)
|
||||
LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL_SURFS, XModelSurfs, modelSurfs)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader)
|
||||
LOAD_ASSET(ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
|
||||
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GLASSWORLD, GlassWorld, glassWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_PATHDATA, PathData, pathData)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLE_TRACK, VehicleTrack, vehicleTrack)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_ATTACHMENT, WeaponAttachment, attachment)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon)
|
||||
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_SURFACE_FX, SurfaceFxTable, surfaceFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_SCRIPTFILE, ScriptFile, scriptfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef)
|
||||
LOAD_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet)
|
||||
LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLE, VehicleDef, vehDef)
|
||||
LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts)
|
||||
|
||||
default:
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOAD_ASSET
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
@ -20,4 +20,4 @@ namespace IW5
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW5
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace IW5
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW5
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
@ -12,4 +12,4 @@ namespace IW5
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW5
|
||||
|
@ -11,7 +11,7 @@ Actions_XModel::Actions_XModel(Zone* zone)
|
||||
|
||||
void Actions_XModel::SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSurfs) const
|
||||
{
|
||||
if(modelSurfs)
|
||||
if (modelSurfs)
|
||||
{
|
||||
lodInfo->modelSurfs = m_zone->GetMemory()->Create<XModelSurfs>();
|
||||
memcpy(lodInfo->modelSurfs, modelSurfs, sizeof(XModelSurfs));
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
@ -12,4 +12,4 @@ namespace IW5
|
||||
|
||||
void SetModelSurfs(XModelLodInfo* lodInfo, XModelSurfs* modelSurfs) const;
|
||||
};
|
||||
}
|
||||
} // namespace IW5
|
||||
|
@ -1,31 +1,30 @@
|
||||
#include "ZoneLoaderFactoryIW5.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ContentLoaderIW5.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||
#include "Game/IW5/GameIW5.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/ZoneConstantsIW5.h"
|
||||
#include "Loading/Processor/ProcessorAuthedBlocks.h"
|
||||
#include "Loading/Processor/ProcessorCaptureData.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Steps/StepVerifyMagic.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepVerifyFileName.h"
|
||||
#include "Loading/Steps/StepLoadSignature.h"
|
||||
#include "Loading/Steps/StepVerifySignature.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepLoadHash.h"
|
||||
#include "Loading/Steps/StepLoadSignature.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepRemoveProcessor.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepVerifyFileName.h"
|
||||
#include "Loading/Steps/StepVerifyHash.h"
|
||||
#include "Loading/Steps/StepVerifyMagic.h"
|
||||
#include "Loading/Steps/StepVerifySignature.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
@ -84,8 +83,7 @@ class ZoneLoaderFactory::Impl
|
||||
{
|
||||
if (isOfficial)
|
||||
{
|
||||
auto rsa = Crypto::CreateRSA(IPublicKeyAlgorithm::HashingAlgorithm::RSA_HASH_SHA256,
|
||||
Crypto::RSAPaddingMode::RSA_PADDING_PSS);
|
||||
auto rsa = Crypto::CreateRSA(IPublicKeyAlgorithm::HashingAlgorithm::RSA_HASH_SHA256, Crypto::RSAPaddingMode::RSA_PADDING_PSS);
|
||||
|
||||
if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD)))
|
||||
{
|
||||
@ -104,8 +102,7 @@ class ZoneLoaderFactory::Impl
|
||||
}
|
||||
}
|
||||
|
||||
static void AddAuthHeaderSteps(const bool isSecure, const bool isOfficial, ZoneLoader* zoneLoader,
|
||||
std::string& fileName)
|
||||
static void AddAuthHeaderSteps(const bool isSecure, const bool isOfficial, ZoneLoader* zoneLoader, std::string& fileName)
|
||||
{
|
||||
// Unsigned zones do not have an auth header
|
||||
if (!isSecure)
|
||||
@ -138,15 +135,19 @@ class ZoneLoaderFactory::Impl
|
||||
auto* masterBlockHashesPtr = masterBlockHashes.get();
|
||||
zoneLoader->AddLoadingStep(std::move(masterBlockHashes));
|
||||
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepVerifyHash>(std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), 0, subHeaderHashPtr, subHeaderCapturePtr));
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepVerifyHash>(std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), 0, subHeaderHashPtr, subHeaderCapturePtr));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepRemoveProcessor>(subHeaderCapturePtr));
|
||||
|
||||
// Skip the rest of the first chunk
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepSkipBytes>(ZoneConstants::AUTHED_CHUNK_SIZE - sizeof(DB_AuthHeader)));
|
||||
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorAuthedBlocks>(
|
||||
ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP, ZoneConstants::AUTHED_CHUNK_SIZE, std::extent<decltype(DB_AuthSubHeader::masterBlockHashes)>::value,
|
||||
std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()), masterBlockHashesPtr)));
|
||||
zoneLoader->AddLoadingStep(
|
||||
std::make_unique<StepAddProcessor>(std::make_unique<ProcessorAuthedBlocks>(ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP,
|
||||
ZoneConstants::AUTHED_CHUNK_SIZE,
|
||||
std::extent<decltype(DB_AuthSubHeader::masterBlockHashes)>::value,
|
||||
std::unique_ptr<IHashFunction>(Crypto::CreateSHA256()),
|
||||
masterBlockHashesPtr)));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -187,7 +188,8 @@ public:
|
||||
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, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
// Return the fully setup zoneloader
|
||||
return zoneLoader;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/IZoneLoaderFactory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace IW5
|
||||
@ -12,4 +13,4 @@ namespace IW5
|
||||
public:
|
||||
ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW5
|
||||
|
@ -1,9 +1,6 @@
|
||||
#include "ContentLoaderT5.h"
|
||||
|
||||
#include "Game/T5/T5.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/T5/XAssets/clipmap_t/clipmap_t_load_db.h"
|
||||
#include "Game/T5/XAssets/comworld/comworld_load_db.h"
|
||||
#include "Game/T5/XAssets/ddlroot_t/ddlroot_t_load_db.h"
|
||||
@ -36,6 +33,9 @@
|
||||
#include "Game/T5/XAssets/xanimparts/xanimparts_load_db.h"
|
||||
#include "Game/T5/XAssets/xglobals/xglobals_load_db.h"
|
||||
#include "Game/T5/XAssets/xmodel/xmodel_load_db.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace T5;
|
||||
|
||||
@ -71,15 +71,15 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
{
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define SKIP_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
break;
|
||||
|
||||
assert(varXAsset != nullptr);
|
||||
@ -89,44 +89,44 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, PhysConstraints, physConstraints)
|
||||
LOAD_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, DestructibleDef, destructibleDef)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, SndBank, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_PATCH, SndPatch, soundPatch)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponVariantDef, weapon)
|
||||
LOAD_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_PACK_INDEX, PackIndex, packIndex)
|
||||
LOAD_ASSET(ASSET_TYPE_XGLOBALS, XGlobals, xGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_DDL, ddlRoot_t, ddlRoot)
|
||||
LOAD_ASSET(ASSET_TYPE_GLASSES, Glasses, glasses)
|
||||
LOAD_ASSET(ASSET_TYPE_EMBLEMSET, EmblemSet, emblemSet)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, PhysConstraints, physConstraints)
|
||||
LOAD_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, DestructibleDef, destructibleDef)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, SndBank, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_PATCH, SndPatch, soundPatch)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponVariantDef, weapon)
|
||||
LOAD_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_PACK_INDEX, PackIndex, packIndex)
|
||||
LOAD_ASSET(ASSET_TYPE_XGLOBALS, XGlobals, xGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_DDL, ddlRoot_t, ddlRoot)
|
||||
LOAD_ASSET(ASSET_TYPE_GLASSES, Glasses, glasses)
|
||||
LOAD_ASSET(ASSET_TYPE_EMBLEMSET, EmblemSet, emblemSet)
|
||||
|
||||
default:
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOAD_ASSET
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T5/T5.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
@ -20,4 +20,4 @@ namespace T5
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
};
|
||||
}
|
||||
} // namespace T5
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/T5/T5.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace T5
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
};
|
||||
}
|
||||
} // namespace T5
|
||||
|
@ -1,23 +1,22 @@
|
||||
#include "ZoneLoaderFactoryT5.h"
|
||||
|
||||
#include "ContentLoaderT5.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
#include "Game/T5/GameT5.h"
|
||||
#include "Game/T5/T5.h"
|
||||
#include "Game/T5/ZoneConstantsT5.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ContentLoaderT5.h"
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
#include "Game/T5/GameT5.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/T5/ZoneConstantsT5.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
class ZoneLoaderFactory::Impl
|
||||
@ -91,7 +90,8 @@ public:
|
||||
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, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
// Return the fully setup zoneloader
|
||||
return zoneLoader;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/IZoneLoaderFactory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace T5
|
||||
@ -12,4 +13,4 @@ namespace T5
|
||||
public:
|
||||
ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) override;
|
||||
};
|
||||
}
|
||||
} // namespace T5
|
||||
|
@ -1,9 +1,6 @@
|
||||
#include "ContentLoaderT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "Game/T6/XAssets/addonmapents/addonmapents_load_db.h"
|
||||
#include "Game/T6/XAssets/clipmap_t/clipmap_t_load_db.h"
|
||||
#include "Game/T6/XAssets/comworld/comworld_load_db.h"
|
||||
@ -52,6 +49,9 @@
|
||||
#include "Game/T6/XAssets/xglobals/xglobals_load_db.h"
|
||||
#include "Game/T6/XAssets/xmodel/xmodel_load_db.h"
|
||||
#include "Game/T6/XAssets/zbarrierdef/zbarrierdef_load_db.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
@ -87,13 +87,13 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
|
||||
void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
{
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
#define LOAD_ASSET(type_index, typeName, headerEntry) \
|
||||
case type_index: \
|
||||
{ \
|
||||
Loader_##typeName loader(m_zone, m_stream); \
|
||||
loader.Load(&varXAsset->header.headerEntry); \
|
||||
break; \
|
||||
}
|
||||
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
@ -102,60 +102,60 @@ void ContentLoader::LoadXAsset(const bool atStreamStart) const
|
||||
|
||||
switch (varXAsset->type)
|
||||
{
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, PhysConstraints, physConstraints)
|
||||
LOAD_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, DestructibleDef, destructibleDef)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, SndBank, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_PATCH, SndPatch, soundPatch)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_FONTICON, FontIcon, fontIcon)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponVariantDef, weapon)
|
||||
LOAD_ASSET(ASSET_TYPE_ATTACHMENT, WeaponAttachment, attachment)
|
||||
LOAD_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, WeaponAttachmentUnique, attachmentUnique)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON_CAMO, WeaponCamo, weaponCamo)
|
||||
LOAD_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef)
|
||||
LOAD_ASSET(ASSET_TYPE_XGLOBALS, XGlobals, xGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_DDL, ddlRoot_t, ddlRoot)
|
||||
LOAD_ASSET(ASSET_TYPE_GLASSES, Glasses, glasses)
|
||||
LOAD_ASSET(ASSET_TYPE_EMBLEMSET, EmblemSet, emblemSet)
|
||||
LOAD_ASSET(ASSET_TYPE_SCRIPTPARSETREE, ScriptParseTree, scriptParseTree)
|
||||
LOAD_ASSET(ASSET_TYPE_KEYVALUEPAIRS, KeyValuePairs, keyValuePairs)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLEDEF, VehicleDef, vehicleDef)
|
||||
LOAD_ASSET(ASSET_TYPE_MEMORYBLOCK, MemoryBlock, memoryBlock);
|
||||
LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef)
|
||||
LOAD_ASSET(ASSET_TYPE_SKINNEDVERTS, SkinnedVertsDef, skinnedVertsDef)
|
||||
LOAD_ASSET(ASSET_TYPE_QDB, Qdb, qdb)
|
||||
LOAD_ASSET(ASSET_TYPE_SLUG, Slug, slug)
|
||||
LOAD_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, FootstepTableDef, footstepTableDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, FootstepFXTableDef, footstepFXTableDef)
|
||||
LOAD_ASSET(ASSET_TYPE_ZBARRIER, ZBarrierDef, zbarrierDef)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
|
||||
LOAD_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, PhysConstraints, physConstraints)
|
||||
LOAD_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, DestructibleDef, destructibleDef)
|
||||
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
|
||||
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
|
||||
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
|
||||
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
|
||||
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND, SndBank, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SOUND_PATCH, SndPatch, soundPatch)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
|
||||
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
|
||||
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
|
||||
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_FONTICON, FontIcon, fontIcon)
|
||||
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
|
||||
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
|
||||
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponVariantDef, weapon)
|
||||
LOAD_ASSET(ASSET_TYPE_ATTACHMENT, WeaponAttachment, attachment)
|
||||
LOAD_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, WeaponAttachmentUnique, attachmentUnique)
|
||||
LOAD_ASSET(ASSET_TYPE_WEAPON_CAMO, WeaponCamo, weaponCamo)
|
||||
LOAD_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
|
||||
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
|
||||
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
|
||||
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
|
||||
LOAD_ASSET(ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef)
|
||||
LOAD_ASSET(ASSET_TYPE_XGLOBALS, XGlobals, xGlobals)
|
||||
LOAD_ASSET(ASSET_TYPE_DDL, ddlRoot_t, ddlRoot)
|
||||
LOAD_ASSET(ASSET_TYPE_GLASSES, Glasses, glasses)
|
||||
LOAD_ASSET(ASSET_TYPE_EMBLEMSET, EmblemSet, emblemSet)
|
||||
LOAD_ASSET(ASSET_TYPE_SCRIPTPARSETREE, ScriptParseTree, scriptParseTree)
|
||||
LOAD_ASSET(ASSET_TYPE_KEYVALUEPAIRS, KeyValuePairs, keyValuePairs)
|
||||
LOAD_ASSET(ASSET_TYPE_VEHICLEDEF, VehicleDef, vehicleDef)
|
||||
LOAD_ASSET(ASSET_TYPE_MEMORYBLOCK, MemoryBlock, memoryBlock);
|
||||
LOAD_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts)
|
||||
LOAD_ASSET(ASSET_TYPE_TRACER, TracerDef, tracerDef)
|
||||
LOAD_ASSET(ASSET_TYPE_SKINNEDVERTS, SkinnedVertsDef, skinnedVertsDef)
|
||||
LOAD_ASSET(ASSET_TYPE_QDB, Qdb, qdb)
|
||||
LOAD_ASSET(ASSET_TYPE_SLUG, Slug, slug)
|
||||
LOAD_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, FootstepTableDef, footstepTableDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, FootstepFXTableDef, footstepFXTableDef)
|
||||
LOAD_ASSET(ASSET_TYPE_ZBARRIER, ZBarrierDef, zbarrierDef)
|
||||
|
||||
default:
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOAD_ASSET
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
@ -20,4 +20,4 @@ namespace T6
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
@ -13,4 +13,4 @@ namespace T6
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
@ -1,30 +1,29 @@
|
||||
#include "ZoneLoaderFactoryT6.h"
|
||||
|
||||
#include "ContentLoaderT6.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/ZoneConstantsT6.h"
|
||||
#include "Loading/Processor/ProcessorXChunks.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadSignature.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepLoadZoneSizes.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepVerifyFileName.h"
|
||||
#include "Loading/Steps/StepVerifyMagic.h"
|
||||
#include "Loading/Steps/StepVerifySignature.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Zone/XChunk/XChunkProcessorInflate.h"
|
||||
#include "Zone/XChunk/XChunkProcessorSalsa20Decryption.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/ZoneConstantsT6.h"
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ContentLoaderT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Loading/Processor/ProcessorXChunks.h"
|
||||
#include "Zone/XChunk/XChunkProcessorSalsa20Decryption.h"
|
||||
#include "Zone/XChunk/XChunkProcessorInflate.h"
|
||||
#include "Loading/Steps/StepVerifyMagic.h"
|
||||
#include "Loading/Steps/StepSkipBytes.h"
|
||||
#include "Loading/Steps/StepVerifyFileName.h"
|
||||
#include "Loading/Steps/StepLoadSignature.h"
|
||||
#include "Loading/Steps/StepVerifySignature.h"
|
||||
#include "Loading/Steps/StepAddProcessor.h"
|
||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||
#include "Loading/Steps/StepLoadZoneSizes.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
class ZoneLoaderFactory::Impl
|
||||
@ -153,8 +152,8 @@ class ZoneLoaderFactory::Impl
|
||||
if (isEncrypted)
|
||||
{
|
||||
// If zone is encrypted, the decryption is applied before the decompression. T6 Zones always use Salsa20.
|
||||
auto chunkProcessorSalsa20 = std::make_unique<XChunkProcessorSalsa20Decryption>(ZoneConstants::STREAM_COUNT, fileName, ZoneConstants::SALSA20_KEY_TREYARCH,
|
||||
sizeof(ZoneConstants::SALSA20_KEY_TREYARCH));
|
||||
auto chunkProcessorSalsa20 = std::make_unique<XChunkProcessorSalsa20Decryption>(
|
||||
ZoneConstants::STREAM_COUNT, fileName, ZoneConstants::SALSA20_KEY_TREYARCH, sizeof(ZoneConstants::SALSA20_KEY_TREYARCH));
|
||||
result = chunkProcessorSalsa20.get();
|
||||
xChunkProcessor->AddChunkProcessor(std::move(chunkProcessorSalsa20));
|
||||
}
|
||||
@ -203,7 +202,8 @@ public:
|
||||
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, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
if (isSecure)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/IZoneLoaderFactory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace T6
|
||||
@ -12,4 +13,4 @@ namespace T6
|
||||
public:
|
||||
ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) override;
|
||||
};
|
||||
}
|
||||
} // namespace T6
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "AssetLoader.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "Zone/ZoneTypes.h"
|
||||
#include "Pool/XAssetInfo.h"
|
||||
#include "ContentLoaderBase.h"
|
||||
#include "Pool/XAssetInfo.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
class AssetLoader : public ContentLoaderBase
|
||||
{
|
||||
@ -18,7 +18,7 @@ protected:
|
||||
scr_string_t* varScriptString;
|
||||
|
||||
AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream);
|
||||
|
||||
|
||||
void AddDependency(XAssetInfoGeneric* assetInfo);
|
||||
|
||||
scr_string_t UseScriptString(scr_string_t scrString);
|
||||
|
@ -9,4 +9,4 @@ protected:
|
||||
|
||||
public:
|
||||
explicit AssetLoadingActions(Zone* zone);
|
||||
};
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "ContentLoaderBase.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
const void* ContentLoaderBase::PTR_FOLLOWING = reinterpret_cast<void*>(-1);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/Stream/IZoneInputStream.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
class ContentLoaderBase
|
||||
{
|
||||
|
@ -13,4 +13,4 @@ std::string BlockOverflowException::DetailedMessage()
|
||||
char const* BlockOverflowException::what() const noexcept
|
||||
{
|
||||
return "Invalid Zone. XBlock overflowed.";
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ InvalidChunkSizeException::InvalidChunkSizeException(const size_t size, const si
|
||||
|
||||
std::string InvalidChunkSizeException::DetailedMessage()
|
||||
{
|
||||
if(m_max > 0)
|
||||
if (m_max > 0)
|
||||
{
|
||||
return "Zone chunk size has a chunk size of " + std::to_string(m_size) + " which is larger than the maximum of " + std::to_string(m_max);
|
||||
}
|
||||
@ -27,4 +27,4 @@ std::string InvalidChunkSizeException::DetailedMessage()
|
||||
char const* InvalidChunkSizeException::what() const noexcept
|
||||
{
|
||||
return "Zone has invalid chunk size";
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ std::string InvalidFileNameException::DetailedMessage()
|
||||
char const* InvalidFileNameException::what() const noexcept
|
||||
{
|
||||
return "The filename when created and when loaded does not match";
|
||||
}
|
||||
}
|
||||
|
@ -8,4 +8,4 @@ std::string InvalidHashException::DetailedMessage()
|
||||
char const* InvalidHashException::what() const noexcept
|
||||
{
|
||||
return "Loaded fastfile has an invalid hash.";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "InvalidMagicException.h"
|
||||
|
||||
|
||||
InvalidMagicException::InvalidMagicException(const char* expectedMagic)
|
||||
{
|
||||
m_expected_magic = expectedMagic;
|
||||
@ -13,4 +13,4 @@ std::string InvalidMagicException::DetailedMessage()
|
||||
char const* InvalidMagicException::what() const noexcept
|
||||
{
|
||||
return "Encountered invalid magic when loading.";
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ std::string InvalidOffsetBlockException::DetailedMessage()
|
||||
char const* InvalidOffsetBlockException::what() const noexcept
|
||||
{
|
||||
return "Zone referenced invalid block";
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ InvalidOffsetBlockOffsetException::InvalidOffsetBlockOffsetException(XBlock* blo
|
||||
|
||||
std::string InvalidOffsetBlockOffsetException::DetailedMessage()
|
||||
{
|
||||
return "Zone referenced offset " + std::to_string(m_referenced_offset) + " of block " + m_referenced_block->m_name
|
||||
+ " which is larger than its size " + std::to_string(m_referenced_block->m_buffer_size);
|
||||
return "Zone referenced offset " + std::to_string(m_referenced_offset) + " of block " + m_referenced_block->m_name + " which is larger than its size "
|
||||
+ std::to_string(m_referenced_block->m_buffer_size);
|
||||
}
|
||||
|
||||
char const* InvalidOffsetBlockOffsetException::what() const noexcept
|
||||
{
|
||||
return "Zone referenced offset of block that is out of bounds";
|
||||
}
|
||||
}
|
||||
|
@ -8,4 +8,4 @@ std::string InvalidSignatureException::DetailedMessage()
|
||||
char const* InvalidSignatureException::what() const noexcept
|
||||
{
|
||||
return "Loaded fastfile has an invalid signature.";
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ std::string InvalidVersionException::DetailedMessage()
|
||||
char const* InvalidVersionException::what() const noexcept
|
||||
{
|
||||
return "Encountered invalid version when loading.";
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ std::string InvalidXBlockSizeException::DetailedMessage()
|
||||
char const* InvalidXBlockSizeException::what() const noexcept
|
||||
{
|
||||
return "Zone has invalid block size";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "LoadingException.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class InvalidXBlockSizeException final : public LoadingException
|
||||
{
|
||||
uint64_t m_size;
|
||||
|
@ -13,4 +13,4 @@ std::string OutOfBlockBoundsException::DetailedMessage()
|
||||
char const* OutOfBlockBoundsException::what() const noexcept
|
||||
{
|
||||
return "Invalid Zone. Out of XBlock bounds.";
|
||||
}
|
||||
}
|
||||
|
@ -8,4 +8,4 @@ std::string TooManyAuthedGroupsException::DetailedMessage()
|
||||
char const* TooManyAuthedGroupsException::what() const noexcept
|
||||
{
|
||||
return "Loaded fastfile has too many authed groups.";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "UnexpectedEndOfFileException.h"
|
||||
|
||||
|
||||
UnexpectedEndOfFileException::UnexpectedEndOfFileException() = default;
|
||||
|
||||
std::string UnexpectedEndOfFileException::DetailedMessage()
|
||||
@ -10,4 +10,4 @@ std::string UnexpectedEndOfFileException::DetailedMessage()
|
||||
char const* UnexpectedEndOfFileException::what() const noexcept
|
||||
{
|
||||
return "Unexpected end of file";
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ std::string UnsupportedAssetTypeException::DetailedMessage()
|
||||
char const* UnsupportedAssetTypeException::what() const noexcept
|
||||
{
|
||||
return "Zone has unsupported asset type.";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/Stream/IZoneInputStream.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
class IContentLoadingEntryPoint
|
||||
{
|
||||
@ -9,4 +9,4 @@ public:
|
||||
virtual ~IContentLoadingEntryPoint() = default;
|
||||
|
||||
virtual void Load(Zone* zone, IZoneInputStream* stream) = 0;
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/ZoneLoader.h"
|
||||
#include "ILoadingStream.h"
|
||||
#include "Loading/ZoneLoader.h"
|
||||
|
||||
class ZoneLoader;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class ILoadingStream
|
||||
{
|
||||
@ -10,4 +10,4 @@ public:
|
||||
|
||||
virtual size_t Load(void* buffer, size_t length) = 0;
|
||||
virtual int64_t Pos() = 0;
|
||||
};
|
||||
};
|
||||
|
@ -14,4 +14,4 @@ public:
|
||||
IZoneLoaderFactory& operator=(IZoneLoaderFactory&& other) noexcept = default;
|
||||
|
||||
virtual ZoneLoader* CreateLoaderForHeader(ZoneHeader& header, std::string& fileName) = 0;
|
||||
};
|
||||
};
|
||||
|
@ -14,4 +14,4 @@ size_t LoadingFileStream::Load(void* buffer, const size_t length)
|
||||
int64_t LoadingFileStream::Pos()
|
||||
{
|
||||
return m_stream.tellg();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <istream>
|
||||
|
||||
#include "ILoadingStream.h"
|
||||
|
||||
#include <istream>
|
||||
|
||||
class LoadingFileStream final : public ILoadingStream
|
||||
{
|
||||
std::istream& m_stream;
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "ProcessorAuthedBlocks.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/Exception/InvalidHashException.h"
|
||||
#include "Loading/Exception/TooManyAuthedGroupsException.h"
|
||||
#include "Loading/Exception/UnexpectedEndOfFileException.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
class ProcessorAuthedBlocks::Impl
|
||||
{
|
||||
ProcessorAuthedBlocks* const m_base;
|
||||
@ -30,7 +30,9 @@ class ProcessorAuthedBlocks::Impl
|
||||
size_t m_current_chunk_size;
|
||||
|
||||
public:
|
||||
Impl(ProcessorAuthedBlocks* base, const unsigned authedChunkCount, const size_t chunkSize,
|
||||
Impl(ProcessorAuthedBlocks* base,
|
||||
const unsigned authedChunkCount,
|
||||
const size_t chunkSize,
|
||||
const unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction,
|
||||
IHashProvider* masterBlockHashProvider)
|
||||
@ -76,8 +78,7 @@ public:
|
||||
m_master_block_hash_provider->GetHash(m_current_group - 1, &masterBlockHash, &masterBlockHashSize);
|
||||
|
||||
if (masterBlockHashSize != m_hash_function->GetHashSize()
|
||||
|| std::memcmp(m_current_chunk_hash_buffer.get(), masterBlockHash,
|
||||
m_hash_function->GetHashSize()) != 0)
|
||||
|| std::memcmp(m_current_chunk_hash_buffer.get(), masterBlockHash, m_hash_function->GetHashSize()) != 0)
|
||||
throw InvalidHashException();
|
||||
|
||||
memcpy(m_chunk_hashes_buffer.get(), m_chunk_buffer.get(), m_authed_chunk_count * m_hash_function->GetHashSize());
|
||||
@ -88,7 +89,8 @@ public:
|
||||
{
|
||||
if (std::memcmp(m_current_chunk_hash_buffer.get(),
|
||||
&m_chunk_hashes_buffer[(m_current_chunk_in_group - 1) * m_hash_function->GetHashSize()],
|
||||
m_hash_function->GetHashSize()) != 0)
|
||||
m_hash_function->GetHashSize())
|
||||
!= 0)
|
||||
throw InvalidHashException();
|
||||
|
||||
if (++m_current_chunk_in_group > m_authed_chunk_count)
|
||||
@ -136,12 +138,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
ProcessorAuthedBlocks::ProcessorAuthedBlocks(const unsigned authedChunkCount, const size_t chunkSize,
|
||||
ProcessorAuthedBlocks::ProcessorAuthedBlocks(const unsigned authedChunkCount,
|
||||
const size_t chunkSize,
|
||||
const unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction,
|
||||
IHashProvider* masterBlockHashProvider)
|
||||
: m_impl(new Impl(this, authedChunkCount, chunkSize, maxMasterBlockCount, std::move(hashFunction),
|
||||
masterBlockHashProvider))
|
||||
: m_impl(new Impl(this, authedChunkCount, chunkSize, maxMasterBlockCount, std::move(hashFunction), masterBlockHashProvider))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "Crypto.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Loading/IHashProvider.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ProcessorAuthedBlocks final : public StreamProcessor
|
||||
{
|
||||
@ -11,8 +11,11 @@ class ProcessorAuthedBlocks final : public StreamProcessor
|
||||
Impl* m_impl;
|
||||
|
||||
public:
|
||||
ProcessorAuthedBlocks(unsigned authedChunkCount, size_t chunkSize, unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction, IHashProvider* masterBlockHashProvider);
|
||||
ProcessorAuthedBlocks(unsigned authedChunkCount,
|
||||
size_t chunkSize,
|
||||
unsigned maxMasterBlockCount,
|
||||
std::unique_ptr<IHashFunction> hashFunction,
|
||||
IHashProvider* masterBlockHashProvider);
|
||||
~ProcessorAuthedBlocks() override;
|
||||
ProcessorAuthedBlocks(const ProcessorAuthedBlocks& other) = delete;
|
||||
ProcessorAuthedBlocks(ProcessorAuthedBlocks&& other) noexcept = default;
|
||||
|
@ -10,8 +10,7 @@ ProcessorCaptureData::ProcessorCaptureData(const size_t captureSize)
|
||||
{
|
||||
}
|
||||
|
||||
ProcessorCaptureData::~ProcessorCaptureData()
|
||||
= default;
|
||||
ProcessorCaptureData::~ProcessorCaptureData() = default;
|
||||
|
||||
size_t ProcessorCaptureData::Load(void* buffer, const size_t length)
|
||||
{
|
||||
@ -29,7 +28,7 @@ size_t ProcessorCaptureData::Load(void* buffer, const size_t length)
|
||||
|
||||
m_captured_data_size += loadedSize;
|
||||
|
||||
if(length > dataToCapture)
|
||||
if (length > dataToCapture)
|
||||
loadedSize += m_base_stream->Load(&static_cast<uint8_t*>(buffer)[dataToCapture], length - dataToCapture);
|
||||
|
||||
return loadedSize;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ProcessorCaptureData final : public StreamProcessor, public ICapturedDataProvider
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> m_data;
|
||||
|
@ -24,7 +24,7 @@ size_t ProcessorIW4xDecryption::Load(void* buffer, const size_t length)
|
||||
const auto readLen = m_base_stream->Load(buffer, length);
|
||||
|
||||
auto* charBuffer = static_cast<uint8_t*>(buffer);
|
||||
for(auto i = 0u; i < readLen; i++)
|
||||
for (auto i = 0u; i < readLen; i++)
|
||||
{
|
||||
auto value = charBuffer[i];
|
||||
value ^= m_last_byte;
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "ProcessorInflate.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include "Loading/Exception/InvalidCompressionException.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <zlib.h>
|
||||
#include <zutil.h>
|
||||
|
||||
#include "Loading/Exception/InvalidCompressionException.h"
|
||||
|
||||
class ProcessorInflate::Impl
|
||||
{
|
||||
z_stream m_stream{};
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
auto ret = inflate(&m_stream, Z_SYNC_FLUSH);
|
||||
|
||||
if(ret < 0)
|
||||
if (ret < 0)
|
||||
throw InvalidCompressionException();
|
||||
}
|
||||
|
||||
|
@ -11,18 +11,17 @@ ProcessorStreamCipher::~ProcessorStreamCipher()
|
||||
m_cipher = nullptr;
|
||||
}
|
||||
|
||||
|
||||
size_t ProcessorStreamCipher::Load(void* buffer, const size_t length)
|
||||
{
|
||||
if(m_base_stream != nullptr)
|
||||
if (m_base_stream != nullptr)
|
||||
{
|
||||
const size_t readSize = m_base_stream->Load(buffer, length);
|
||||
|
||||
if(readSize > 0)
|
||||
if (readSize > 0)
|
||||
m_cipher->Process(buffer, buffer, readSize);
|
||||
|
||||
return readSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Crypto.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
|
||||
class ProcessorStreamCipher final : public StreamProcessor
|
||||
{
|
||||
|
@ -1,14 +1,15 @@
|
||||
#include "ProcessorXChunks.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
#include "Loading/Exception/InvalidChunkSizeException.h"
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include "Loading/Exception/InvalidChunkSizeException.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <condition_variable>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class DBLoadStream
|
||||
{
|
||||
@ -59,15 +60,15 @@ class DBLoadStream
|
||||
}
|
||||
|
||||
public:
|
||||
DBLoadStream(const int streamIndex, const size_t chunkSize,
|
||||
std::vector<std::unique_ptr<IXChunkProcessor>>& chunkProcessors) : m_processors(chunkProcessors)
|
||||
DBLoadStream(const int streamIndex, const size_t chunkSize, std::vector<std::unique_ptr<IXChunkProcessor>>& chunkProcessors)
|
||||
: m_processors(chunkProcessors)
|
||||
{
|
||||
m_index = streamIndex;
|
||||
m_chunk_size = chunkSize;
|
||||
|
||||
for(auto& buffer : m_buffers)
|
||||
for (auto& buffer : m_buffers)
|
||||
buffer = std::make_unique<uint8_t[]>(chunkSize);
|
||||
|
||||
|
||||
m_input_buffer = m_buffers[0].get();
|
||||
m_output_buffer = m_buffers[1].get();
|
||||
|
||||
@ -246,8 +247,8 @@ public:
|
||||
m_eof_stream = 0;
|
||||
}
|
||||
|
||||
ProcessorXChunksImpl(ProcessorXChunks* base, const int numStreams, const size_t xChunkSize,
|
||||
const size_t vanillaBufferSize) : ProcessorXChunksImpl(base, numStreams, xChunkSize)
|
||||
ProcessorXChunksImpl(ProcessorXChunks* base, const int numStreams, const size_t xChunkSize, const size_t vanillaBufferSize)
|
||||
: ProcessorXChunksImpl(base, numStreams, xChunkSize)
|
||||
{
|
||||
m_vanilla_buffer_size = vanillaBufferSize;
|
||||
}
|
||||
@ -334,4 +335,4 @@ size_t ProcessorXChunks::Load(void* buffer, const size_t length)
|
||||
int64_t ProcessorXChunks::Pos()
|
||||
{
|
||||
return m_impl->Pos();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Zone/XChunk/IXChunkProcessor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ProcessorXChunks : public StreamProcessor
|
||||
{
|
||||
class ProcessorXChunksImpl;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "StepAddProcessor.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StepAddProcessor::StepAddProcessor(std::unique_ptr<StreamProcessor> streamProcessor)
|
||||
@ -13,4 +14,4 @@ void StepAddProcessor::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* strea
|
||||
|
||||
zoneLoader->AddStreamProcessor(std::move(m_stream_processor));
|
||||
m_stream_processor = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Loading/ILoadingStep.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class StepAddProcessor final : public ILoadingStep
|
||||
{
|
||||
std::unique_ptr<StreamProcessor> m_stream_processor;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "StepAllocXBlocks.h"
|
||||
|
||||
#include "Loading/Exception/InvalidXBlockSizeException.h"
|
||||
|
||||
const uint64_t StepAllocXBlocks::MAX_XBLOCK_SIZE = 0x3C000000;
|
||||
@ -11,20 +12,20 @@ void StepAllocXBlocks::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* strea
|
||||
stream->Load(blockSizes, sizeof(xblock_size_t) * blockCount);
|
||||
|
||||
uint64_t totalMemory = 0;
|
||||
for(unsigned int block = 0; block < blockCount; block++)
|
||||
for (unsigned int block = 0; block < blockCount; block++)
|
||||
{
|
||||
totalMemory += blockSizes[block];
|
||||
}
|
||||
|
||||
if(totalMemory > MAX_XBLOCK_SIZE)
|
||||
if (totalMemory > MAX_XBLOCK_SIZE)
|
||||
{
|
||||
throw InvalidXBlockSizeException(totalMemory, MAX_XBLOCK_SIZE);
|
||||
}
|
||||
|
||||
for(unsigned int block = 0; block < blockCount; block++)
|
||||
for (unsigned int block = 0; block < blockCount; block++)
|
||||
{
|
||||
zoneLoader->m_blocks[block]->Alloc(blockSizes[block]);
|
||||
}
|
||||
|
||||
delete[] blockSizes;
|
||||
}
|
||||
}
|
||||
|
@ -37,4 +37,4 @@ void StepDumpData::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
}
|
||||
|
||||
tempFile.close();
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ public:
|
||||
explicit StepDumpData(unsigned int dumpCount);
|
||||
|
||||
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "StepLoadHash.h"
|
||||
|
||||
#include "Loading/Exception/UnexpectedEndOfFileException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StepLoadHash::StepLoadHash(const size_t hashSize, const unsigned hashCount)
|
||||
@ -9,8 +11,7 @@ StepLoadHash::StepLoadHash(const size_t hashSize, const unsigned hashCount)
|
||||
{
|
||||
}
|
||||
|
||||
StepLoadHash::~StepLoadHash()
|
||||
= default;
|
||||
StepLoadHash::~StepLoadHash() = default;
|
||||
|
||||
void StepLoadHash::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
{
|
||||
@ -36,7 +37,7 @@ void StepLoadHash::GetCapturedData(const uint8_t** pCapturedData, size_t* pSize)
|
||||
{
|
||||
assert(pCapturedData != nullptr);
|
||||
assert(pSize != nullptr);
|
||||
|
||||
|
||||
*pCapturedData = m_hashes.get();
|
||||
*pSize = m_hash_size * m_hash_count;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Loading/IHashProvider.h"
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class StepLoadHash final : public ILoadingStep, public IHashProvider, public ICapturedDataProvider
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "StepLoadSignature.h"
|
||||
|
||||
#include "Loading/Exception/UnexpectedEndOfFileException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StepLoadSignature::StepLoadSignature(const size_t signatureSize)
|
||||
@ -17,8 +19,8 @@ StepLoadSignature::~StepLoadSignature()
|
||||
void StepLoadSignature::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
{
|
||||
assert(stream != nullptr);
|
||||
|
||||
if(stream->Load(m_signature, m_signature_size) != m_signature_size)
|
||||
|
||||
if (stream->Load(m_signature, m_signature_size) != m_signature_size)
|
||||
throw UnexpectedEndOfFileException();
|
||||
}
|
||||
|
||||
@ -31,4 +33,4 @@ void StepLoadSignature::GetSignature(const uint8_t** pSignature, size_t* pSize)
|
||||
|
||||
*pSignature = m_signature;
|
||||
*pSize = m_signature_size;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
#include "StepLoadZoneContent.h"
|
||||
|
||||
#include "Zone/Stream/Impl/XBlockInputStream.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StepLoadZoneContent::StepLoadZoneContent(std::unique_ptr<IContentLoadingEntryPoint> entryPoint, Zone* zone, const int offsetBlockBitCount, const block_t insertBlock)
|
||||
StepLoadZoneContent::StepLoadZoneContent(std::unique_ptr<IContentLoadingEntryPoint> entryPoint,
|
||||
Zone* zone,
|
||||
const int offsetBlockBitCount,
|
||||
const block_t insertBlock)
|
||||
: m_content_loader(std::move(entryPoint)),
|
||||
m_zone(zone),
|
||||
m_offset_block_bit_count(offsetBlockBitCount),
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
#include "Loading/ILoadingStep.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class StepLoadZoneContent final : public ILoadingStep
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class StepLoadZoneSizes final : public ILoadingStep
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "StepRemoveProcessor.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StepRemoveProcessor::StepRemoveProcessor(StreamProcessor* streamProcessor)
|
||||
|
@ -10,11 +10,11 @@ void StepSkipBytes::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
uint8_t tempBuffer[128];
|
||||
unsigned int skippedBytes = 0;
|
||||
|
||||
while(skippedBytes < m_skip_count)
|
||||
while (skippedBytes < m_skip_count)
|
||||
{
|
||||
unsigned int toSkip;
|
||||
|
||||
if(m_skip_count - skippedBytes < sizeof(tempBuffer))
|
||||
if (m_skip_count - skippedBytes < sizeof(tempBuffer))
|
||||
{
|
||||
toSkip = m_skip_count - skippedBytes;
|
||||
}
|
||||
@ -27,4 +27,4 @@ void StepSkipBytes::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
|
||||
skippedBytes += toSkip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ public:
|
||||
explicit StepSkipBytes(unsigned int skipCount);
|
||||
|
||||
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
|
||||
};
|
||||
};
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "StepVerifyFileName.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Loading/Exception/InvalidFileNameException.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
StepVerifyFileName::StepVerifyFileName(std::string fileName, const size_t fileNameBufferSize)
|
||||
{
|
||||
m_file_name = std::move(fileName);
|
||||
m_file_name_buffer_size = fileNameBufferSize;
|
||||
|
||||
if(m_file_name.length() > m_file_name_buffer_size)
|
||||
if (m_file_name.length() > m_file_name_buffer_size)
|
||||
m_file_name.erase(m_file_name_buffer_size);
|
||||
}
|
||||
|
||||
@ -19,12 +19,12 @@ void StepVerifyFileName::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* str
|
||||
unsigned bufferOffset = 0;
|
||||
char c;
|
||||
|
||||
for(; bufferOffset < m_file_name_buffer_size; bufferOffset++)
|
||||
for (; bufferOffset < m_file_name_buffer_size; bufferOffset++)
|
||||
{
|
||||
|
||||
stream->Load(&c, sizeof(char));
|
||||
|
||||
if(c == '\00')
|
||||
if (c == '\00')
|
||||
{
|
||||
bufferOffset++;
|
||||
break;
|
||||
@ -34,7 +34,7 @@ void StepVerifyFileName::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* str
|
||||
}
|
||||
|
||||
// Skip the rest of the buffer which should be null bytes
|
||||
while(bufferOffset < m_file_name_buffer_size)
|
||||
while (bufferOffset < m_file_name_buffer_size)
|
||||
{
|
||||
stream->Load(&c, sizeof(char));
|
||||
bufferOffset++;
|
||||
@ -42,6 +42,6 @@ void StepVerifyFileName::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* str
|
||||
|
||||
std::string originalFileName = originalFilenameStream.str();
|
||||
|
||||
if(originalFileName != m_file_name)
|
||||
if (originalFileName != m_file_name)
|
||||
throw InvalidFileNameException(m_file_name, originalFileName);
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ public:
|
||||
explicit StepVerifyFileName(std::string fileName, size_t fileNameBufferSize);
|
||||
|
||||
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
|
||||
};
|
||||
};
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include "StepVerifyHash.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
#include "Loading/Exception/InvalidHashException.h"
|
||||
|
||||
StepVerifyHash::StepVerifyHash(std::unique_ptr<IHashFunction> hashFunction, const unsigned hashIndex, IHashProvider* hashProvider,
|
||||
ICapturedDataProvider* dataProvider)
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
StepVerifyHash::StepVerifyHash(std::unique_ptr<IHashFunction> hashFunction,
|
||||
const unsigned hashIndex,
|
||||
IHashProvider* hashProvider,
|
||||
ICapturedDataProvider* dataProvider)
|
||||
: m_hash_function(std::move(hashFunction)),
|
||||
m_hash_index(hashIndex),
|
||||
m_hash_provider(hashProvider),
|
||||
@ -14,8 +16,7 @@ StepVerifyHash::StepVerifyHash(std::unique_ptr<IHashFunction> hashFunction, cons
|
||||
{
|
||||
}
|
||||
|
||||
StepVerifyHash::~StepVerifyHash()
|
||||
= default;
|
||||
StepVerifyHash::~StepVerifyHash() = default;
|
||||
|
||||
void StepVerifyHash::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
{
|
||||
@ -35,6 +36,6 @@ void StepVerifyHash::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
|
||||
m_hash_function->Process(dataToHash, dataToHashSize);
|
||||
m_hash_function->Finish(hashMemory.get());
|
||||
|
||||
if(std::memcmp(hashData, hashMemory.get(), m_hash_function->GetHashSize()) != 0)
|
||||
if (std::memcmp(hashData, hashMemory.get(), m_hash_function->GetHashSize()) != 0)
|
||||
throw InvalidHashException();
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Crypto.h"
|
||||
#include "Loading/IHashProvider.h"
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
#include "Loading/IHashProvider.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class StepVerifyHash final : public ILoadingStep
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "StepVerifyMagic.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Loading/Exception/InvalidMagicException.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
StepVerifyMagic::StepVerifyMagic(const char* magic)
|
||||
{
|
||||
m_magic = magic;
|
||||
@ -14,11 +14,11 @@ void StepVerifyMagic::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream
|
||||
{
|
||||
char currentCharacter;
|
||||
|
||||
for(unsigned i = 0; i < m_magic_len; i++)
|
||||
for (unsigned i = 0; i < m_magic_len; i++)
|
||||
{
|
||||
stream->Load(¤tCharacter, sizeof(char));
|
||||
|
||||
if(currentCharacter != m_magic[i])
|
||||
if (currentCharacter != m_magic[i])
|
||||
throw InvalidMagicException(m_magic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ public:
|
||||
explicit StepVerifyMagic(const char* magic);
|
||||
|
||||
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
|
||||
};
|
||||
};
|
||||
|
@ -1,8 +1,12 @@
|
||||
#include "StepVerifySignature.h"
|
||||
|
||||
#include "Loading/Exception/InvalidSignatureException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StepVerifySignature::StepVerifySignature(std::unique_ptr<IPublicKeyAlgorithm> signatureAlgorithm, ISignatureProvider* signatureProvider, ICapturedDataProvider* signatureDataProvider)
|
||||
StepVerifySignature::StepVerifySignature(std::unique_ptr<IPublicKeyAlgorithm> signatureAlgorithm,
|
||||
ISignatureProvider* signatureProvider,
|
||||
ICapturedDataProvider* signatureDataProvider)
|
||||
: m_algorithm(std::move(signatureAlgorithm)),
|
||||
m_signature_provider(signatureProvider),
|
||||
m_signature_data_provider(signatureDataProvider)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Crypto.h"
|
||||
#include "Loading/ILoadingStep.h"
|
||||
#include "Loading/ISignatureProvider.h"
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
|
||||
@ -12,7 +12,9 @@ class StepVerifySignature final : public ILoadingStep
|
||||
ICapturedDataProvider* m_signature_data_provider;
|
||||
|
||||
public:
|
||||
StepVerifySignature(std::unique_ptr<IPublicKeyAlgorithm> signatureAlgorithm, ISignatureProvider* signatureProvider, ICapturedDataProvider* signatureDataProvider);
|
||||
StepVerifySignature(std::unique_ptr<IPublicKeyAlgorithm> signatureAlgorithm,
|
||||
ISignatureProvider* signatureProvider,
|
||||
ICapturedDataProvider* signatureDataProvider);
|
||||
~StepVerifySignature() override = default;
|
||||
StepVerifySignature(const StepVerifySignature& other) = delete;
|
||||
StepVerifySignature(StepVerifySignature&& other) noexcept = default;
|
||||
@ -20,4 +22,4 @@ public:
|
||||
StepVerifySignature& operator=(StepVerifySignature&& other) noexcept = default;
|
||||
|
||||
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
|
||||
};
|
||||
};
|
||||
|
@ -8,4 +8,4 @@ StreamProcessor::StreamProcessor()
|
||||
void StreamProcessor::SetBaseStream(ILoadingStream* baseStream)
|
||||
{
|
||||
m_base_stream = baseStream;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "ZoneLoader.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Exception/LoadingException.h"
|
||||
#include "LoadingFileStream.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
ZoneLoader::ZoneLoader(std::unique_ptr<Zone> zone)
|
||||
: m_processor_chain_dirty(false),
|
||||
m_zone(std::move(zone))
|
||||
@ -30,10 +30,12 @@ void ZoneLoader::AddXBlock(std::unique_ptr<XBlock> block)
|
||||
{
|
||||
m_blocks.push_back(block.get());
|
||||
|
||||
std::sort(m_blocks.begin(), m_blocks.end(), [](XBlock* b1, XBlock* b2) -> bool
|
||||
{
|
||||
return b1->m_index < b2->m_index;
|
||||
});
|
||||
std::sort(m_blocks.begin(),
|
||||
m_blocks.end(),
|
||||
[](XBlock* b1, XBlock* b2) -> bool
|
||||
{
|
||||
return b1->m_index < b2->m_index;
|
||||
});
|
||||
|
||||
m_zone->GetMemory()->AddBlock(std::move(block));
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "ILoadingStep.h"
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/XBlock.h"
|
||||
#include "StreamProcessor.h"
|
||||
#include "Zone/XBlock.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <vector>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class ILoadingStep;
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#include "Zone/Stream/IZoneStream.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class IZoneInputStream : public IZoneStream
|
||||
{
|
||||
public:
|
||||
virtual void* Alloc(unsigned align) = 0;
|
||||
|
||||
template<typename T>
|
||||
T* Alloc(const unsigned align)
|
||||
template<typename T> T* Alloc(const unsigned align)
|
||||
{
|
||||
return static_cast<T*>(Alloc(align));
|
||||
}
|
||||
@ -21,41 +20,38 @@ public:
|
||||
virtual void IncBlockPos(size_t size) = 0;
|
||||
virtual void LoadNullTerminated(void* dst) = 0;
|
||||
|
||||
template<typename T>
|
||||
void Load(T* dst)
|
||||
template<typename T> void Load(T* dst)
|
||||
{
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Load(T* dst, const uint32_t count)
|
||||
template<typename T> void Load(T* dst, const uint32_t count)
|
||||
{
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), count * sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void LoadPartial(T* dst, const size_t size)
|
||||
template<typename T> void LoadPartial(T* dst, const size_t size)
|
||||
{
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), size);
|
||||
}
|
||||
|
||||
virtual void** InsertPointer() = 0;
|
||||
template<typename T>
|
||||
T** InsertPointer()
|
||||
|
||||
template<typename T> T** InsertPointer()
|
||||
{
|
||||
return reinterpret_cast<T**>(InsertPointer());
|
||||
}
|
||||
|
||||
virtual void* ConvertOffsetToPointer(const void* offset) = 0;
|
||||
template<typename T>
|
||||
T* ConvertOffsetToPointer(T* offset)
|
||||
|
||||
template<typename T> T* ConvertOffsetToPointer(T* offset)
|
||||
{
|
||||
return static_cast<T*>(ConvertOffsetToPointer(static_cast<const void*>(offset)));
|
||||
}
|
||||
|
||||
virtual void* ConvertOffsetToAlias(const void* offset) = 0;
|
||||
template<typename T>
|
||||
T* ConvertOffsetToAlias(T* offset)
|
||||
|
||||
template<typename T> T* ConvertOffsetToAlias(T* offset)
|
||||
{
|
||||
return static_cast<T*>(ConvertOffsetToAlias(static_cast<const void*>(offset)));
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "XBlockInputStream.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include "Loading/Exception/BlockOverflowException.h"
|
||||
#include "Loading/Exception/InvalidOffsetBlockException.h"
|
||||
#include "Loading/Exception/InvalidOffsetBlockOffsetException.h"
|
||||
#include "Loading/Exception/OutOfBlockBoundsException.h"
|
||||
|
||||
XBlockInputStream::XBlockInputStream(std::vector<XBlock*>& blocks, ILoadingStream* stream, const int blockBitCount,
|
||||
const block_t insertBlock) : m_blocks(blocks)
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
XBlockInputStream::XBlockInputStream(std::vector<XBlock*>& blocks, ILoadingStream* stream, const int blockBitCount, const block_t insertBlock)
|
||||
: m_blocks(blocks)
|
||||
{
|
||||
m_stream = stream;
|
||||
|
||||
@ -51,7 +51,7 @@ void XBlockInputStream::PushBlock(const block_t block)
|
||||
|
||||
m_block_stack.push(newBlock);
|
||||
|
||||
if(newBlock->m_type == XBlock::Type::BLOCK_TYPE_TEMP)
|
||||
if (newBlock->m_type == XBlock::Type::BLOCK_TYPE_TEMP)
|
||||
{
|
||||
m_temp_offsets.push(m_block_offsets[newBlock->m_index]);
|
||||
}
|
||||
@ -140,7 +140,6 @@ void XBlockInputStream::LoadDataInBlock(void* dst, const size_t size)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
IncBlockPos(size);
|
||||
}
|
||||
|
||||
@ -183,8 +182,7 @@ void XBlockInputStream::LoadNullTerminated(void* dst)
|
||||
|
||||
m_stream->Load(&byte, 1);
|
||||
block->m_buffer[offset++] = byte;
|
||||
}
|
||||
while (byte != 0);
|
||||
} while (byte != 0);
|
||||
|
||||
m_block_offsets[block->m_index] = offset;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/ILoadingStream.h"
|
||||
#include "Zone/Stream/IZoneInputStream.h"
|
||||
#include "Zone/XBlock.h"
|
||||
#include "Loading/ILoadingStream.h"
|
||||
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
class XBlockInputStream final : public IZoneInputStream
|
||||
{
|
||||
@ -39,5 +39,4 @@ public:
|
||||
|
||||
void* ConvertOffsetToPointer(const void* offset) override;
|
||||
void* ConvertOffsetToAlias(const void* offset) override;
|
||||
|
||||
};
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "ZoneLoading.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "Game/IW3/ZoneLoaderFactoryIW3.h"
|
||||
#include "Game/IW4/ZoneLoaderFactoryIW4.h"
|
||||
#include "Game/IW5/ZoneLoaderFactoryIW5.h"
|
||||
@ -11,23 +7,21 @@
|
||||
#include "Game/T6/ZoneLoaderFactoryT6.h"
|
||||
#include "Utils/ObjFileStream.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
IZoneLoaderFactory* ZoneLoaderFactories[]
|
||||
{
|
||||
new IW3::ZoneLoaderFactory(),
|
||||
new IW4::ZoneLoaderFactory(),
|
||||
new IW5::ZoneLoaderFactory(),
|
||||
new T5::ZoneLoaderFactory(),
|
||||
new T6::ZoneLoaderFactory()
|
||||
};
|
||||
IZoneLoaderFactory* ZoneLoaderFactories[]{
|
||||
new IW3::ZoneLoaderFactory(), new IW4::ZoneLoaderFactory(), new IW5::ZoneLoaderFactory(), new T5::ZoneLoaderFactory(), new T6::ZoneLoaderFactory()};
|
||||
|
||||
std::unique_ptr<Zone> ZoneLoading::LoadZone(const std::string& path)
|
||||
{
|
||||
auto zoneName = fs::path(path).filename().replace_extension("").string();
|
||||
std::ifstream file(path, std::fstream::in | std::fstream::binary);
|
||||
|
||||
if(!file.is_open())
|
||||
if (!file.is_open())
|
||||
{
|
||||
printf("Could not open file '%s'.\n", path.c_str());
|
||||
return nullptr;
|
||||
@ -35,22 +29,22 @@ std::unique_ptr<Zone> ZoneLoading::LoadZone(const std::string& path)
|
||||
|
||||
ZoneHeader header{};
|
||||
file.read(reinterpret_cast<char*>(&header), sizeof header);
|
||||
if(file.gcount() != sizeof header)
|
||||
if (file.gcount() != sizeof header)
|
||||
{
|
||||
std::cout << "Failed to read zone header from file '" << path << "'.\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ZoneLoader* zoneLoader = nullptr;
|
||||
for(auto* factory : ZoneLoaderFactories)
|
||||
for (auto* factory : ZoneLoaderFactories)
|
||||
{
|
||||
zoneLoader = factory->CreateLoaderForHeader(header, zoneName);
|
||||
|
||||
if(zoneLoader != nullptr)
|
||||
if (zoneLoader != nullptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if(zoneLoader == nullptr)
|
||||
if (zoneLoader == nullptr)
|
||||
{
|
||||
printf("Could not create factory for zone '%s'.\n", zoneName.c_str());
|
||||
return nullptr;
|
||||
@ -61,4 +55,4 @@ std::unique_ptr<Zone> ZoneLoading::LoadZone(const std::string& path)
|
||||
|
||||
file.close();
|
||||
return std::move(loadedZone);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class ZoneLoading
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user