mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-11-10 10:01:58 +00:00
feat: QOS (007: Quantum of Solace) support (#894)
* feat: QOS (007: Quantum of Solace) support * feat: add qos localize loader * feat: add qos stringtable loader * chore: comment about official zones * fix: add qos gfximage runtime fields * chore: remove useless dev time comments * fix: remove all `static_asserts`s from asset headers causing build fail on x64 * chore: change union ordering of qos `entryInternalData` * chore: move qos asset type enum to qos.h * fix: qos and t4 xsurface index buffer * chore: implement qos MaterialInfo struct * chore: adjust some gfxworld struct members * chore: implement qos PhysPreset and PhysConstraints * chore: fix and adjust slight inconsistencies with qos zone code * chore: reorder qos ZoneCode.lua entries in order of asset type enum * chore: remove asset types that are not actual asset types in zones * chore: check common asset arrays with static_assert * chore: rename qos assets * chore: reorder qos in templates to be in alphabetical order * chore: use function for CopyMipLevel in Dx9TextureLoader * chore: use templates for qos MapEntsDumper * chore: add missing braces in XModelToCommonConverter * chore: add generic way to peek at zone data * Qos does not use a classic ZoneHeader so code needs to be more generic * fix: do not use raw_byte and raw_uint typedefs for qos * fix: not being able to write clipmapmp * chore: additional research on qos vertex property and stuff --------- Co-authored-by: Jan Laupetin <[email protected]>
This commit is contained in:
1 parent
5c0a7257fd
commit
9f49e0e31c
142 files changed
+6000
-97
No files matched your search
@@ -0,0 +1,166 @@
|
||||
#include "ContentLoaderQOS.h"
|
||||
|
||||
#include "Game/QOS/AssetLoaderQOS.h"
|
||||
#include "Loading/Exception/UnsupportedAssetTypeException.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace QOS;
|
||||
|
||||
ContentLoader::ContentLoader(Zone& zone, ZoneInputStream& stream)
|
||||
: ContentLoaderBase(zone, stream),
|
||||
varXAssetList(nullptr),
|
||||
varXAsset(nullptr),
|
||||
varScriptStringList(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
|
||||
{
|
||||
assert(!atStreamStart);
|
||||
|
||||
if (varScriptStringList->strings != nullptr)
|
||||
{
|
||||
assert(GetZonePointerType(varScriptStringList->strings) == ZonePointerType::FOLLOWING);
|
||||
|
||||
#ifdef ARCH_x86
|
||||
varScriptStringList->strings = m_stream.Alloc<const char*>(4);
|
||||
#else
|
||||
varScriptStringList->strings = m_stream.AllocOutOfBlock<const char*>(4, varScriptStringList->count);
|
||||
#endif
|
||||
varXString = varScriptStringList->strings;
|
||||
LoadXStringArray(true, varScriptStringList->count);
|
||||
|
||||
if (varScriptStringList->strings && varScriptStringList->count > 0)
|
||||
m_zone.m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
|
||||
}
|
||||
|
||||
assert(m_zone.m_script_strings.Count() <= SCR_STRING_MAX + 1);
|
||||
}
|
||||
|
||||
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; \
|
||||
}
|
||||
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream.Load<XAsset>(varXAsset);
|
||||
|
||||
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, snd_alias_list_t, sound)
|
||||
LOAD_ASSET(ASSET_TYPE_SND_CURVE, SndCurve, sndCurve)
|
||||
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_GFXWORLD, GfxWorld, gfxWorld)
|
||||
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
|
||||
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
|
||||
LOAD_ASSET(ASSET_TYPE_MENUFILE, 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)
|
||||
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_XMLTREE, XmlTree, xmlTree)
|
||||
LOAD_ASSET(ASSET_TYPE_SCENE_ANIMATION, SceneAnimation, sceneAnimation)
|
||||
LOAD_ASSET(ASSET_TYPE_CUTSCENE, Cutscene, cutscene)
|
||||
LOAD_ASSET(ASSET_TYPE_CUSTOM_CAMERA, CustomCamera, customCamera)
|
||||
|
||||
default:
|
||||
{
|
||||
throw UnsupportedAssetTypeException(varXAsset->type);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOAD_ASSET
|
||||
}
|
||||
|
||||
void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count)
|
||||
{
|
||||
assert(varXAsset != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
{
|
||||
#ifdef ARCH_x86
|
||||
m_stream.Load<XAsset>(varXAsset, count);
|
||||
#else
|
||||
const auto fill = m_stream.LoadWithFill(8u * count);
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
fill.Fill(varXAsset[index].type, 8u * index);
|
||||
fill.FillPtr(varXAsset[index].header.data, 8u * index + 4u);
|
||||
m_stream.AddPointerLookup(&varXAsset[index].header.data, fill.BlockBuffer(8u * index + 4u));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXAsset(false);
|
||||
varXAsset++;
|
||||
|
||||
#ifdef DEBUG_OFFSETS
|
||||
m_stream.DebugOffsets(index);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::Load()
|
||||
{
|
||||
XAssetList assetList{};
|
||||
varXAssetList = &assetList;
|
||||
|
||||
#ifdef ARCH_x86
|
||||
m_stream.LoadDataRaw(&assetList, sizeof(assetList));
|
||||
#else
|
||||
const auto fillAccessor = m_stream.LoadWithFill(16u);
|
||||
varScriptStringList = &varXAssetList->stringList;
|
||||
fillAccessor.Fill(varScriptStringList->count, 0u);
|
||||
fillAccessor.FillPtr(varScriptStringList->strings, 4u);
|
||||
|
||||
fillAccessor.Fill(varXAssetList->assetCount, 8u);
|
||||
fillAccessor.FillPtr(varXAssetList->assets, 12u);
|
||||
#endif
|
||||
|
||||
m_stream.PushBlock(XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
varScriptStringList = &assetList.stringList;
|
||||
LoadScriptStringList(false);
|
||||
|
||||
if (assetList.assets != nullptr)
|
||||
{
|
||||
assert(GetZonePointerType(assetList.assets) == ZonePointerType::FOLLOWING);
|
||||
|
||||
#ifdef ARCH_x86
|
||||
assetList.assets = m_stream.Alloc<XAsset>(4);
|
||||
#else
|
||||
assetList.assets = m_stream.AllocOutOfBlock<XAsset>(4, assetList.assetCount);
|
||||
#endif
|
||||
varXAsset = assetList.assets;
|
||||
LoadXAssetArray(true, assetList.assetCount);
|
||||
}
|
||||
|
||||
m_stream.PopBlock();
|
||||
}
|
||||
Reference in new issue
Block a user