mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Compare commits
104 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0f3ee1fa79 | ||
|
c8cd6826c1 | ||
|
5afc24fd89 | ||
|
598abe095b | ||
|
d6eee273ff | ||
|
7edbe7378b | ||
|
b83bafb0f8 | ||
|
e750e3ffd9 | ||
|
d5b6c6e9c2 | ||
|
d6c1ef775e | ||
|
c05d4ea34e | ||
|
b2d9bf416d | ||
|
3134ec5a37 | ||
|
0d35696940 | ||
|
b215b22018 | ||
|
a447dd29fa | ||
|
985996975b | ||
|
f235798cf6 | ||
|
0228e86980 | ||
|
01302cf061 | ||
|
6f31e8cc29 | ||
|
37d52ae8da | ||
|
481d301545 | ||
|
d3bb99e92c | ||
|
cec70e783f | ||
|
a2c8129a13 | ||
|
e13eb256bb | ||
|
aab510c917 | ||
|
820fe47473 | ||
|
0366b24bd7 | ||
|
49f0794545 | ||
|
20911d552d | ||
|
1748f9e1a5 | ||
|
a37b5fee8c | ||
|
42e2eb80b3 | ||
|
885c57bfa5 | ||
|
fa88b135f9 | ||
|
56c4eeb5cd | ||
|
0fcae6a55a | ||
|
f97f38dc31 | ||
|
95f5dca5e0 | ||
|
f2723255f5 | ||
|
11cb93f736 | ||
|
e40d688e11 | ||
|
2eeb20d1cd | ||
|
7b79504477 | ||
|
4cc7ab77d5 | ||
|
08fb6b0496 | ||
|
a871889c13 | ||
|
81bc21eacf | ||
|
aec779dae5 | ||
|
97c4a23d5e | ||
|
0c587e5e5f | ||
|
4ac38bfc66 | ||
|
34a0bd4f4f | ||
|
047e8aa125 | ||
|
b5303475d9 | ||
|
4adc9115b2 | ||
|
a4347b0b0d | ||
|
4e5c72d79a | ||
|
58f5f66dcf | ||
|
54d19dcc8a | ||
|
f05a21984a | ||
|
b071beea3f | ||
|
548c0c23bf | ||
|
6d186bc09c | ||
|
96dc2c9318 | ||
|
e4c08e1372 | ||
|
1b6824f2bd | ||
|
0eb0383051 | ||
|
222d96a923 | ||
|
07dccbf2f8 | ||
|
b24b6b1979 | ||
|
a220142e86 | ||
|
4c30bd129a | ||
|
3d3a0ca565 | ||
|
903bd5a960 | ||
|
2402d4f9c7 | ||
|
a21b410fd7 | ||
|
2b1ade2b5a | ||
|
d869de5881 | ||
|
2ce1a4e050 | ||
|
89e22329f8 | ||
|
bea601d932 | ||
|
826c1d2f2d | ||
|
0b91eeb932 | ||
|
94ca0ab79e | ||
|
f6d36b2d6e | ||
|
140eb7b7a4 | ||
|
708e759f8c | ||
|
80fa61b45c | ||
|
f436cd6caa | ||
|
4d0b0651eb | ||
|
7a639a359c | ||
|
990bfe27df | ||
|
b4194eff28 | ||
|
8ace49b715 | ||
|
b623ed49a0 | ||
|
0ffbdf5b73 | ||
|
f930c874b8 | ||
|
74f84cbf83 | ||
|
8c453f1683 | ||
|
aa73dca59d | ||
|
a41d15d43a |
@ -177,7 +177,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
||||
| ComWorld | ❌ | ❌ | |
|
||||
| GameWorldSp | ❌ | ❌ | |
|
||||
| GameWorldMp | ❌ | ❌ | |
|
||||
| MapEnts | ❌ | ❌ | |
|
||||
| MapEnts | ✅ | ❌ | |
|
||||
| GfxWorld | ❌ | ❌ | |
|
||||
| GfxLightDef | ❌ | ❌ | |
|
||||
| Font_s | ❌ | ❌ | |
|
||||
|
@ -16,7 +16,7 @@ workspace "OpenAssetTools"
|
||||
objdir "%{wks.location}/obj"
|
||||
symbols "On"
|
||||
systemversion "latest"
|
||||
cppdialect "C++20"
|
||||
cppdialect "C++23"
|
||||
largeaddressaware "on"
|
||||
|
||||
flags {
|
||||
@ -54,6 +54,10 @@ workspace "OpenAssetTools"
|
||||
symbols "On"
|
||||
filter {}
|
||||
|
||||
filter {"system:windows", "configurations:Debug" }
|
||||
buildoptions { "/bigobj" }
|
||||
filter {}
|
||||
|
||||
filter "configurations:Release"
|
||||
defines "NDEBUG"
|
||||
optimize "Full"
|
||||
|
@ -4,4 +4,6 @@
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
make -C build -j$(nproc) config=debug_x86 clean
|
||||
make -C build -j$(nproc) config=release_x86 clean
|
||||
make -C build -j$(nproc) config=release_x86 clean
|
||||
make -C build -j$(nproc) config=debug_x64 clean
|
||||
make -C build -j$(nproc) config=release_x64 clean
|
||||
|
6
scripts/make-debug-x64.sh
Executable file
6
scripts/make-debug-x64.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Go to repository root
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
make -C build -j$(nproc) config=debug_x64 all
|
@ -3,4 +3,4 @@
|
||||
# Go to repository root
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
make -C build -j$(nproc) config=debug_x86 all
|
||||
make -C build -j$(nproc) config=debug_x86 all
|
||||
|
7
scripts/make-release-x64.sh
Executable file
7
scripts/make-release-x64.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Go to repository root
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
echo "Start building with $(nproc) threads"
|
||||
make -C build -j$(nproc) config=release_x64 all
|
@ -4,4 +4,4 @@
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
echo "Start building with $(nproc) threads"
|
||||
make -C build -j$(nproc) config=release_x86 all
|
||||
make -C build -j$(nproc) config=release_x86 all
|
||||
|
@ -3814,7 +3814,8 @@ namespace T6
|
||||
uint16_t dynEntId;
|
||||
};
|
||||
|
||||
union gcc_align(8) __m128
|
||||
// Usually __m128, but that is not portable
|
||||
union gcc_align(8) custom_m128
|
||||
{
|
||||
float m128_f32[4];
|
||||
uint64_t m128_u64[2];
|
||||
@ -3827,19 +3828,12 @@ namespace T6
|
||||
unsigned int m128_u32[4];
|
||||
};
|
||||
|
||||
struct vector3
|
||||
{
|
||||
__m128 x;
|
||||
__m128 y;
|
||||
__m128 z;
|
||||
};
|
||||
|
||||
struct vector4
|
||||
{
|
||||
__m128 x;
|
||||
__m128 y;
|
||||
__m128 z;
|
||||
__m128 w;
|
||||
custom_m128 x;
|
||||
custom_m128 y;
|
||||
custom_m128 z;
|
||||
custom_m128 w;
|
||||
};
|
||||
|
||||
struct type_align(16) SSkinInstance
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
struct ZoneHeader
|
||||
{
|
||||
@ -7,21 +8,11 @@ struct ZoneHeader
|
||||
uint32_t m_version;
|
||||
};
|
||||
|
||||
#ifdef ARCH_x64
|
||||
typedef uint32_t scr_string_t;
|
||||
typedef uint64_t xchunk_size_t;
|
||||
typedef uint64_t xblock_size_t;
|
||||
typedef uint64_t zone_pointer_t;
|
||||
|
||||
constexpr uint16_t SCR_STRING_MAX = UINT32_MAX;
|
||||
#elif ARCH_x86
|
||||
typedef uint16_t scr_string_t;
|
||||
typedef uint32_t xchunk_size_t;
|
||||
typedef uint32_t xblock_size_t;
|
||||
typedef uint32_t zone_pointer_t;
|
||||
|
||||
constexpr uint16_t SCR_STRING_MAX = UINT16_MAX;
|
||||
#endif
|
||||
constexpr uint16_t SCR_STRING_MAX = std::numeric_limits<scr_string_t>::max();
|
||||
|
||||
typedef int block_t;
|
||||
typedef int asset_type_t;
|
||||
|
@ -32,7 +32,8 @@ namespace base64
|
||||
|
||||
size_t DecodeBase64(const void* base64Data, const size_t inputLength, void* outputBuffer, const size_t outputBufferSize)
|
||||
{
|
||||
unsigned long outLength = GetBase64DecodeOutputLength(inputLength);
|
||||
unsigned long outLength = GetBase64DecodeOutputLength(base64Data, inputLength);
|
||||
assert(outLength <= outputBufferSize);
|
||||
if (outLength > outputBufferSize)
|
||||
return 0u;
|
||||
|
||||
@ -42,8 +43,28 @@ namespace base64
|
||||
return static_cast<size_t>(outLength);
|
||||
}
|
||||
|
||||
size_t GetBase64DecodeOutputLength(const void* base64Data, const size_t inputLength)
|
||||
{
|
||||
assert(base64Data);
|
||||
assert(inputLength);
|
||||
|
||||
if (!base64Data || inputLength == 0u)
|
||||
return 0u;
|
||||
|
||||
auto padding = 0u;
|
||||
if (inputLength >= 1 && static_cast<const char*>(base64Data)[inputLength - 1] == '=')
|
||||
{
|
||||
if (inputLength >= 2 && static_cast<const char*>(base64Data)[inputLength - 2] == '=')
|
||||
padding = 2u;
|
||||
else
|
||||
padding = 1u;
|
||||
}
|
||||
|
||||
return ((inputLength / 4u) * 3u) - padding;
|
||||
}
|
||||
|
||||
size_t GetBase64DecodeOutputLength(const size_t inputLength)
|
||||
{
|
||||
return inputLength / 4u;
|
||||
return (inputLength / 4u) * 3u;
|
||||
}
|
||||
} // namespace base64
|
||||
|
@ -8,5 +8,6 @@ namespace base64
|
||||
size_t GetBase64EncodeOutputLength(size_t inputLength);
|
||||
|
||||
size_t DecodeBase64(const void* base64Data, size_t inputLength, void* outputBuffer, size_t outputBufferSize);
|
||||
size_t GetBase64DecodeOutputLength(const void* base64Data, const size_t inputLength);
|
||||
size_t GetBase64DecodeOutputLength(size_t inputLength);
|
||||
} // namespace base64
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "SearchPath/IWD.h"
|
||||
#include "SearchPath/SearchPathFilesystem.h"
|
||||
#include "SearchPath/SearchPaths.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
@ -215,7 +216,10 @@ namespace
|
||||
{
|
||||
if (!curTemplate.CanRender(PROJECT_MASK) && curTemplate.CanRender(GAME_MASK))
|
||||
{
|
||||
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, GameId_Names[static_cast<unsigned>(game)]);
|
||||
std::string gameName(GameId_Names[static_cast<unsigned>(game)]);
|
||||
utils::MakeStringLowerCase(gameName);
|
||||
|
||||
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, gameName);
|
||||
if (AddSearchPath(addedSearchPaths, searchPaths, renderedTemplate))
|
||||
hasSearchPath = true;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace ipak_consts
|
||||
static constexpr size_t IPAK_CHUNK_SIZE = 0x8000;
|
||||
static constexpr size_t IPAK_CHUNK_COUNT_PER_READ = 0x8;
|
||||
|
||||
static constexpr uint32_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
||||
static constexpr size_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
||||
static constexpr uint32_t IPAK_COMMAND_UNCOMPRESSED = 0;
|
||||
static constexpr uint32_t IPAK_COMMAND_COMPRESSED = 1;
|
||||
static constexpr uint32_t IPAK_COMMAND_SKIP = 0xCF;
|
||||
|
@ -68,7 +68,7 @@ namespace
|
||||
T result;
|
||||
} data{};
|
||||
|
||||
const auto byteCount = utils::Align(bitCount, 8u) / 8u;
|
||||
const auto byteCount = utils::Align(bitCount, 8uz) / 8uz;
|
||||
assert(byteCount <= sizeof(T));
|
||||
|
||||
const auto shiftCount = (8u - bitCount % 8) % 8;
|
||||
@ -83,7 +83,7 @@ namespace
|
||||
|
||||
while (remainingBits > 0)
|
||||
{
|
||||
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8u));
|
||||
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8uz));
|
||||
|
||||
if (m_remaining_bits_last_byte > 0)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
||||
return 0u;
|
||||
}
|
||||
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
|
||||
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8u);
|
||||
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8uz);
|
||||
}
|
||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||
{
|
||||
@ -69,7 +69,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
||||
return 0u;
|
||||
}
|
||||
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
|
||||
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8u);
|
||||
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8uz);
|
||||
}
|
||||
|
||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||
|
@ -216,7 +216,7 @@ namespace
|
||||
const auto remainingSize = dataSize - dataOffset;
|
||||
const auto remainingChunkBufferWindowSize = std::max((ipak_consts::IPAK_CHUNK_COUNT_PER_READ * ipak_consts::IPAK_CHUNK_SIZE)
|
||||
- static_cast<size_t>(m_current_offset - m_chunk_buffer_window_start),
|
||||
0u);
|
||||
0uz);
|
||||
|
||||
if (remainingChunkBufferWindowSize == 0)
|
||||
{
|
||||
|
@ -184,7 +184,11 @@ namespace dds
|
||||
m_width = header.dwWidth;
|
||||
m_height = header.dwHeight;
|
||||
m_depth = header.dwDepth;
|
||||
m_has_mip_maps = (header.dwCaps & DDSCAPS_MIPMAP) != 0 || header.dwMipMapCount > 1;
|
||||
|
||||
// Best thing to do here would be to check (header.dwCaps & DDSCAPS_MIPMAP) != 0 but some tools just create bad files
|
||||
// I encountered both files that have the flag without them actually having mipmaps (mipMapCount == 1)
|
||||
// and also files that have mipMapCount > 1 but not the flag
|
||||
m_has_mip_maps = header.dwMipMapCount > 1;
|
||||
|
||||
if (header.dwCaps2 & DDSCAPS2_CUBEMAP)
|
||||
m_texture_type = TextureType::T_CUBE;
|
||||
|
@ -65,8 +65,10 @@ std::unique_ptr<XAssetInfoGeneric> GenericAssetRegistration::CreateXAssetInfo()
|
||||
AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup)
|
||||
: ZoneAssetCreationStateContainer(zone),
|
||||
m_zone(zone),
|
||||
m_forced_asset_pools(ZoneAssetPools::CreateForGame(zone.m_game->GetId(), &zone, zone.m_priority)),
|
||||
m_creators(creators),
|
||||
m_ignored_asset_lookup(ignoredAssetLookup)
|
||||
m_ignored_asset_lookup(ignoredAssetLookup),
|
||||
m_forced_load_depth(0u)
|
||||
{
|
||||
}
|
||||
|
||||
@ -78,10 +80,14 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio
|
||||
const auto assetType = xAssetInfo->m_type;
|
||||
const auto* pAssetName = xAssetInfo->m_name.c_str();
|
||||
|
||||
auto* addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
||||
XAssetInfoGeneric* addedAsset;
|
||||
if (m_forced_load_depth > 0)
|
||||
addedAsset = m_forced_asset_pools->AddAsset(std::move(xAssetInfo));
|
||||
else
|
||||
addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
||||
|
||||
if (addedAsset == nullptr)
|
||||
std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
|
||||
|
||||
return addedAsset;
|
||||
}
|
||||
|
||||
@ -102,6 +108,16 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
||||
if (alreadyLoadedAsset)
|
||||
return alreadyLoadedAsset;
|
||||
|
||||
if (m_forced_load_depth > 0)
|
||||
{
|
||||
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset)
|
||||
return alreadyLoadedAsset;
|
||||
|
||||
// If we are already force loading an asset we should not load its dependencies
|
||||
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||
}
|
||||
|
||||
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||
|
||||
@ -121,9 +137,9 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName)
|
||||
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||
{
|
||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
const auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset)
|
||||
return IndirectAssetReference(assetType, assetName);
|
||||
|
||||
@ -137,3 +153,44 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(a
|
||||
}
|
||||
return IndirectAssetReference(assetType, assetName);
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||
{
|
||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||
return alreadyLoadedAsset;
|
||||
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||
return alreadyLoadedAsset;
|
||||
|
||||
auto result = AssetCreationResult::NoAction();
|
||||
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||
{
|
||||
// Load default asset to zone
|
||||
if (!LoadDefaultAssetDependency(assetType, std::format(",{}", assetName)))
|
||||
return nullptr;
|
||||
|
||||
++m_forced_load_depth;
|
||||
|
||||
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||
|
||||
assert(m_forced_load_depth > 0);
|
||||
m_forced_load_depth = std::min(m_forced_load_depth - 1u, 0u);
|
||||
}
|
||||
else
|
||||
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||
|
||||
if (result.HasTakenAction())
|
||||
{
|
||||
if (!result.HasFailed())
|
||||
return result.GetAssetInfo();
|
||||
|
||||
std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -65,12 +65,31 @@ public:
|
||||
|
||||
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
|
||||
|
||||
/**
|
||||
* \brief Loads an asset dependency like \c LoadDependency but guarantees that the returned asset is not a reference.
|
||||
* If normally a reference would be created, the actual asset is loaded but a reference is added to the zone.
|
||||
* \tparam AssetType The type of the asset
|
||||
* \param assetName The name of the asset
|
||||
* \return XAssetInfo of the asset that is guaranteed to not be a reference or \c nullptr
|
||||
*/
|
||||
template<typename AssetType> XAssetInfo<typename AssetType::Type>* ForceLoadDependency(const std::string& assetName)
|
||||
{
|
||||
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||
|
||||
return static_cast<XAssetInfo<typename AssetType::Type>*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName));
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName);
|
||||
|
||||
private:
|
||||
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
|
||||
|
||||
Zone& m_zone;
|
||||
std::unique_ptr<ZoneAssetPools> m_forced_asset_pools;
|
||||
const AssetCreatorCollection* m_creators;
|
||||
const IgnoredAssetLookup* m_ignored_asset_lookup;
|
||||
|
||||
unsigned m_forced_load_depth;
|
||||
};
|
||||
|
||||
#include "AssetCreatorCollection.h"
|
||||
|
@ -96,7 +96,6 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
|
@ -135,8 +135,7 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||
collection.AddAssetCreator(CreateSoundCurveLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapSp>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapMp>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldMp>(memory));
|
||||
|
@ -53,15 +53,15 @@ namespace
|
||||
case CommonStructuredDataTypeCategory::SHORT:
|
||||
return {DATA_SHORT, {0}};
|
||||
case CommonStructuredDataTypeCategory::STRING:
|
||||
return {DATA_STRING, {inputType.m_info.string_length}};
|
||||
return {DATA_STRING, {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||
case CommonStructuredDataTypeCategory::ENUM:
|
||||
return {DATA_ENUM, {inputType.m_info.type_index}};
|
||||
return {DATA_ENUM, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::STRUCT:
|
||||
return {DATA_STRUCT, {inputType.m_info.type_index}};
|
||||
return {DATA_STRUCT, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
||||
return {DATA_INDEXED_ARRAY, {inputType.m_info.type_index}};
|
||||
return {DATA_INDEXED_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||
return {DATA_ENUM_ARRAY, {inputType.m_info.type_index}};
|
||||
return {DATA_ENUM_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||
default:
|
||||
assert(false);
|
||||
@ -129,14 +129,14 @@ namespace
|
||||
{
|
||||
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
||||
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8u) / 8u;
|
||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
}
|
||||
|
||||
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
||||
{
|
||||
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
||||
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8u) / 8u;
|
||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
}
|
||||
|
||||
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
||||
|
@ -109,7 +109,6 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImage>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundBank>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
|
@ -404,7 +404,6 @@ namespace T6
|
||||
collection.AddAssetCreator(CreateImageLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateSoundBankLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
|
@ -262,7 +262,7 @@ namespace
|
||||
|
||||
for (const auto& attachmentName : valueArray)
|
||||
{
|
||||
auto* attachmentAssetInfo = m_context.LoadDependency<AssetAttachment>(attachmentName);
|
||||
auto* attachmentAssetInfo = m_context.ForceLoadDependency<AssetAttachment>(attachmentName);
|
||||
if (attachmentAssetInfo == nullptr)
|
||||
{
|
||||
std::cerr << std::format("Failed to load attachment asset \"{}\"\n", attachmentName);
|
||||
@ -314,7 +314,7 @@ namespace
|
||||
|
||||
for (const auto& attachmentUniqueName : valueArray)
|
||||
{
|
||||
auto* attachmentUniqueAssetInfo = m_context.LoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
||||
auto* attachmentUniqueAssetInfo = m_context.ForceLoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
||||
if (attachmentUniqueAssetInfo == nullptr)
|
||||
{
|
||||
std::cerr << std::format("Failed to load attachment unique asset \"{}\"\n", attachmentUniqueName);
|
||||
|
@ -131,7 +131,7 @@ public:
|
||||
sizeof(SoundAssetBankEntry),
|
||||
sizeof(SoundAssetBankChecksum),
|
||||
0x40,
|
||||
m_entries.size(),
|
||||
static_cast<unsigned>(m_entries.size()),
|
||||
0,
|
||||
0,
|
||||
m_total_size,
|
||||
@ -157,9 +157,9 @@ public:
|
||||
|
||||
SoundAssetBankEntry entry{
|
||||
sound.m_sound_id,
|
||||
soundSize,
|
||||
static_cast<size_t>(m_current_offset),
|
||||
frameCount,
|
||||
static_cast<unsigned>(soundSize),
|
||||
static_cast<unsigned>(m_current_offset),
|
||||
static_cast<unsigned>(frameCount),
|
||||
frameRateIndex,
|
||||
static_cast<unsigned char>(header.formatChunk.nChannels),
|
||||
sound.m_looping,
|
||||
@ -188,8 +188,8 @@ public:
|
||||
const auto frameRateIndex = INDEX_FOR_FRAMERATE[metaData.m_sample_rate];
|
||||
SoundAssetBankEntry entry{
|
||||
sound.m_sound_id,
|
||||
soundSize,
|
||||
static_cast<size_t>(m_current_offset),
|
||||
static_cast<unsigned>(soundSize),
|
||||
static_cast<unsigned>(m_current_offset),
|
||||
static_cast<unsigned>(metaData.m_total_samples),
|
||||
frameRateIndex,
|
||||
metaData.m_number_of_channels,
|
||||
|
@ -240,7 +240,7 @@ namespace sdd::struct_scope_sequences
|
||||
if (state->m_current_struct_is_root && state->m_current_struct->m_properties.empty())
|
||||
state->m_current_struct_padding_offset -= 64u;
|
||||
|
||||
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8u) / 8;
|
||||
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8uz) / 8;
|
||||
state->m_current_struct_padding_offset = 0u;
|
||||
state->m_current_struct_is_root = false;
|
||||
state->m_current_struct = nullptr;
|
||||
|
@ -74,7 +74,7 @@ class StructuredDataDefSizeCalculatorInternal
|
||||
|
||||
m_type_stack.emplace_back(CommonStructuredDataTypeCategory::STRUCT, index);
|
||||
|
||||
auto currentOffset = 0u;
|
||||
auto currentOffset = 0uz;
|
||||
for (auto& property : _struct.m_properties)
|
||||
{
|
||||
CalculateForType(property.m_type);
|
||||
@ -85,7 +85,7 @@ class StructuredDataDefSizeCalculatorInternal
|
||||
|
||||
currentOffset += property.m_type.GetSizeInBits(m_def);
|
||||
}
|
||||
currentOffset = utils::Align(currentOffset, 8u);
|
||||
currentOffset = utils::Align(currentOffset, 8uz);
|
||||
_struct.m_size_in_byte += currentOffset / 8;
|
||||
|
||||
m_struct_calculated[index] = true;
|
||||
|
@ -286,7 +286,7 @@ namespace
|
||||
|
||||
common.m_vertices.emplace_back(vertex);
|
||||
|
||||
XModelVertexBoneWeights vertexWeights{common.m_bone_weight_data.weights.size(), 0u};
|
||||
XModelVertexBoneWeights vertexWeights{.weightOffset = static_cast<unsigned>(common.m_bone_weight_data.weights.size()), .weightCount = 0u};
|
||||
for (auto i = 0u; i < std::extent_v<decltype(joints)>; i++)
|
||||
{
|
||||
if (std::abs(weights[i]) < std::numeric_limits<float>::epsilon())
|
||||
@ -315,12 +315,12 @@ namespace
|
||||
throw GltfLoadException("Requires primitives attribute POSITION");
|
||||
|
||||
AccessorsForVertex accessorsForVertex{
|
||||
*primitives.attributes.POSITION,
|
||||
primitives.attributes.NORMAL,
|
||||
primitives.attributes.COLOR_0,
|
||||
primitives.attributes.TEXCOORD_0,
|
||||
primitives.attributes.JOINTS_0,
|
||||
primitives.attributes.WEIGHTS_0,
|
||||
.positionAccessor = *primitives.attributes.POSITION,
|
||||
.normalAccessor = primitives.attributes.NORMAL,
|
||||
.colorAccessor = primitives.attributes.COLOR_0,
|
||||
.uvAccessor = primitives.attributes.TEXCOORD_0,
|
||||
.jointsAccessor = primitives.attributes.JOINTS_0,
|
||||
.weightsAccessor = primitives.attributes.WEIGHTS_0,
|
||||
};
|
||||
|
||||
const auto existingVertices = m_vertex_offset_for_accessors.find(accessorsForVertex);
|
||||
@ -328,7 +328,7 @@ namespace
|
||||
existingVertices == m_vertex_offset_for_accessors.end() ? CreateVertices(common, accessorsForVertex) : existingVertices->second;
|
||||
|
||||
// clang-format off
|
||||
auto* indexAccessor = GetAccessorForIndex(
|
||||
const auto* indexAccessor = GetAccessorForIndex(
|
||||
"INDICES",
|
||||
primitives.indices,
|
||||
{JsonAccessorType::SCALAR},
|
||||
@ -547,15 +547,12 @@ namespace
|
||||
if (!jRoot.nodes)
|
||||
return false;
|
||||
|
||||
if (!common.m_bones.empty())
|
||||
throw GltfLoadException("Only scenes with at most one skin are supported");
|
||||
|
||||
const auto rootNode = GetRootNodeForSkin(jRoot, skin).value_or(skin.joints[0]);
|
||||
const auto skinBoneOffset = common.m_bones.size();
|
||||
common.m_bones.resize(skinBoneOffset + skin.joints.size());
|
||||
|
||||
constexpr float defaultTranslation[3]{0.0f, 0.0f, 0.0f};
|
||||
constexpr XModelQuaternion defaultRotation{0.0f, 0.0f, 0.0f, 1.0f};
|
||||
constexpr XModelQuaternion defaultRotation{.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f};
|
||||
constexpr float defaultScale[3]{1.0f, 1.0f, 1.0f};
|
||||
|
||||
return ConvertJoint(jRoot, skin, common, skinBoneOffset, rootNode, std::nullopt, defaultTranslation, defaultRotation, defaultScale);
|
||||
@ -566,13 +563,27 @@ namespace
|
||||
if (!jRoot.meshes)
|
||||
return;
|
||||
|
||||
std::optional<unsigned> alreadyLoadedSkinIndex;
|
||||
|
||||
for (const auto& loadObject : m_load_objects)
|
||||
{
|
||||
if (loadObject.skinIndex && jRoot.skins)
|
||||
{
|
||||
const auto& skin = jRoot.skins.value()[*loadObject.skinIndex];
|
||||
if (!ConvertSkin(jRoot, skin, common))
|
||||
return;
|
||||
if (alreadyLoadedSkinIndex)
|
||||
{
|
||||
if (*alreadyLoadedSkinIndex != *loadObject.skinIndex)
|
||||
throw GltfLoadException("Only scenes with at most one skin are supported");
|
||||
|
||||
// Do not load already loaded skin
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& skin = jRoot.skins.value()[*loadObject.skinIndex];
|
||||
if (!ConvertSkin(jRoot, skin, common))
|
||||
return;
|
||||
|
||||
alreadyLoadedSkinIndex = *loadObject.skinIndex;
|
||||
}
|
||||
}
|
||||
|
||||
const auto& mesh = jRoot.meshes.value()[loadObject.meshIndex];
|
||||
|
@ -48,11 +48,12 @@ bool DataUriBuffer::ReadDataFromUri(const std::string& uri)
|
||||
if (!IsDataUri(uri))
|
||||
return false;
|
||||
|
||||
const auto base64Data = &uri[URI_PREFIX_LENGTH];
|
||||
const auto base64DataLength = uri.size() - URI_PREFIX_LENGTH;
|
||||
m_data_size = base64::GetBase64DecodeOutputLength(base64DataLength);
|
||||
m_data_size = base64::GetBase64DecodeOutputLength(base64Data, base64DataLength);
|
||||
m_data = std::make_unique<uint8_t[]>(m_data_size);
|
||||
|
||||
m_data_size = base64::DecodeBase64(&uri[URI_PREFIX_LENGTH], base64DataLength, m_data.get(), m_data_size);
|
||||
m_data_size = base64::DecodeBase64(base64Data, base64DataLength, m_data.get(), m_data_size);
|
||||
|
||||
return m_data_size > 0;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include JSON_HEADER
|
||||
|
||||
#include "Asset/AssetRegistration.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Utils/QuatInt16.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
#include "XModel/Gltf/GltfBinInput.h"
|
||||
@ -44,7 +43,6 @@
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
using namespace GAME;
|
||||
@ -146,17 +144,17 @@ namespace
|
||||
assert(common.m_vertex_bone_weights.size() == common.m_vertices.size());
|
||||
|
||||
XModelBone rootBone{
|
||||
"root",
|
||||
std::nullopt,
|
||||
{1.0f, 1.0f, 1.0f},
|
||||
{0.0f, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 0.0f, 1.0f},
|
||||
.name = "root",
|
||||
.parentIndex = std::nullopt,
|
||||
.scale = {1.0f, 1.0f, 1.0f},
|
||||
.globalOffset = {0.0f, 0.0f, 0.0f},
|
||||
.localOffset = {0.0f, 0.0f, 0.0f},
|
||||
.globalRotation = {.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f},
|
||||
.localRotation = {.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f},
|
||||
};
|
||||
common.m_bones.emplace_back(rootBone);
|
||||
|
||||
XModelBoneWeight rootWeight{0, 1.0f};
|
||||
|
||||
XModelBoneWeight rootWeight{.boneIndex = 0, .weight = 1.0f};
|
||||
common.m_bone_weight_data.weights.emplace_back(rootWeight);
|
||||
|
||||
for (auto& vertexBoneWeights : common.m_vertex_bone_weights)
|
||||
@ -401,7 +399,7 @@ namespace
|
||||
}
|
||||
|
||||
static std::vector<std::optional<size_t>>
|
||||
GetRigidBoneIndicesForTris(const std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common)
|
||||
GetRigidBoneIndicesForTris(const std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
|
||||
{
|
||||
std::vector<std::optional<size_t>> rigidBoneIndexForTri;
|
||||
rigidBoneIndexForTri.reserve(surface.triCount);
|
||||
@ -422,7 +420,7 @@ namespace
|
||||
return rigidBoneIndexForTri;
|
||||
}
|
||||
|
||||
static void ReorderRigidTrisByBoneIndex(const std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common)
|
||||
static void ReorderRigidTrisByBoneIndex(const std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
|
||||
{
|
||||
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(vertexIndices, surface, common);
|
||||
|
||||
@ -456,17 +454,17 @@ namespace
|
||||
surface.partBits[partBitsIndex] |= 1 << shiftValue;
|
||||
}
|
||||
|
||||
void CreateVertListData(XSurface& surface, const std::vector<size_t>& vertexIndices, const XModelCommon& common) const
|
||||
void CreateVertListData(XSurface& surface, const std::vector<size_t>& xmodelToCommonVertexIndexLookup, const XModelCommon& common) const
|
||||
{
|
||||
ReorderRigidTrisByBoneIndex(vertexIndices, surface, common);
|
||||
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(vertexIndices, surface, common);
|
||||
ReorderRigidTrisByBoneIndex(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
|
||||
std::vector<XRigidVertList> vertLists;
|
||||
|
||||
auto currentVertexTail = 0u;
|
||||
auto currentTriTail = 0u;
|
||||
|
||||
const auto vertexCount = vertexIndices.size();
|
||||
const auto vertexCount = xmodelToCommonVertexIndexLookup.size();
|
||||
const auto triCount = static_cast<size_t>(surface.triCount);
|
||||
const auto boneCount = common.m_bones.size();
|
||||
for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++)
|
||||
@ -475,7 +473,7 @@ namespace
|
||||
boneVertList.boneOffset = static_cast<uint16_t>(boneIndex * sizeof(DObjSkelMat));
|
||||
|
||||
auto currentVertexHead = currentVertexTail;
|
||||
while (currentVertexHead < vertexCount && GetRigidBoneForVertex(currentVertexHead, common) == boneIndex)
|
||||
while (currentVertexHead < vertexCount && GetRigidBoneForVertex(xmodelToCommonVertexIndexLookup[currentVertexHead], common) == boneIndex)
|
||||
currentVertexHead++;
|
||||
|
||||
auto currentTriHead = currentTriTail;
|
||||
@ -512,7 +510,7 @@ namespace
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void ReorderVerticesByWeightCount(std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common)
|
||||
static void ReorderVerticesByWeightCount(std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
|
||||
{
|
||||
if (common.m_bone_weight_data.weights.empty())
|
||||
return;
|
||||
@ -541,13 +539,21 @@ namespace
|
||||
return false;
|
||||
});
|
||||
|
||||
std::vector<XSurfaceTri> preSortTris(surface.triCount);
|
||||
std::memcpy(preSortTris.data(), surface.triIndices, sizeof(XSurfaceTri) * surface.triCount);
|
||||
|
||||
std::vector<size_t> reverseLookup(reorderLookup.size());
|
||||
for (auto i = 0u; i < reverseLookup.size(); i++)
|
||||
reverseLookup[reorderLookup[i]] = i;
|
||||
|
||||
for (auto triIndex = 0u; triIndex < surface.triCount; triIndex++)
|
||||
{
|
||||
const auto& preSortTriIndices = preSortTris[triIndex];
|
||||
auto& triIndices = surface.triIndices[triIndex];
|
||||
|
||||
triIndices.i[0] = static_cast<uint16_t>(reorderLookup[triIndices.i[0]]);
|
||||
triIndices.i[1] = static_cast<uint16_t>(reorderLookup[triIndices.i[1]]);
|
||||
triIndices.i[2] = static_cast<uint16_t>(reorderLookup[triIndices.i[2]]);
|
||||
triIndices.i[0] = static_cast<uint16_t>(reverseLookup[preSortTriIndices.i[0]]);
|
||||
triIndices.i[1] = static_cast<uint16_t>(reverseLookup[preSortTriIndices.i[1]]);
|
||||
triIndices.i[2] = static_cast<uint16_t>(reverseLookup[preSortTriIndices.i[2]]);
|
||||
}
|
||||
|
||||
for (auto& entry : reorderLookup)
|
||||
@ -572,6 +578,7 @@ namespace
|
||||
surface.triCount = static_cast<uint16_t>(commonObject.m_faces.size());
|
||||
surface.triIndices = m_memory.Alloc<XSurfaceTri>(surface.triCount);
|
||||
|
||||
xmodelToCommonVertexIndexLookup.reserve(static_cast<size_t>(surface.triCount) * std::extent_v<decltype(XModelFace::vertexIndex)>);
|
||||
for (auto faceIndex = 0u; faceIndex < surface.triCount; faceIndex++)
|
||||
{
|
||||
const auto& face = commonObject.m_faces[faceIndex];
|
||||
@ -594,8 +601,6 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
ReorderVerticesByWeightCount(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
|
||||
constexpr auto maxVertices = std::numeric_limits<decltype(XSurface::vertCount)>::max();
|
||||
if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVertices)
|
||||
{
|
||||
@ -603,6 +608,8 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
ReorderVerticesByWeightCount(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
|
||||
surface.baseVertIndex = static_cast<uint16_t>(vertexOffset);
|
||||
surface.vertCount = static_cast<uint16_t>(xmodelToCommonVertexIndexLookup.size());
|
||||
surface.verts0 = m_memory.Alloc<GfxPackedVertex>(surface.vertCount);
|
||||
|
@ -284,7 +284,7 @@ namespace
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -301,7 +301,7 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
@ -313,8 +313,8 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
@ -330,10 +330,10 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
@ -350,12 +350,12 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
|
@ -34,7 +34,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
|
||||
DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
|
@ -37,22 +37,22 @@ CommonStructuredDataType AssetDumperStructuredDataDefSet::ConvertType(const Comm
|
||||
case DATA_ENUM:
|
||||
assert(!def->m_enums.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::ENUM;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumIndex), def->m_enums.size() - 1u), 0u);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumIndex), def->m_enums.size() - 1uz), 0uz);
|
||||
break;
|
||||
case DATA_STRUCT:
|
||||
assert(!def->m_structs.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::STRUCT;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.structIndex), def->m_structs.size() - 1u), 0u);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.structIndex), def->m_structs.size() - 1uz), 0uz);
|
||||
break;
|
||||
case DATA_INDEXED_ARRAY:
|
||||
assert(!def->m_indexed_arrays.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::INDEXED_ARRAY;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1u), 0u);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1uz), 0uz);
|
||||
break;
|
||||
case DATA_ENUM_ARRAY:
|
||||
assert(!def->m_enumed_arrays.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::ENUM_ARRAY;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1u), 0u);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1uz), 0uz);
|
||||
break;
|
||||
case DATA_COUNT:
|
||||
default:
|
||||
@ -138,7 +138,7 @@ void AssetDumperStructuredDataDefSet::ConvertEnumedArray(const CommonStructuredD
|
||||
assert(!def->m_enums.empty());
|
||||
out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8;
|
||||
out->m_array_type = ConvertType(def, in->elementType);
|
||||
out->m_enum_index = std::max(std::min(static_cast<size_t>(in->enumIndex), def->m_enums.size() - 1u), 0u);
|
||||
out->m_enum_index = std::max(std::min(static_cast<size_t>(in->enumIndex), def->m_enums.size() - 1uz), 0uz);
|
||||
|
||||
if (def->m_enums.empty())
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ namespace
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -284,7 +284,7 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
@ -296,8 +296,8 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
@ -313,10 +313,10 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
@ -333,12 +333,12 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
|
@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||
DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
|
||||
DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
|
@ -35,7 +35,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
|
23
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.cpp
Normal file
23
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "AssetDumperMapEnts.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
bool AssetDumperMapEnts::ShouldDump(XAssetInfo<MapEnts>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
|
||||
{
|
||||
const auto* mapEnts = asset->Asset();
|
||||
|
||||
const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name));
|
||||
|
||||
if (!mapEntsFile)
|
||||
return;
|
||||
|
||||
auto& stream = *mapEntsFile;
|
||||
stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1);
|
||||
}
|
14
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.h
Normal file
14
src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperMapEnts final : public AbstractAssetDumper<MapEnts>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<MapEnts>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset) override;
|
||||
};
|
||||
} // namespace T6
|
@ -110,7 +110,7 @@ namespace
|
||||
"devraw/",
|
||||
};
|
||||
|
||||
constexpr size_t FRAME_RATE_FOR_INDEX[]{
|
||||
constexpr unsigned FRAME_RATE_FOR_INDEX[]{
|
||||
8000,
|
||||
12000,
|
||||
16000,
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||
#include "AssetDumpers/AssetDumperLeaderboardDef.h"
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
#include "AssetDumpers/AssetDumperMapEnts.h"
|
||||
#include "AssetDumpers/AssetDumperMaterial.h"
|
||||
#include "AssetDumpers/AssetDumperPhysConstraints.h"
|
||||
#include "AssetDumpers/AssetDumperPhysPreset.h"
|
||||
@ -49,11 +50,11 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE)
|
||||
DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||
DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
|
||||
|
@ -27,7 +27,7 @@ void WavWriter::WritePcmHeader(const WavMetaData& metaData, const size_t dataLen
|
||||
};
|
||||
m_stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
|
||||
|
||||
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, dataLen};
|
||||
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, static_cast<unsigned>(dataLen)};
|
||||
m_stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void StructuredDataDefDumper::DumpType(const CommonStructuredDataDef& def,
|
||||
|
||||
void StructuredDataDefDumper::DumpProperty(const CommonStructuredDataDef& def,
|
||||
const CommonStructuredDataStructProperty& property,
|
||||
unsigned& currentOffsetInBit) const
|
||||
size_t& currentOffsetInBit) const
|
||||
{
|
||||
std::string typeName;
|
||||
std::vector<std::string> arraySpecifiers;
|
||||
@ -205,11 +205,11 @@ void StructuredDataDefDumper::DumpStruct(const CommonStructuredDataDef& def, con
|
||||
IncIndent();
|
||||
|
||||
auto currentOffsetInBit =
|
||||
def.m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT && def.m_root_type.m_info.type_index == structIndex ? 64u : 0u;
|
||||
def.m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT && def.m_root_type.m_info.type_index == structIndex ? 64uz : 0uz;
|
||||
for (const auto& property : _struct.m_properties)
|
||||
DumpProperty(def, property, currentOffsetInBit);
|
||||
|
||||
currentOffsetInBit = utils::Align(currentOffsetInBit, 8u);
|
||||
currentOffsetInBit = utils::Align(currentOffsetInBit, 8uz);
|
||||
if ((currentOffsetInBit / 8) < _struct.m_size_in_byte)
|
||||
{
|
||||
Indent();
|
||||
|
@ -17,7 +17,7 @@ class StructuredDataDefDumper : AbstractTextDumper
|
||||
|
||||
void DumpEnum(const CommonStructuredDataEnum& _enum);
|
||||
void DumpType(const CommonStructuredDataDef& def, CommonStructuredDataType type, std::string& typeName, std::vector<std::string>& arraySpecifiers) const;
|
||||
void DumpProperty(const CommonStructuredDataDef& def, const CommonStructuredDataStructProperty& property, unsigned& currentOffsetInBit) const;
|
||||
void DumpProperty(const CommonStructuredDataDef& def, const CommonStructuredDataStructProperty& property, size_t& currentOffsetInBit) const;
|
||||
void DumpStruct(const CommonStructuredDataDef& def, const CommonStructuredDataStruct& _struct, size_t structIndex);
|
||||
|
||||
public:
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <Eigen>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
|
||||
using namespace gltf;
|
||||
@ -41,13 +42,13 @@ namespace
|
||||
|
||||
CreateJsonAsset(gltf.asset);
|
||||
CreateSkeletonNodes(gltf, xmodel);
|
||||
CreateMeshNode(gltf, xmodel);
|
||||
CreateMeshNodes(gltf, xmodel);
|
||||
CreateRootNode(gltf, xmodel);
|
||||
CreateMaterials(gltf, xmodel);
|
||||
CreateBufferViews(gltf, xmodel);
|
||||
CreateAccessors(gltf, xmodel);
|
||||
CreateSkin(gltf, xmodel);
|
||||
CreateMesh(gltf, xmodel);
|
||||
CreateMeshes(gltf, xmodel);
|
||||
CreateScene(gltf, xmodel);
|
||||
FillBufferData(gltf, xmodel, bufferData);
|
||||
CreateBuffer(gltf, xmodel, bufferData);
|
||||
@ -68,39 +69,44 @@ namespace
|
||||
asset.generator = GLTF_GENERATOR;
|
||||
}
|
||||
|
||||
void CreateMeshNode(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
void CreateMeshNodes(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
{
|
||||
JsonNode meshNode;
|
||||
|
||||
if (!xmodel.m_name.empty())
|
||||
meshNode.name = xmodel.m_name;
|
||||
|
||||
// We only have one mesh
|
||||
meshNode.mesh = 0u;
|
||||
|
||||
// Only add skin if the model has bones
|
||||
if (!xmodel.m_bones.empty())
|
||||
{
|
||||
// We only have one skin
|
||||
meshNode.skin = 0u;
|
||||
}
|
||||
|
||||
if (!gltf.nodes.has_value())
|
||||
gltf.nodes.emplace();
|
||||
|
||||
m_mesh_node = gltf.nodes->size();
|
||||
m_first_mesh_node = gltf.nodes->size();
|
||||
|
||||
if (xmodel.m_bones.empty())
|
||||
m_root_node = m_mesh_node;
|
||||
auto meshIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
{
|
||||
JsonNode meshNode;
|
||||
|
||||
gltf.nodes->emplace_back(std::move(meshNode));
|
||||
if (!object.name.empty())
|
||||
meshNode.name = object.name;
|
||||
|
||||
meshNode.mesh = meshIndex++;
|
||||
|
||||
// Only add skin if the model has bones
|
||||
if (!xmodel.m_bones.empty())
|
||||
{
|
||||
// We only have one skin
|
||||
meshNode.skin = 0u;
|
||||
}
|
||||
|
||||
gltf.nodes->emplace_back(std::move(meshNode));
|
||||
}
|
||||
|
||||
// If we only have one mesh and no bones we don't need a dedicated root node
|
||||
if (xmodel.m_bones.empty() && xmodel.m_objects.size() == 1)
|
||||
m_root_node = m_first_mesh_node;
|
||||
}
|
||||
|
||||
void CreateRootNode(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
{
|
||||
JsonNode rootNode;
|
||||
|
||||
if (xmodel.m_bones.empty())
|
||||
// If we have at most one mesh and no bones we don't need a dedicated root node
|
||||
if (xmodel.m_bones.empty() && xmodel.m_objects.size() <= 1)
|
||||
return;
|
||||
|
||||
if (!xmodel.m_name.empty())
|
||||
@ -110,29 +116,31 @@ namespace
|
||||
gltf.nodes.emplace();
|
||||
|
||||
rootNode.children.emplace();
|
||||
rootNode.children->push_back(m_mesh_node);
|
||||
|
||||
const auto meshCount = xmodel.m_objects.size();
|
||||
for (auto meshIndex = 0u; meshIndex < meshCount; meshIndex++)
|
||||
rootNode.children->push_back(m_first_mesh_node + meshIndex);
|
||||
|
||||
rootNode.children->push_back(m_first_bone_node);
|
||||
|
||||
m_root_node = gltf.nodes->size();
|
||||
gltf.nodes->emplace_back(std::move(rootNode));
|
||||
}
|
||||
|
||||
void CreateMesh(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
void CreateMeshes(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
{
|
||||
if (!gltf.meshes.has_value())
|
||||
gltf.meshes.emplace();
|
||||
|
||||
JsonMesh mesh;
|
||||
|
||||
const auto hasBoneWeightData = !xmodel.m_bone_weight_data.weights.empty();
|
||||
|
||||
auto objectIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
{
|
||||
JsonMesh mesh;
|
||||
JsonMeshPrimitives primitives;
|
||||
|
||||
if (object.materialIndex >= 0)
|
||||
primitives.material = static_cast<unsigned>(object.materialIndex);
|
||||
primitives.material = object.materialIndex;
|
||||
|
||||
primitives.attributes.POSITION = m_position_accessor;
|
||||
primitives.attributes.NORMAL = m_normal_accessor;
|
||||
@ -149,9 +157,8 @@ namespace
|
||||
|
||||
mesh.primitives.emplace_back(primitives);
|
||||
objectIndex++;
|
||||
gltf.meshes->emplace_back(std::move(mesh));
|
||||
}
|
||||
|
||||
gltf.meshes->emplace_back(std::move(mesh));
|
||||
}
|
||||
|
||||
static void CreateMaterials(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
@ -466,18 +473,12 @@ namespace
|
||||
vertex->coordinates[1] = commonVertex.coordinates[2];
|
||||
vertex->coordinates[2] = -commonVertex.coordinates[1];
|
||||
|
||||
if (minPosition[0] > vertex->coordinates[0])
|
||||
minPosition[0] = vertex->coordinates[0];
|
||||
if (minPosition[1] > vertex->coordinates[1])
|
||||
minPosition[1] = vertex->coordinates[1];
|
||||
if (minPosition[2] > vertex->coordinates[2])
|
||||
minPosition[2] = vertex->coordinates[2];
|
||||
if (maxPosition[0] < vertex->coordinates[0])
|
||||
maxPosition[0] = vertex->coordinates[0];
|
||||
if (maxPosition[1] < vertex->coordinates[1])
|
||||
maxPosition[1] = vertex->coordinates[1];
|
||||
if (maxPosition[2] < vertex->coordinates[2])
|
||||
maxPosition[2] = vertex->coordinates[2];
|
||||
minPosition[0] = std::min(minPosition[0], vertex->coordinates[0]);
|
||||
minPosition[1] = std::min(minPosition[1], vertex->coordinates[1]);
|
||||
minPosition[2] = std::min(minPosition[2], vertex->coordinates[2]);
|
||||
maxPosition[0] = std::max(maxPosition[0], vertex->coordinates[0]);
|
||||
maxPosition[1] = std::max(maxPosition[1], vertex->coordinates[1]);
|
||||
maxPosition[2] = std::max(maxPosition[2], vertex->coordinates[2]);
|
||||
|
||||
vertex->normal[0] = commonVertex.normal[0];
|
||||
vertex->normal[1] = commonVertex.normal[2];
|
||||
@ -499,7 +500,7 @@ namespace
|
||||
{
|
||||
assert(xmodel.m_vertex_bone_weights.size() == xmodel.m_vertices.size());
|
||||
|
||||
auto* joints = reinterpret_cast<uint8_t*>(&bufferData[currentBufferOffset]);
|
||||
auto* joints = &bufferData[currentBufferOffset];
|
||||
auto* weights = reinterpret_cast<float*>(&bufferData[currentBufferOffset + sizeof(uint8_t) * 4u * xmodel.m_vertex_bone_weights.size()]);
|
||||
for (const auto& commonVertexWeights : xmodel.m_vertex_bone_weights)
|
||||
{
|
||||
@ -610,7 +611,7 @@ namespace
|
||||
gltf.buffers->emplace_back(std::move(jsonBuffer));
|
||||
}
|
||||
|
||||
unsigned m_mesh_node = 0u;
|
||||
unsigned m_first_mesh_node = 0u;
|
||||
unsigned m_root_node = 0u;
|
||||
unsigned m_first_bone_node = 0u;
|
||||
unsigned m_position_accessor = 0u;
|
||||
|
@ -32,7 +32,9 @@
|
||||
#include <cassert>
|
||||
#include <format>
|
||||
|
||||
namespace GAME
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string GetFileNameForLod(const std::string& modelName, const unsigned lod, const std::string& extension)
|
||||
{
|
||||
@ -223,10 +225,10 @@ namespace GAME
|
||||
bone.globalOffset[1] = baseMat.trans.y;
|
||||
bone.globalOffset[2] = baseMat.trans.z;
|
||||
bone.globalRotation = {
|
||||
baseMat.quat.x,
|
||||
baseMat.quat.y,
|
||||
baseMat.quat.z,
|
||||
baseMat.quat.w,
|
||||
.x = baseMat.quat.x,
|
||||
.y = baseMat.quat.y,
|
||||
.z = baseMat.quat.z,
|
||||
.w = baseMat.quat.w,
|
||||
};
|
||||
|
||||
if (boneNum < model->numRootBones)
|
||||
@ -234,7 +236,7 @@ namespace GAME
|
||||
bone.localOffset[0] = 0;
|
||||
bone.localOffset[1] = 0;
|
||||
bone.localOffset[2] = 0;
|
||||
bone.localRotation = {0, 0, 0, 1};
|
||||
bone.localRotation = {.x = 0, .y = 0, .z = 0, .w = 1};
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -245,10 +247,10 @@ namespace GAME
|
||||
|
||||
const auto& quat = model->quats[boneNum - model->numRootBones];
|
||||
bone.localRotation = {
|
||||
QuatInt16::ToFloat(quat.v[0]),
|
||||
QuatInt16::ToFloat(quat.v[1]),
|
||||
QuatInt16::ToFloat(quat.v[2]),
|
||||
QuatInt16::ToFloat(quat.v[3]),
|
||||
.x = QuatInt16::ToFloat(quat.v[0]),
|
||||
.y = QuatInt16::ToFloat(quat.v[1]),
|
||||
.z = QuatInt16::ToFloat(quat.v[2]),
|
||||
.w = QuatInt16::ToFloat(quat.v[3]),
|
||||
};
|
||||
}
|
||||
|
||||
@ -390,8 +392,9 @@ namespace GAME
|
||||
{
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
||||
|
||||
weightCollection.weights[weightOffset++] =
|
||||
XModelBoneWeight{.boneIndex = static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -408,8 +411,8 @@ namespace GAME
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
|
||||
@ -420,13 +423,13 @@ namespace GAME
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
|
||||
vertsBlendOffset += 3;
|
||||
|
||||
@ -437,16 +440,16 @@ namespace GAME
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
|
||||
vertsBlendOffset += 5;
|
||||
|
||||
@ -457,19 +460,19 @@ namespace GAME
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex3, boneWeight3};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex3, .weight = boneWeight3};
|
||||
|
||||
vertsBlendOffset += 7;
|
||||
|
||||
@ -567,7 +570,7 @@ namespace GAME
|
||||
void DumpXModelExportLod(const XModelCommon& common, const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
{
|
||||
const auto* model = asset->Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForLod(model->name, lod, ".XMODEL_EXPORT"));
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForLod(model->name, lod, ".xmodel_export"));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
@ -662,13 +665,13 @@ namespace GAME
|
||||
switch (ObjWriting::Configuration.ModelOutputFormat)
|
||||
{
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::XMODEL_EXPORT:
|
||||
return ".XMODEL_EXPORT";
|
||||
return ".xmodel_export";
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::OBJ:
|
||||
return ".OBJ";
|
||||
return ".obj";
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::GLTF:
|
||||
return ".GLTF";
|
||||
return ".gltf";
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::GLB:
|
||||
return ".GLB";
|
||||
return ".glb";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
@ -724,7 +727,10 @@ namespace GAME
|
||||
const JsonDumper dumper(context, *assetFile);
|
||||
dumper.Dump(asset->Asset());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace GAME
|
||||
{
|
||||
void DumpXModel(AssetDumpingContext& context, XAssetInfo<XModel>* asset)
|
||||
{
|
||||
DumpXModelJson(context, asset);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AbstractDirectiveStreamProxy.h"
|
||||
|
||||
TokenPos AbstractDirectiveStreamProxy::CreatePos(const ParserLine& line, const unsigned position)
|
||||
TokenPos AbstractDirectiveStreamProxy::CreatePos(const ParserLine& line, const size_t position)
|
||||
{
|
||||
return TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(position + 1));
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, unsigned& position)
|
||||
bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, size_t& position)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@ -21,7 +21,7 @@ bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, unsign
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, unsigned& position, int& value)
|
||||
bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, size_t& position, int& value)
|
||||
{
|
||||
if (position >= line.m_line.size())
|
||||
return false;
|
||||
@ -40,7 +40,7 @@ bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, unsign
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, unsigned& position)
|
||||
bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, size_t& position)
|
||||
{
|
||||
auto firstChar = true;
|
||||
while (true)
|
||||
@ -60,7 +60,7 @@ bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, uns
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, unsigned& position, char c)
|
||||
bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, size_t& position, char c)
|
||||
{
|
||||
if (position < line.m_line.size() && line.m_line[position] == c)
|
||||
{
|
||||
@ -71,12 +71,12 @@ bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, unsign
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchNextCharacter(const ParserLine& line, unsigned& position, char c)
|
||||
bool AbstractDirectiveStreamProxy::MatchNextCharacter(const ParserLine& line, size_t& position, char c)
|
||||
{
|
||||
return SkipWhitespace(line, position) && MatchCharacter(line, position, c);
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, unsigned& position, const char* str, unsigned len)
|
||||
bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, size_t& position, const char* str, size_t len)
|
||||
{
|
||||
if (line.m_line.compare(position, len, str) == 0)
|
||||
{
|
||||
@ -87,12 +87,12 @@ bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, unsigned&
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchNextString(const ParserLine& line, unsigned& position, const char* str, unsigned len)
|
||||
bool AbstractDirectiveStreamProxy::MatchNextString(const ParserLine& line, size_t& position, const char* str, size_t len)
|
||||
{
|
||||
return SkipWhitespace(line, position) && MatchString(line, position, str, len);
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::FindDirective(const ParserLine& line, unsigned& directiveStartPosition, unsigned& directiveEndPos)
|
||||
bool AbstractDirectiveStreamProxy::FindDirective(const ParserLine& line, size_t& directiveStartPosition, size_t& directiveEndPos)
|
||||
{
|
||||
directiveStartPosition = 0;
|
||||
for (; directiveStartPosition < line.m_line.size(); directiveStartPosition++)
|
||||
|
@ -3,20 +3,22 @@
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "Parsing/TokenPos.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class AbstractDirectiveStreamProxy : public IParserLineStream
|
||||
{
|
||||
protected:
|
||||
AbstractDirectiveStreamProxy() = default;
|
||||
|
||||
static TokenPos CreatePos(const ParserLine& line, unsigned position);
|
||||
static TokenPos CreatePos(const ParserLine& line, size_t position);
|
||||
|
||||
static bool SkipWhitespace(const ParserLine& line, unsigned& position);
|
||||
static bool ExtractInteger(const ParserLine& line, unsigned& position, int& value);
|
||||
static bool ExtractIdentifier(const ParserLine& line, unsigned& position);
|
||||
static bool MatchCharacter(const ParserLine& line, unsigned& position, char c);
|
||||
static bool MatchNextCharacter(const ParserLine& line, unsigned& position, char c);
|
||||
static bool MatchString(const ParserLine& line, unsigned& position, const char* str, unsigned len);
|
||||
static bool MatchNextString(const ParserLine& line, unsigned& position, const char* str, unsigned len);
|
||||
static bool SkipWhitespace(const ParserLine& line, size_t& position);
|
||||
static bool ExtractInteger(const ParserLine& line, size_t& position, int& value);
|
||||
static bool ExtractIdentifier(const ParserLine& line, size_t& position);
|
||||
static bool MatchCharacter(const ParserLine& line, size_t& position, char c);
|
||||
static bool MatchNextCharacter(const ParserLine& line, size_t& position, char c);
|
||||
static bool MatchString(const ParserLine& line, size_t& position, const char* str, size_t len);
|
||||
static bool MatchNextString(const ParserLine& line, size_t& position, const char* str, size_t len);
|
||||
|
||||
static bool FindDirective(const ParserLine& line, unsigned& directiveStartPosition, unsigned& directiveEndPos);
|
||||
static bool FindDirective(const ParserLine& line, size_t& directiveStartPosition, size_t& directiveEndPos);
|
||||
};
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
bool IsStringizeParameterForwardLookup(const std::string& value, unsigned pos)
|
||||
bool IsStringizeParameterForwardLookup(const std::string& value, size_t pos)
|
||||
{
|
||||
return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_');
|
||||
}
|
||||
|
||||
bool IsTokenPastingOperatorForwardLookup(const std::string& value, unsigned pos)
|
||||
bool IsTokenPastingOperatorForwardLookup(const std::string& value, size_t pos)
|
||||
{
|
||||
return pos + 1 < value.size() && value[pos + 1] == '#';
|
||||
}
|
||||
@ -32,7 +32,7 @@ DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition()
|
||||
{
|
||||
}
|
||||
|
||||
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const unsigned position, const bool stringize)
|
||||
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const size_t position, const bool stringize)
|
||||
: m_parameter_index(index),
|
||||
m_parameter_position(position),
|
||||
m_stringize(stringize)
|
||||
@ -175,7 +175,7 @@ int DefinesStreamProxy::GetLineEndEscapePos(const ParserLine& line)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const unsigned currentPos)
|
||||
void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const size_t currentPos)
|
||||
{
|
||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||
if (lineEndEscapePos < 0)
|
||||
@ -204,7 +204,7 @@ void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const unsigned c
|
||||
}
|
||||
}
|
||||
|
||||
void DefinesStreamProxy::ContinueParameters(const ParserLine& line, unsigned& currentPos)
|
||||
void DefinesStreamProxy::ContinueParameters(const ParserLine& line, size_t& currentPos)
|
||||
{
|
||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||
while (true)
|
||||
@ -241,7 +241,7 @@ void DefinesStreamProxy::ContinueParameters(const ParserLine& line, unsigned& cu
|
||||
}
|
||||
}
|
||||
|
||||
void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, unsigned& currentPos)
|
||||
void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, size_t& currentPos)
|
||||
{
|
||||
m_current_define_parameters = std::vector<std::string>();
|
||||
if (line.m_line[currentPos] != '(')
|
||||
@ -253,7 +253,7 @@ void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, unsigned&
|
||||
ContinueParameters(line, currentPos);
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -284,7 +284,7 @@ bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const unsi
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -323,7 +323,7 @@ std::unique_ptr<ISimpleExpression> DefinesStreamProxy::ParseExpression(std::shar
|
||||
return expressionInterpreter.Evaluate();
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -356,7 +356,7 @@ bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -398,7 +398,7 @@ bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsign
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -439,7 +439,7 @@ bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const unsig
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -460,7 +460,7 @@ bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const unsign
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -486,8 +486,8 @@ bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const unsig
|
||||
|
||||
bool DefinesStreamProxy::MatchDirectives(ParserLine& line)
|
||||
{
|
||||
unsigned directiveStartPos;
|
||||
unsigned directiveEndPos;
|
||||
size_t directiveStartPos;
|
||||
size_t directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
@ -537,9 +537,9 @@ void DefinesStreamProxy::ExtractParametersFromMacroUsage(
|
||||
ContinueMacroParameters(line, linePos, state, input, inputPos);
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, unsigned& pos, std::string& definitionName)
|
||||
bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName)
|
||||
{
|
||||
unsigned currentPos = pos;
|
||||
auto currentPos = pos;
|
||||
|
||||
if (!MatchNextCharacter(line, currentPos, '('))
|
||||
return false;
|
||||
@ -559,7 +559,7 @@ bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, unsigned
|
||||
|
||||
void DefinesStreamProxy::ExpandDefinedExpressions(ParserLine& line) const
|
||||
{
|
||||
auto currentPos = 0u;
|
||||
auto currentPos = 0uz;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -1094,7 +1094,7 @@ ParserLine DefinesStreamProxy::NextLine()
|
||||
{
|
||||
if (m_in_define)
|
||||
{
|
||||
unsigned currentPos = 0u;
|
||||
auto currentPos = 0uz;
|
||||
|
||||
if (m_parameter_state != ParameterState::NOT_IN_PARAMETERS)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "Parsing/Simple/Expression/ISimpleExpression.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
@ -29,11 +30,11 @@ public:
|
||||
{
|
||||
public:
|
||||
unsigned m_parameter_index;
|
||||
unsigned m_parameter_position;
|
||||
size_t m_parameter_position;
|
||||
bool m_stringize;
|
||||
|
||||
DefineParameterPosition();
|
||||
DefineParameterPosition(unsigned index, unsigned position, bool stringize);
|
||||
DefineParameterPosition(unsigned index, size_t position, bool stringize);
|
||||
};
|
||||
|
||||
class Define
|
||||
@ -96,22 +97,22 @@ private:
|
||||
MacroParameterState m_multi_line_macro_parameters;
|
||||
|
||||
static int GetLineEndEscapePos(const ParserLine& line);
|
||||
void MatchDefineParameters(const ParserLine& line, unsigned& currentPos);
|
||||
void ContinueDefine(const ParserLine& line, unsigned currentPos);
|
||||
void ContinueParameters(const ParserLine& line, unsigned& currentPos);
|
||||
_NODISCARD bool MatchDefineDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchUndefDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchIfDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchElIfDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchElseDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchEndifDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
void MatchDefineParameters(const ParserLine& line, size_t& currentPos);
|
||||
void ContinueDefine(const ParserLine& line, size_t currentPos);
|
||||
void ContinueParameters(const ParserLine& line, size_t& currentPos);
|
||||
_NODISCARD bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchDirectives(ParserLine& line);
|
||||
|
||||
void ExtractParametersFromMacroUsage(const ParserLine& line, unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
||||
bool FindMacroForIdentifier(const std::string& input, unsigned wordStart, unsigned wordEnd, const Define*& value) const;
|
||||
|
||||
static bool MatchDefinedExpression(const ParserLine& line, unsigned& pos, std::string& definitionName);
|
||||
static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName);
|
||||
void ExpandDefinedExpressions(ParserLine& line) const;
|
||||
|
||||
bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define);
|
||||
|
@ -13,9 +13,9 @@ IncludingStreamProxy::IncludingStreamProxy(IParserLineStream* stream)
|
||||
}
|
||||
|
||||
bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
||||
const unsigned includeDirectivePosition,
|
||||
unsigned& filenameStartPosition,
|
||||
unsigned& filenameEndPosition)
|
||||
const size_t includeDirectivePosition,
|
||||
size_t& filenameStartPosition,
|
||||
size_t& filenameEndPosition)
|
||||
{
|
||||
auto currentPos = includeDirectivePosition;
|
||||
bool isDoubleQuotes;
|
||||
@ -60,7 +60,7 @@ bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const unsigned directiveStartPos, const unsigned directiveEndPos) const
|
||||
bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const size_t directiveStartPos, const size_t directiveEndPos) const
|
||||
{
|
||||
auto currentPos = directiveStartPos;
|
||||
|
||||
@ -70,7 +70,7 @@ bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const u
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned filenameStart, filenameEnd;
|
||||
size_t filenameStart, filenameEnd;
|
||||
|
||||
if (!ExtractIncludeFilename(line, currentPos, filenameStart, filenameEnd))
|
||||
throw ParsingException(TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(currentPos)), INCLUDE_QUOTES_ERROR);
|
||||
@ -86,7 +86,7 @@ bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const u
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, const unsigned directiveStartPos, const unsigned directiveEndPos)
|
||||
bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, const size_t directiveStartPos, const size_t directiveEndPos)
|
||||
{
|
||||
auto currentPos = directiveStartPos;
|
||||
|
||||
@ -116,7 +116,7 @@ bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, cons
|
||||
|
||||
bool IncludingStreamProxy::MatchDirectives(const ParserLine& line)
|
||||
{
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -16,9 +16,9 @@ class IncludingStreamProxy final : public AbstractDirectiveStreamProxy
|
||||
std::set<std::string> m_included_files;
|
||||
|
||||
_NODISCARD static bool
|
||||
ExtractIncludeFilename(const ParserLine& line, unsigned includeDirectivePosition, unsigned& filenameStartPosition, unsigned& filenameEndPosition);
|
||||
_NODISCARD bool MatchIncludeDirective(const ParserLine& line, unsigned directiveStartPos, unsigned directiveEndPos) const;
|
||||
_NODISCARD bool MatchPragmaOnceDirective(const ParserLine& line, unsigned directiveStartPos, unsigned directiveEndPos);
|
||||
ExtractIncludeFilename(const ParserLine& line, size_t includeDirectivePosition, size_t& filenameStartPosition, size_t& filenameEndPosition);
|
||||
_NODISCARD bool MatchIncludeDirective(const ParserLine& line, size_t directiveStartPos, size_t directiveEndPos) const;
|
||||
_NODISCARD bool MatchPragmaOnceDirective(const ParserLine& line, size_t directiveStartPos, size_t directiveEndPos);
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
||||
|
||||
public:
|
||||
|
@ -7,7 +7,7 @@ PackDefinitionStreamProxy::PackDefinitionStreamProxy(IParserLineStream* stream)
|
||||
{
|
||||
}
|
||||
|
||||
bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
{
|
||||
auto packValue = 0;
|
||||
auto currentPosition = directiveStartPosition;
|
||||
@ -60,7 +60,7 @@ bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const
|
||||
|
||||
bool PackDefinitionStreamProxy::MatchDirectives(const ParserLine& line)
|
||||
{
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -21,7 +21,7 @@ private:
|
||||
IParserLineStream* const m_stream;
|
||||
std::stack<int> m_current_pack;
|
||||
|
||||
_NODISCARD bool MatchPackDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchPackDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
||||
|
||||
public:
|
||||
|
@ -15,7 +15,7 @@ void SetDefineStreamProxy::SetDefinesProxy(DefinesStreamProxy* definesProxy)
|
||||
m_defines_proxy = definesProxy;
|
||||
}
|
||||
|
||||
bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -59,7 +59,7 @@ bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const unsig
|
||||
|
||||
bool SetDefineStreamProxy::MatchDirectives(const ParserLine& line) const
|
||||
{
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -22,7 +22,7 @@ namespace templating
|
||||
private:
|
||||
static constexpr const char* SET_DIRECTIVE = "set";
|
||||
|
||||
_NODISCARD bool MatchSetDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSetDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
||||
|
||||
IParserLineStream* const m_stream;
|
||||
|
@ -18,7 +18,7 @@ void TemplatingStreamProxy::SetDefinesProxy(DefinesStreamProxy* definesProxy)
|
||||
m_defines_proxy = definesProxy;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -43,7 +43,7 @@ bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const u
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -93,7 +93,7 @@ bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -128,7 +128,7 @@ bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -146,7 +146,7 @@ bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const uns
|
||||
|
||||
bool TemplatingStreamProxy::MatchDirectives(const ParserLine& line) const
|
||||
{
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -43,10 +43,10 @@ namespace templating
|
||||
static constexpr const char* FILENAME_DIRECTIVE = "filename";
|
||||
static constexpr const char* SKIP_DIRECTIVE = "skip";
|
||||
|
||||
_NODISCARD bool MatchSwitchDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchOptionsDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchFilenameDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSkipDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSwitchDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchOptionsDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchFilenameDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSkipDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
||||
|
||||
IParserLineStream* const m_stream;
|
||||
|
@ -25,6 +25,23 @@ bool UnlinkerPaths::LoadUserPaths(const UnlinkerArgs& args)
|
||||
auto searchPathName = absolutePath.string();
|
||||
m_user_paths.CommitSearchPath(std::make_unique<SearchPathFilesystem>(searchPathName));
|
||||
m_specified_user_paths.emplace(std::move(searchPathName));
|
||||
|
||||
std::filesystem::directory_iterator iterator(absolutePath);
|
||||
const auto end = fs::end(iterator);
|
||||
for (auto i = fs::begin(iterator); i != end; ++i)
|
||||
{
|
||||
if (!i->is_regular_file())
|
||||
continue;
|
||||
|
||||
auto extension = i->path().extension().string();
|
||||
utils::MakeStringLowerCase(extension);
|
||||
if (extension == ".iwd")
|
||||
{
|
||||
auto iwd = iwd::LoadFromFile(i->path().string());
|
||||
if (iwd)
|
||||
m_user_paths.CommitSearchPath(std::move(iwd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::format("{} SearchPaths{}\n", m_specified_user_paths.size(), !m_specified_user_paths.empty() ? ":" : "");
|
||||
|
@ -1,123 +1,57 @@
|
||||
#include "GameAssetPoolIW3.h"
|
||||
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound",
|
||||
"clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character",
|
||||
"xmodelalias", "rawfile", "stringtable",
|
||||
};
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound",
|
||||
"clipmap_unused", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character",
|
||||
"xmodelalias", "rawfile", "stringtable",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority)
|
||||
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
}
|
||||
|
||||
void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
INIT_POOL(m_phys_preset);
|
||||
INIT_POOL(m_xanim_parts);
|
||||
INIT_POOL(m_xmodel);
|
||||
INIT_POOL(m_material);
|
||||
INIT_POOL(m_technique_set);
|
||||
INIT_POOL(m_image);
|
||||
INIT_POOL(m_sound);
|
||||
INIT_POOL(m_sound_curve);
|
||||
INIT_POOL(m_loaded_sound);
|
||||
INIT_POOL(m_clip_map);
|
||||
INIT_POOL(m_com_world);
|
||||
INIT_POOL(m_game_world_sp);
|
||||
INIT_POOL(m_game_world_mp);
|
||||
INIT_POOL(m_map_ents);
|
||||
INIT_POOL(m_gfx_world);
|
||||
INIT_POOL(m_gfx_light_def);
|
||||
INIT_POOL(m_font);
|
||||
INIT_POOL(m_menu_list);
|
||||
INIT_POOL(m_menu_def);
|
||||
INIT_POOL(m_localize);
|
||||
INIT_POOL(m_weapon);
|
||||
INIT_POOL(m_fx);
|
||||
INIT_POOL(m_fx_impact_table);
|
||||
INIT_POOL(m_raw_file);
|
||||
INIT_POOL(m_string_table);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
|
||||
{
|
||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
#undef INIT_POOL
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||
@ -125,7 +59,7 @@ XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGe
|
||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
assert((poolName) != nullptr); \
|
||||
assert(poolName); \
|
||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||
}
|
||||
@ -174,7 +108,7 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, const std
|
||||
#define CASE_GET_ASSET(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) != nullptr) \
|
||||
if (poolName) \
|
||||
return (poolName)->GetAsset(std::move(name)); \
|
||||
break; \
|
||||
}
|
||||
|
@ -9,13 +9,6 @@
|
||||
|
||||
class GameAssetPoolIW3 final : public ZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
static const char* ASSET_TYPE_NAMES[];
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
public:
|
||||
std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset;
|
||||
std::unique_ptr<AssetPool<IW3::XAnimParts>> m_xanim_parts;
|
||||
@ -46,17 +39,20 @@ public:
|
||||
std::unique_ptr<AssetPool<IW3::RawFile>> m_raw_file;
|
||||
std::unique_ptr<AssetPool<IW3::StringTable>> m_string_table;
|
||||
|
||||
GameAssetPoolIW3(Zone* zone, int priority);
|
||||
GameAssetPoolIW3(Zone* zone, zone_priority_t priority);
|
||||
~GameAssetPoolIW3() override = default;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
void InitPoolDynamic(asset_type_t type) override;
|
||||
|
||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
private:
|
||||
zone_priority_t m_priority;
|
||||
};
|
||||
|
@ -1,144 +1,72 @@
|
||||
#include "GameAssetPoolIW4.h"
|
||||
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
const char* GameAssetPoolIW4::ASSET_TYPE_NAMES[]{
|
||||
"physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel", "material", "pixelshader", "vertexshader", "vertexdecl", "techniqueset",
|
||||
"image", "sound", "soundcurve", "loadedsound", "clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents",
|
||||
"fxworld", "gfxworld", "lightdef", "uimap", "font", "menulist", "menu", "localize", "weapon", "snddriverglobals",
|
||||
"fx", "impactfx", "aitype", "mptype", "character", "xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef",
|
||||
"tracer", "vehicle", "addonmapents",
|
||||
};
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel",
|
||||
"material", "pixelshader", "vertexshader", "vertexdecl", "techniqueset",
|
||||
"image", "sound", "soundcurve", "loadedsound", "clipmap_unused",
|
||||
"clipmap_used", "comworld", "gameworldsp", "gameworldmp", "mapents",
|
||||
"fxworld", "gfxworld", "lightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "snddriverglobals",
|
||||
"fx", "impactfx", "aitype", "mptype", "character",
|
||||
"xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef",
|
||||
"tracer", "vehicle", "addonmapents",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
|
||||
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
}
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
||||
INIT_POOL(m_phys_preset);
|
||||
INIT_POOL(m_phys_collmap);
|
||||
INIT_POOL(m_xanim_parts);
|
||||
INIT_POOL(m_xmodel);
|
||||
INIT_POOL(m_material);
|
||||
INIT_POOL(m_material_pixel_shader);
|
||||
INIT_POOL(m_material_vertex_shader);
|
||||
INIT_POOL(m_material_vertex_decl);
|
||||
INIT_POOL(m_technique_set);
|
||||
INIT_POOL(m_image);
|
||||
INIT_POOL(m_sound);
|
||||
INIT_POOL(m_sound_curve);
|
||||
INIT_POOL(m_loaded_sound);
|
||||
INIT_POOL(m_clip_map);
|
||||
INIT_POOL(m_com_world);
|
||||
INIT_POOL(m_game_world_sp);
|
||||
INIT_POOL(m_game_world_mp);
|
||||
INIT_POOL(m_map_ents);
|
||||
INIT_POOL(m_fx_world);
|
||||
INIT_POOL(m_gfx_world);
|
||||
INIT_POOL(m_gfx_light_def);
|
||||
INIT_POOL(m_font);
|
||||
INIT_POOL(m_menu_list);
|
||||
INIT_POOL(m_menu_def);
|
||||
INIT_POOL(m_localize);
|
||||
INIT_POOL(m_weapon);
|
||||
INIT_POOL(m_fx);
|
||||
INIT_POOL(m_fx_impact_table);
|
||||
INIT_POOL(m_raw_file);
|
||||
INIT_POOL(m_string_table);
|
||||
INIT_POOL(m_leaderboard);
|
||||
INIT_POOL(m_structed_data_def_set);
|
||||
INIT_POOL(m_tracer);
|
||||
INIT_POOL(m_vehicle);
|
||||
INIT_POOL(m_addon_map_ents);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
|
||||
{
|
||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_DYNAMIC
|
||||
#undef INIT_POOL
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||
@ -146,7 +74,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGe
|
||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
assert((poolName) != nullptr); \
|
||||
assert(poolName); \
|
||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||
}
|
||||
@ -205,7 +133,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, const std
|
||||
#define CASE_GET_ASSET(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) != nullptr) \
|
||||
if (poolName) \
|
||||
return (poolName)->GetAsset(name); \
|
||||
break; \
|
||||
}
|
||||
|
@ -3,20 +3,11 @@
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Pool/AssetPool.h"
|
||||
#include "Pool/ZoneAssetPools.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class GameAssetPoolIW4 final : public ZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
||||
static const char* ASSET_TYPE_NAMES[];
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
public:
|
||||
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;
|
||||
std::unique_ptr<AssetPool<IW4::PhysCollmap>> m_phys_collmap;
|
||||
@ -54,17 +45,20 @@ public:
|
||||
std::unique_ptr<AssetPool<IW4::VehicleDef>> m_vehicle;
|
||||
std::unique_ptr<AssetPool<IW4::AddonMapEnts>> m_addon_map_ents;
|
||||
|
||||
GameAssetPoolIW4(Zone* zone, int priority);
|
||||
GameAssetPoolIW4(Zone* zone, zone_priority_t priority);
|
||||
~GameAssetPoolIW4() override = default;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
void InitPoolDynamic(asset_type_t type) override;
|
||||
|
||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
private:
|
||||
zone_priority_t m_priority;
|
||||
};
|
||||
|
@ -1,193 +1,114 @@
|
||||
#include "GameAssetPoolIW5.h"
|
||||
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{
|
||||
"physpreset",
|
||||
"physcollmap",
|
||||
"xanim",
|
||||
"xmodelsurfs",
|
||||
"xmodel",
|
||||
"material",
|
||||
"pixelshader",
|
||||
"vertexshader",
|
||||
"vertexdecl",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"sound",
|
||||
"soundcurve",
|
||||
"loadedsound",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"glassworld",
|
||||
"pathdata",
|
||||
"vehicletrack",
|
||||
"mapents",
|
||||
"fxworld",
|
||||
"gfxworld",
|
||||
"lightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"attachment",
|
||||
"weapon",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"impactfx",
|
||||
"surfacefx",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"scriptfile",
|
||||
"stringtable",
|
||||
"leaderboard",
|
||||
"structureddatadef",
|
||||
"tracer",
|
||||
"vehicle",
|
||||
"addonmapents",
|
||||
};
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"physpreset",
|
||||
"physcollmap",
|
||||
"xanim",
|
||||
"xmodelsurfs",
|
||||
"xmodel",
|
||||
"material",
|
||||
"pixelshader",
|
||||
"vertexshader",
|
||||
"vertexdecl",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"sound",
|
||||
"soundcurve",
|
||||
"loadedsound",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"glassworld",
|
||||
"pathdata",
|
||||
"vehicletrack",
|
||||
"mapents",
|
||||
"fxworld",
|
||||
"gfxworld",
|
||||
"lightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"attachment",
|
||||
"weapon",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"impactfx",
|
||||
"surfacefx",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"scriptfile",
|
||||
"stringtable",
|
||||
"leaderboard",
|
||||
"structureddatadef",
|
||||
"tracer",
|
||||
"vehicle",
|
||||
"addonmapents",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority)
|
||||
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
}
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
||||
INIT_POOL(m_phys_preset);
|
||||
INIT_POOL(m_phys_collmap);
|
||||
INIT_POOL(m_xanim_parts);
|
||||
INIT_POOL(m_xmodel_surfs);
|
||||
INIT_POOL(m_xmodel);
|
||||
INIT_POOL(m_material);
|
||||
INIT_POOL(m_material_pixel_shader);
|
||||
INIT_POOL(m_material_vertex_shader);
|
||||
INIT_POOL(m_material_vertex_decl);
|
||||
INIT_POOL(m_technique_set);
|
||||
INIT_POOL(m_image);
|
||||
INIT_POOL(m_sound);
|
||||
INIT_POOL(m_sound_curve);
|
||||
INIT_POOL(m_loaded_sound);
|
||||
INIT_POOL(m_clip_map);
|
||||
INIT_POOL(m_com_world);
|
||||
INIT_POOL(m_glass_world);
|
||||
INIT_POOL(m_path_data);
|
||||
INIT_POOL(m_vehicle_track);
|
||||
INIT_POOL(m_map_ents);
|
||||
INIT_POOL(m_fx_world);
|
||||
INIT_POOL(m_gfx_world);
|
||||
INIT_POOL(m_gfx_light_def);
|
||||
INIT_POOL(m_font);
|
||||
INIT_POOL(m_menu_list);
|
||||
INIT_POOL(m_menu_def);
|
||||
INIT_POOL(m_localize);
|
||||
INIT_POOL(m_attachment);
|
||||
INIT_POOL(m_weapon);
|
||||
INIT_POOL(m_fx);
|
||||
INIT_POOL(m_fx_impact_table);
|
||||
INIT_POOL(m_surface_fx_table);
|
||||
INIT_POOL(m_raw_file);
|
||||
INIT_POOL(m_script_file);
|
||||
INIT_POOL(m_string_table);
|
||||
INIT_POOL(m_leaderboard);
|
||||
INIT_POOL(m_structed_data_def_set);
|
||||
INIT_POOL(m_tracer);
|
||||
INIT_POOL(m_vehicle);
|
||||
INIT_POOL(m_addon_map_ents);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
void GameAssetPoolIW5::InitPoolDynamic(const asset_type_t type)
|
||||
{
|
||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_DYNAMIC
|
||||
#undef INIT_POOL
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||
@ -195,7 +116,7 @@ XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGe
|
||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
assert((poolName) != nullptr); \
|
||||
assert(poolName); \
|
||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||
}
|
||||
@ -258,8 +179,8 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, const std
|
||||
#define CASE_GET_ASSET(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) != nullptr) \
|
||||
return (poolName)->GetAsset(std::move(name)); \
|
||||
if (poolName) \
|
||||
return (poolName)->GetAsset(name); \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,6 @@
|
||||
|
||||
class GameAssetPoolIW5 final : public ZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
||||
static const char* ASSET_TYPE_NAMES[];
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
public:
|
||||
std::unique_ptr<AssetPool<IW5::PhysPreset>> m_phys_preset;
|
||||
std::unique_ptr<AssetPool<IW5::PhysCollmap>> m_phys_collmap;
|
||||
@ -58,17 +50,20 @@ public:
|
||||
std::unique_ptr<AssetPool<IW5::VehicleDef>> m_vehicle;
|
||||
std::unique_ptr<AssetPool<IW5::AddonMapEnts>> m_addon_map_ents;
|
||||
|
||||
GameAssetPoolIW5(Zone* zone, int priority);
|
||||
GameAssetPoolIW5(Zone* zone, zone_priority_t priority);
|
||||
~GameAssetPoolIW5() override = default;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
void InitPoolDynamic(asset_type_t type) override;
|
||||
|
||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
private:
|
||||
zone_priority_t m_priority;
|
||||
};
|
||||
|
@ -1,140 +1,67 @@
|
||||
#include "GameAssetPoolT5.h"
|
||||
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace T5;
|
||||
|
||||
const char* GameAssetPoolT5::ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
|
||||
"techniqueset", "image", "soundbank", "soundpatch", "clipmap", "clipmap", "comworld",
|
||||
"gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "weapondef", "weaponvariant", "snddriverglobals",
|
||||
"fx", "fximpacttable", "aitype", "mptype", "mpbody", "mphead", "character",
|
||||
"xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
|
||||
"emblemset",
|
||||
};
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
|
||||
"techniqueset", "image", "soundbank", "soundpatch", "clipmap_unused", "clipmap", "comworld",
|
||||
"gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "weapondef", "weaponvariant", "snddriverglobals",
|
||||
"fx", "fximpacttable", "aitype", "mptype", "mpbody", "mphead", "character",
|
||||
"xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
|
||||
"emblemset",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority)
|
||||
GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
}
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
||||
INIT_POOL(m_phys_preset);
|
||||
INIT_POOL(m_phys_constraints);
|
||||
INIT_POOL(m_destructible_def);
|
||||
INIT_POOL(m_xanim_parts);
|
||||
INIT_POOL(m_xmodel);
|
||||
INIT_POOL(m_material);
|
||||
INIT_POOL(m_technique_set);
|
||||
INIT_POOL(m_image);
|
||||
INIT_POOL(m_sound_bank);
|
||||
INIT_POOL(m_sound_patch);
|
||||
INIT_POOL(m_clip_map);
|
||||
INIT_POOL(m_com_world);
|
||||
INIT_POOL(m_game_world_sp);
|
||||
INIT_POOL(m_game_world_mp);
|
||||
INIT_POOL(m_map_ents);
|
||||
INIT_POOL(m_gfx_world);
|
||||
INIT_POOL(m_gfx_light_def);
|
||||
INIT_POOL(m_font);
|
||||
INIT_POOL(m_menu_list);
|
||||
INIT_POOL(m_menu_def);
|
||||
INIT_POOL(m_localize);
|
||||
INIT_POOL(m_weapon);
|
||||
INIT_POOL(m_snd_driver_globals);
|
||||
INIT_POOL(m_fx);
|
||||
INIT_POOL(m_fx_impact_table);
|
||||
INIT_POOL(m_raw_file);
|
||||
INIT_POOL(m_string_table);
|
||||
INIT_POOL(m_pack_index);
|
||||
INIT_POOL(m_xglobals);
|
||||
INIT_POOL(m_ddl);
|
||||
INIT_POOL(m_glasses);
|
||||
INIT_POOL(m_emblem_set);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type)
|
||||
{
|
||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_DYNAMIC
|
||||
#undef INIT_POOL
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||
@ -142,7 +69,7 @@ XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGen
|
||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
assert((poolName) != nullptr); \
|
||||
assert(poolName); \
|
||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||
}
|
||||
@ -198,8 +125,8 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, const std:
|
||||
#define CASE_GET_ASSET(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) != nullptr) \
|
||||
return (poolName)->GetAsset(std::move(name)); \
|
||||
if (poolName) \
|
||||
return (poolName)->GetAsset(name); \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,6 @@
|
||||
|
||||
class GameAssetPoolT5 final : public ZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
||||
static const char* ASSET_TYPE_NAMES[];
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
public:
|
||||
std::unique_ptr<AssetPool<T5::PhysPreset>> m_phys_preset;
|
||||
std::unique_ptr<AssetPool<T5::PhysConstraints>> m_phys_constraints;
|
||||
@ -50,17 +42,20 @@ public:
|
||||
std::unique_ptr<AssetPool<T5::Glasses>> m_glasses;
|
||||
std::unique_ptr<AssetPool<T5::EmblemSet>> m_emblem_set;
|
||||
|
||||
GameAssetPoolT5(Zone* zone, int priority);
|
||||
GameAssetPoolT5(Zone* zone, zone_priority_t priority);
|
||||
~GameAssetPoolT5() override = default;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
void InitPoolDynamic(asset_type_t type) override;
|
||||
|
||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
private:
|
||||
zone_priority_t m_priority;
|
||||
};
|
||||
|
@ -1,225 +1,136 @@
|
||||
#include "GameAssetPoolT6.h"
|
||||
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
const char* GameAssetPoolT6::ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces",
|
||||
"physpreset",
|
||||
"physconstraints",
|
||||
"destructibledef",
|
||||
"xanim",
|
||||
"xmodel",
|
||||
"material",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"soundbank",
|
||||
"soundpatch",
|
||||
"clipmap",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"gameworldsp",
|
||||
"gameworldmp",
|
||||
"mapents",
|
||||
"gfxworld",
|
||||
"gfxlightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"fonticon",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"weapon",
|
||||
"weapondef",
|
||||
"weaponvariant",
|
||||
"weaponfull",
|
||||
"attachment",
|
||||
"attachmentunique",
|
||||
"camo",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"fximpacttable",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"mpbody",
|
||||
"mphead",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"stringtable",
|
||||
"leaderboard",
|
||||
"xglobals",
|
||||
"ddl",
|
||||
"glasses",
|
||||
"emblemset",
|
||||
"script",
|
||||
"keyvaluepairs",
|
||||
"vehicle",
|
||||
"memoryblock",
|
||||
"addonmapents",
|
||||
"tracer",
|
||||
"skinnedverts",
|
||||
"qdb",
|
||||
"slug",
|
||||
"footsteptable",
|
||||
"footstepfxtable",
|
||||
"zbarrier",
|
||||
};
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces",
|
||||
"physpreset",
|
||||
"physconstraints",
|
||||
"destructibledef",
|
||||
"xanim",
|
||||
"xmodel",
|
||||
"material",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"soundbank",
|
||||
"soundpatch",
|
||||
"clipmap_unused",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"gameworldsp",
|
||||
"gameworldmp",
|
||||
"mapents",
|
||||
"gfxworld",
|
||||
"gfxlightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"fonticon",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"weapon",
|
||||
"weapondef",
|
||||
"weaponvariant",
|
||||
"weaponfull",
|
||||
"attachment",
|
||||
"attachmentunique",
|
||||
"camo",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"fximpacttable",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"mpbody",
|
||||
"mphead",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"stringtable",
|
||||
"leaderboard",
|
||||
"xglobals",
|
||||
"ddl",
|
||||
"glasses",
|
||||
"emblemset",
|
||||
"script",
|
||||
"keyvaluepairs",
|
||||
"vehicle",
|
||||
"memoryblock",
|
||||
"addonmapents",
|
||||
"tracer",
|
||||
"skinnedverts",
|
||||
"qdb",
|
||||
"slug",
|
||||
"footsteptable",
|
||||
"footstepfxtable",
|
||||
"zbarrier",
|
||||
};
|
||||
} // namespace
|
||||
|
||||
GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
|
||||
GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
}
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier)
|
||||
INIT_POOL(m_phys_preset);
|
||||
INIT_POOL(m_phys_constraints);
|
||||
INIT_POOL(m_destructible_def);
|
||||
INIT_POOL(m_xanim_parts);
|
||||
INIT_POOL(m_xmodel);
|
||||
INIT_POOL(m_material);
|
||||
INIT_POOL(m_technique_set);
|
||||
INIT_POOL(m_image);
|
||||
INIT_POOL(m_sound_bank);
|
||||
INIT_POOL(m_sound_patch);
|
||||
INIT_POOL(m_clip_map);
|
||||
INIT_POOL(m_com_world);
|
||||
INIT_POOL(m_game_world_sp);
|
||||
INIT_POOL(m_game_world_mp);
|
||||
INIT_POOL(m_map_ents);
|
||||
INIT_POOL(m_gfx_world);
|
||||
INIT_POOL(m_gfx_light_def);
|
||||
INIT_POOL(m_font);
|
||||
INIT_POOL(m_font_icon);
|
||||
INIT_POOL(m_menu_list);
|
||||
INIT_POOL(m_menu_def);
|
||||
INIT_POOL(m_localize);
|
||||
INIT_POOL(m_weapon);
|
||||
INIT_POOL(m_attachment);
|
||||
INIT_POOL(m_attachment_unique);
|
||||
INIT_POOL(m_camo);
|
||||
INIT_POOL(m_snd_driver_globals);
|
||||
INIT_POOL(m_fx);
|
||||
INIT_POOL(m_fx_impact_table);
|
||||
INIT_POOL(m_raw_file);
|
||||
INIT_POOL(m_string_table);
|
||||
INIT_POOL(m_leaderboard);
|
||||
INIT_POOL(m_xglobals);
|
||||
INIT_POOL(m_ddl);
|
||||
INIT_POOL(m_glasses);
|
||||
INIT_POOL(m_emblem_set);
|
||||
INIT_POOL(m_script);
|
||||
INIT_POOL(m_key_value_pairs);
|
||||
INIT_POOL(m_vehicle);
|
||||
INIT_POOL(m_memory_block);
|
||||
INIT_POOL(m_addon_map_ents);
|
||||
INIT_POOL(m_tracer);
|
||||
INIT_POOL(m_skinned_verts);
|
||||
INIT_POOL(m_qdb);
|
||||
INIT_POOL(m_slug);
|
||||
INIT_POOL(m_footstep_table);
|
||||
INIT_POOL(m_footstep_fx_table);
|
||||
INIT_POOL(m_zbarrier);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type)
|
||||
{
|
||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) == nullptr) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier)
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_DYNAMIC
|
||||
#undef INIT_POOL
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||
@ -227,7 +138,7 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGen
|
||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
assert((poolName) != nullptr); \
|
||||
assert(poolName); \
|
||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||
}
|
||||
@ -299,7 +210,7 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, const std:
|
||||
#define CASE_GET_ASSET(assetType, poolName) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if ((poolName) != nullptr) \
|
||||
if (poolName) \
|
||||
return (poolName)->GetAsset(name); \
|
||||
break; \
|
||||
}
|
||||
|
@ -8,14 +8,6 @@
|
||||
|
||||
class GameAssetPoolT6 final : public ZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
||||
static const char* ASSET_TYPE_NAMES[];
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
public:
|
||||
std::unique_ptr<AssetPool<T6::PhysPreset>> m_phys_preset;
|
||||
std::unique_ptr<AssetPool<T6::PhysConstraints>> m_phys_constraints;
|
||||
@ -66,17 +58,20 @@ public:
|
||||
std::unique_ptr<AssetPool<T6::FootstepFXTableDef>> m_footstep_fx_table;
|
||||
std::unique_ptr<AssetPool<T6::ZBarrierDef>> m_zbarrier;
|
||||
|
||||
GameAssetPoolT6(Zone* zone, int priority);
|
||||
GameAssetPoolT6(Zone* zone, zone_priority_t priority);
|
||||
~GameAssetPoolT6() override = default;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
void InitPoolDynamic(asset_type_t type) override;
|
||||
|
||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
private:
|
||||
zone_priority_t m_priority;
|
||||
};
|
||||
|
@ -4,20 +4,18 @@
|
||||
#include "GlobalAssetPool.h"
|
||||
#include "XAssetInfo.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
template<typename T> class AssetPoolDynamic final : public AssetPool<T>
|
||||
{
|
||||
using AssetPool<T>::m_asset_lookup;
|
||||
|
||||
std::vector<std::unique_ptr<XAssetInfo<T>>> m_assets;
|
||||
asset_type_t m_type;
|
||||
|
||||
public:
|
||||
AssetPoolDynamic(const int priority, const asset_type_t type)
|
||||
explicit AssetPoolDynamic(const zone_priority_t priority)
|
||||
{
|
||||
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
AssetPoolDynamic(AssetPoolDynamic<T>&) = delete;
|
||||
|
@ -1,104 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetPool.h"
|
||||
#include "GlobalAssetPool.h"
|
||||
#include "XAssetInfo.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
template<typename T> class AssetPoolStatic final : public AssetPool<T>
|
||||
{
|
||||
using AssetPool<T>::m_asset_lookup;
|
||||
|
||||
struct AssetPoolEntry
|
||||
{
|
||||
XAssetInfo<T>* m_info;
|
||||
|
||||
union
|
||||
{
|
||||
T m_entry;
|
||||
AssetPoolEntry* m_next;
|
||||
};
|
||||
};
|
||||
|
||||
AssetPoolEntry* m_free;
|
||||
AssetPoolEntry* m_pool;
|
||||
XAssetInfo<T>* m_info_pool;
|
||||
size_t m_capacity;
|
||||
asset_type_t m_type;
|
||||
|
||||
public:
|
||||
AssetPoolStatic(const size_t capacity, const int priority, const asset_type_t type)
|
||||
{
|
||||
m_capacity = capacity;
|
||||
m_type = type;
|
||||
|
||||
if (m_capacity > 0)
|
||||
{
|
||||
m_pool = new AssetPoolEntry[m_capacity];
|
||||
m_info_pool = new XAssetInfo<T>[m_capacity];
|
||||
|
||||
for (size_t i = 0; i < m_capacity - 1; i++)
|
||||
{
|
||||
m_pool[i].m_info = &m_info_pool[i];
|
||||
m_pool[i].m_next = &m_pool[i + 1];
|
||||
}
|
||||
m_pool[m_capacity - 1].m_info = &m_info_pool[m_capacity - 1];
|
||||
m_pool[m_capacity - 1].m_next = nullptr;
|
||||
|
||||
m_free = m_pool;
|
||||
|
||||
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pool = nullptr;
|
||||
m_free = nullptr;
|
||||
m_info_pool = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
AssetPoolStatic(AssetPoolStatic<T>&) = delete;
|
||||
AssetPoolStatic(AssetPoolStatic<T>&&) = delete;
|
||||
AssetPoolStatic<T>& operator=(AssetPoolStatic<T>&) = delete;
|
||||
AssetPoolStatic<T>& operator=(AssetPoolStatic<T>&&) = default;
|
||||
|
||||
~AssetPoolStatic() override
|
||||
{
|
||||
if (m_capacity > 0)
|
||||
GlobalAssetPool<T>::UnlinkAssetPool(this);
|
||||
|
||||
delete[] m_pool;
|
||||
m_pool = nullptr;
|
||||
|
||||
delete[] m_info_pool;
|
||||
m_info_pool = nullptr;
|
||||
|
||||
m_free = nullptr;
|
||||
m_capacity = 0;
|
||||
}
|
||||
|
||||
XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) override
|
||||
{
|
||||
if (m_free == nullptr)
|
||||
throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted.");
|
||||
|
||||
const auto normalizedName = XAssetInfo<T>::NormalizeAssetName(xAssetInfo->m_name);
|
||||
|
||||
AssetPoolEntry* poolSlot = m_free;
|
||||
m_free = m_free->m_next;
|
||||
|
||||
const T* pAsset = xAssetInfo->Asset();
|
||||
xAssetInfo->m_ptr = static_cast<void*>(&poolSlot->m_entry);
|
||||
memcpy(&poolSlot->m_entry, pAsset, sizeof(T));
|
||||
|
||||
*poolSlot->m_info = std::move(*xAssetInfo);
|
||||
|
||||
m_asset_lookup[normalizedName] = poolSlot->m_info;
|
||||
|
||||
GlobalAssetPool<T>::LinkAsset(this, normalizedName, poolSlot->m_info);
|
||||
|
||||
return poolSlot->m_info;
|
||||
}
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetPool.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@ -14,7 +15,7 @@ template<typename T> class GlobalAssetPool
|
||||
struct LinkedAssetPool
|
||||
{
|
||||
AssetPool<T>* m_asset_pool;
|
||||
int m_priority;
|
||||
zone_priority_t m_priority;
|
||||
};
|
||||
|
||||
struct GameAssetPoolEntry
|
||||
@ -92,7 +93,7 @@ template<typename T> class GlobalAssetPool
|
||||
}
|
||||
|
||||
public:
|
||||
static void LinkAssetPool(AssetPool<T>* assetPool, const int priority)
|
||||
static void LinkAssetPool(AssetPool<T>* assetPool, const zone_priority_t priority)
|
||||
{
|
||||
auto newLink = std::make_unique<LinkedAssetPool>();
|
||||
newLink->m_asset_pool = assetPool;
|
||||
|
@ -93,6 +93,11 @@ XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type,
|
||||
{
|
||||
}
|
||||
|
||||
bool XAssetInfoGeneric::IsReference() const
|
||||
{
|
||||
return !m_name.empty() && m_name[0] == ',';
|
||||
}
|
||||
|
||||
std::string XAssetInfoGeneric::NormalizeAssetName(std::string input)
|
||||
{
|
||||
utils::MakeStringLowerCase(input);
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default;
|
||||
XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default;
|
||||
|
||||
[[nodiscard]] bool IsReference() const;
|
||||
|
||||
static std::string NormalizeAssetName(std::string input);
|
||||
|
||||
asset_type_t m_type;
|
||||
|
@ -16,12 +16,6 @@ class XAssetInfoGeneric;
|
||||
|
||||
class ZoneAssetPools
|
||||
{
|
||||
protected:
|
||||
Zone* m_zone;
|
||||
std::vector<XAssetInfoGeneric*> m_assets_in_order;
|
||||
|
||||
virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
|
||||
|
||||
public:
|
||||
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
|
||||
|
||||
@ -45,13 +39,16 @@ public:
|
||||
_NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0;
|
||||
_NODISCARD virtual std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const = 0;
|
||||
|
||||
virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0;
|
||||
virtual void InitPoolDynamic(asset_type_t type) = 0;
|
||||
|
||||
_NODISCARD size_t GetTotalAssetCount() const;
|
||||
|
||||
_NODISCARD iterator begin() const;
|
||||
_NODISCARD iterator end() const;
|
||||
|
||||
static std::unique_ptr<ZoneAssetPools> CreateForGame(GameId game, Zone* zone, zone_priority_t priority);
|
||||
|
||||
protected:
|
||||
virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
|
||||
|
||||
Zone* m_zone;
|
||||
std::vector<XAssetInfoGeneric*> m_assets_in_order;
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ uint8_t* AbstractSalsa20Processor::GetHashBlock(const int streamNumber) const
|
||||
void AbstractSalsa20Processor::InitStreams(const std::string& zoneName, const uint8_t* salsa20Key, const size_t keySize) const
|
||||
{
|
||||
// Original buffer must have been 32 bytes because the zoneName can at most be 31 characters be long before being cut off
|
||||
const auto zoneNameLength = std::min(zoneName.length(), 31u);
|
||||
const auto zoneNameLength = std::min(zoneName.length(), 31uz);
|
||||
|
||||
const size_t blockHashBufferSize = BLOCK_HASHES_COUNT * m_stream_count * SHA1_HASH_SIZE;
|
||||
|
||||
|
@ -9,9 +9,6 @@ Zone::Zone(std::string name, const zone_priority_t priority, IGame* game)
|
||||
m_game(game),
|
||||
m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority))
|
||||
{
|
||||
const auto assetTypeCount = m_pools->GetAssetTypeCount();
|
||||
for (auto i = 0; i < assetTypeCount; i++)
|
||||
m_pools->InitPoolDynamic(i);
|
||||
}
|
||||
|
||||
Zone::~Zone()
|
||||
|
@ -126,11 +126,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
{
|
||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXAsset(false);
|
||||
|
@ -146,11 +146,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
{
|
||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXAsset(false);
|
||||
|
@ -155,11 +155,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
{
|
||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXAsset(false);
|
||||
|
@ -139,11 +139,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
{
|
||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXAsset(false);
|
||||
|
@ -168,11 +168,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
||||
if (atStreamStart)
|
||||
m_stream->Load<XAsset>(varXAsset, count);
|
||||
|
||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
{
|
||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
LoadXAsset(false);
|
||||
|
@ -14,7 +14,7 @@ SearchPathOpenFile MockSearchPath::Open(const std::string& fileName)
|
||||
if (foundFileData == m_file_data_map.end())
|
||||
return {};
|
||||
|
||||
return {std::make_unique<std::istringstream>(foundFileData->second), foundFileData->second.size()};
|
||||
return {std::make_unique<std::istringstream>(foundFileData->second), static_cast<int64_t>(foundFileData->second.size())};
|
||||
}
|
||||
|
||||
const std::string& MockSearchPath::GetPath()
|
||||
|
2
thirdparty/catch2
vendored
2
thirdparty/catch2
vendored
@ -1 +1 @@
|
||||
Subproject commit 914aeecfe23b1e16af6ea675a4fb5dbd5a5b8d0a
|
||||
Subproject commit 4c8671cfbbf0019d3827305d4d1c82a74eeb029a
|
2
thirdparty/eigen
vendored
2
thirdparty/eigen
vendored
@ -1 +1 @@
|
||||
Subproject commit 9836e8d035f72003b4af070c0da73660b28b8d2e
|
||||
Subproject commit 33f5f596143d0fce32316ec6fa4bd9f23b4dd9d2
|
2
thirdparty/json
vendored
2
thirdparty/json
vendored
@ -1 +1 @@
|
||||
Subproject commit 2d42229f4d68c6f86f37468b84ac65e86b815bbb
|
||||
Subproject commit c67d538274502163b55e8fb54b5c27c17764722d
|
2
thirdparty/libtomcrypt
vendored
2
thirdparty/libtomcrypt
vendored
@ -1 +1 @@
|
||||
Subproject commit 2e9f2b5e44dd498dba60e5175c6c7effa5ff3728
|
||||
Subproject commit a6b9aff7aab857fe1b491710a5c5b9e2be49cb08
|
2
thirdparty/libtommath
vendored
2
thirdparty/libtommath
vendored
@ -1 +1 @@
|
||||
Subproject commit 5809141a3a6ec1bf3443c927c02b955e19224016
|
||||
Subproject commit e823b0c34cea291bdb94d672731e1c1f08525557
|
2
thirdparty/zlib
vendored
2
thirdparty/zlib
vendored
@ -1 +1 @@
|
||||
Subproject commit ef24c4c7502169f016dcd2a26923dbaf3216748c
|
||||
Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71
|
Loading…
x
Reference in New Issue
Block a user