mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-11-06 17:01:58 +00:00
refactor: use variants in zone instead of only game
This commit is contained in:
138 files changed
+542
-549
No files matched your search
@@ -133,9 +133,7 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW3,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_variant_id = GameVariantId::IW3_PC,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
@@ -148,9 +146,7 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW3,
|
||||
.m_endianness = GameEndianness::BE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::XBOX,
|
||||
.m_variant_id = GameVariantId::IW3_XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
@@ -160,9 +156,7 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW3,
|
||||
.m_endianness = GameEndianness::BE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::XBOX,
|
||||
.m_variant_id = GameVariantId::IW3_XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = false,
|
||||
@@ -181,8 +175,10 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
if (!inspectResult)
|
||||
return nullptr;
|
||||
|
||||
const auto variant = IGameVariant::GetVariantById(inspectResult->m_variant_id);
|
||||
|
||||
// Create new zone
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::IW3, inspectResult->m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GameLanguage::LANGUAGE_NONE;
|
||||
|
||||
@@ -199,7 +195,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
|
||||
zoneLoader->AddLoadingStep(step::CreateStepAddProcessor(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
|
||||
|
||||
if (inspectResult->m_endianness == GameEndianness::LE)
|
||||
if (variant->GetEndianness() == GameEndianness::LE)
|
||||
{
|
||||
// Start of the XFile struct
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneSizes());
|
||||
|
||||
@@ -53,17 +53,16 @@ namespace
|
||||
if (*reinterpret_cast<const uint32_t*>(&header.m_magic[std::char_traits<char>::length(ZoneConstants::MAGIC_IW4X)])
|
||||
== ZoneConstants::ZONE_VERSION_IW4x)
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::IW4,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::IW4_PC32,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultIW4{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_is_iw4x = true,
|
||||
};
|
||||
}
|
||||
@@ -73,34 +72,32 @@ namespace
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_SIGNED_INFINITY_WARD, std::char_traits<char>::length(ZoneConstants::MAGIC_SIGNED_INFINITY_WARD)))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::IW4,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::IW4_PC32,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultIW4{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_is_iw4x = false,
|
||||
};
|
||||
}
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, std::char_traits<char>::length(ZoneConstants::MAGIC_UNSIGNED)))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::IW4,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::IW4_PC32,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultIW4{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_is_iw4x = false,
|
||||
};
|
||||
}
|
||||
@@ -110,33 +107,29 @@ namespace
|
||||
{
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, std::char_traits<char>::length(ZoneConstants::MAGIC_UNSIGNED)))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_variant_id = GameVariantId::IW4_XBOX,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultIW4{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_endianness = GameEndianness::BE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::XBOX,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_is_iw4x = false,
|
||||
};
|
||||
}
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_SIGNED_INFINITY_WARD, std::char_traits<char>::length(ZoneConstants::MAGIC_SIGNED_INFINITY_WARD)))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_variant_id = GameVariantId::IW4_XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultIW4{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW4,
|
||||
.m_endianness = GameEndianness::BE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_is_iw4x = false,
|
||||
};
|
||||
}
|
||||
@@ -161,18 +154,18 @@ namespace
|
||||
#undef XBLOCK_DEF
|
||||
}
|
||||
|
||||
std::unique_ptr<cryptography::IPublicKeyAlgorithm> SetupRsa(const bool isOfficial, const GamePlatform platform)
|
||||
std::unique_ptr<cryptography::IPublicKeyAlgorithm> SetupRsa(const bool isOfficial, const GameVariantId variant)
|
||||
{
|
||||
if (isOfficial)
|
||||
{
|
||||
auto rsa = cryptography::CreateRsa(cryptography::HashingAlgorithm::RSA_HASH_SHA256, cryptography::RsaPaddingMode::RSA_PADDING_PSS);
|
||||
|
||||
bool keySetSuccessful;
|
||||
if (platform == GamePlatform::PC)
|
||||
if (variant == GameVariantId::IW4_PC32 || variant == GameVariantId::IW4_PC64)
|
||||
{
|
||||
keySetSuccessful = rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_PC, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_PC));
|
||||
}
|
||||
else if (platform == GamePlatform::XBOX)
|
||||
else if (variant == GameVariantId::IW4_XBOX)
|
||||
{
|
||||
keySetSuccessful = rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD_XENON));
|
||||
}
|
||||
@@ -206,7 +199,7 @@ namespace
|
||||
return;
|
||||
|
||||
// If file is signed setup a RSA instance.
|
||||
auto rsa = SetupRsa(inspectResult.m_generic_result.m_is_official, inspectResult.m_generic_result.m_platform);
|
||||
auto rsa = SetupRsa(inspectResult.m_generic_result.m_is_official, inspectResult.m_generic_result.m_variant_id);
|
||||
|
||||
zoneLoader.AddLoadingStep(step::CreateStepVerifyMagic(ZoneConstants::MAGIC_AUTH_HEADER));
|
||||
zoneLoader.AddLoadingStep(step::CreateStepSkipBytes(4)); // Skip reserved
|
||||
@@ -266,7 +259,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
return nullptr;
|
||||
|
||||
// Create new zone
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::IW4, inspectResult->m_generic_result.m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_generic_result.m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GameLanguage::LANGUAGE_NONE;
|
||||
|
||||
@@ -285,7 +278,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
zoneLoader->AddLoadingStep(step::CreateStepSkipBytes(8));
|
||||
|
||||
// Xbox fastfiles have an additional header of all included images outside the zone data
|
||||
if (inspectResult->m_generic_result.m_platform == GamePlatform::XBOX)
|
||||
if (inspectResult->m_generic_result.m_variant_id == GameVariantId::IW4_XBOX)
|
||||
zoneLoader->AddLoadingStep(step::CreateStepSkipZoneImageHeaders());
|
||||
|
||||
// Add steps for loading the auth header which also contain the signature of the zone if it is signed.
|
||||
@@ -299,7 +292,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
zoneLoader->AddLoadingStep(step::CreateStepSkipBytes(1));
|
||||
}
|
||||
|
||||
if (inspectResult->m_generic_result.m_endianness == GameEndianness::LE)
|
||||
if (inspectResult->m_generic_result.m_variant_id != GameVariantId::IW4_XBOX)
|
||||
{
|
||||
// Start of the XFile struct
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneSizes());
|
||||
|
||||
@@ -131,9 +131,8 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW5,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::IW5_PC32,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = false,
|
||||
@@ -144,9 +143,8 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::IW5,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::IW5_PC32,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
@@ -165,7 +163,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
return nullptr;
|
||||
|
||||
// Create new zone
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::IW5, inspectResult->m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GameLanguage::LANGUAGE_NONE;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "ContentLoaderQOS.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/QOS/GameQOS.h"
|
||||
#include "Game/QOS/QOS.h"
|
||||
#include "Game/QOS/ZoneConstantsQOS.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
@@ -41,9 +42,7 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::QOS,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_variant_id = GameVariantId::QOS_PC,
|
||||
// There is no way to know whether unsigned zones are official.
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
@@ -62,7 +61,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
if (!inspectResult)
|
||||
return nullptr;
|
||||
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::QOS, inspectResult->m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GameLanguage::LANGUAGE_NONE;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "ContentLoaderT4.h"
|
||||
#include "Game/GameLanguage.h"
|
||||
#include "Game/T4/GameT4.h"
|
||||
#include "Game/T4/T4.h"
|
||||
#include "Game/T4/ZoneConstantsT4.h"
|
||||
#include "Loading/Processor/ProcessorInflate.h"
|
||||
@@ -43,9 +44,7 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T4,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_variant_id = GameVariantId::T4_PC,
|
||||
// There is no way to know whether unsigned zones are official.
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
@@ -65,7 +64,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
return nullptr;
|
||||
|
||||
// Create new zone
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::T4, inspectResult->m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GameLanguage::LANGUAGE_NONE;
|
||||
|
||||
|
||||
@@ -46,9 +46,7 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(Z
|
||||
{
|
||||
return ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T5,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_variant_id = GameVariantId::T5_PC,
|
||||
// There is no way to know whether unsigned zones are official.
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
@@ -68,7 +66,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
return nullptr;
|
||||
|
||||
// Create new zone
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::T5, inspectResult->m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GameLanguage::LANGUAGE_NONE;
|
||||
|
||||
|
||||
@@ -54,68 +54,64 @@ namespace
|
||||
{
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_SIGNED_TREYARCH, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::T6_PC,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_SIGNED_OAT, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::T6_PC,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::T6_PC,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = true,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = false,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = true,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED_SERVER, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
// Assume 32bit at first until we may know better later
|
||||
.m_variant_id = GameVariantId::T6_PC,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PC,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
@@ -124,34 +120,30 @@ namespace
|
||||
{
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_SIGNED_TREYARCH, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_variant_id = GameVariantId::T6_XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::BE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_SIGNED_LZX_TREYARCH, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_variant_id = GameVariantId::T6_XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::BE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::XBOX,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = true,
|
||||
.m_is_encrypted = true,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::LZX,
|
||||
};
|
||||
}
|
||||
@@ -160,36 +152,32 @@ namespace
|
||||
{
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED_SERVER, 8))
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_variant_id = GameVariantId::T6_PS3,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::PS3,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (endianness::FromLittleEndian(header.m_version) == ZoneConstants::ZONE_VERSION_WIIU)
|
||||
{
|
||||
constexpr ZoneLoaderInspectionResult generic{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_variant_id = GameVariantId::T6_WIIU,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
};
|
||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED_SERVER, 8))
|
||||
{
|
||||
return ZoneLoaderInspectionResultT6{
|
||||
.m_generic_result =
|
||||
ZoneLoaderInspectionResult{
|
||||
.m_game_id = GameId::T6,
|
||||
.m_endianness = GameEndianness::LE,
|
||||
.m_word_size = GameWordSize::ARCH_32,
|
||||
.m_platform = GamePlatform::WIIU,
|
||||
.m_is_official = true,
|
||||
.m_is_signed = false,
|
||||
.m_is_encrypted = false,
|
||||
},
|
||||
.m_generic_result = generic,
|
||||
.m_compression_type = ZoneCompressionTypeT6::DEFLATE,
|
||||
};
|
||||
}
|
||||
@@ -269,14 +257,15 @@ namespace
|
||||
return signatureLoadStepPtr;
|
||||
}
|
||||
|
||||
ICapturedDataProvider* AddXChunkProcessor(const ZoneLoaderInspectionResultT6& inspectResult, ZoneLoader& zoneLoader, const std::string& fileName)
|
||||
ICapturedDataProvider*
|
||||
AddXChunkProcessor(const ZoneLoaderInspectionResultT6& inspectResult, const IGameVariant& variant, ZoneLoader& zoneLoader, const std::string& fileName)
|
||||
{
|
||||
ICapturedDataProvider* result = nullptr;
|
||||
auto xChunkProcessor = processor::CreateProcessorXChunks(
|
||||
ZoneConstants::STREAM_COUNT, ZoneConstants::XCHUNK_SIZE, inspectResult.m_generic_result.m_endianness, ZoneConstants::VANILLA_BUFFER_SIZE);
|
||||
ZoneConstants::STREAM_COUNT, ZoneConstants::XCHUNK_SIZE, variant.GetEndianness(), ZoneConstants::VANILLA_BUFFER_SIZE);
|
||||
|
||||
const uint8_t (&salsa20Key)[32] = inspectResult.m_generic_result.m_platform == GamePlatform::XBOX ? ZoneConstants::SALSA20_KEY_TREYARCH_XENON
|
||||
: ZoneConstants::SALSA20_KEY_TREYARCH_PC;
|
||||
const uint8_t (&salsa20Key)[32] =
|
||||
variant.GetPlatform() == GamePlatform::XBOX ? ZoneConstants::SALSA20_KEY_TREYARCH_XENON : ZoneConstants::SALSA20_KEY_TREYARCH_PC;
|
||||
|
||||
if (inspectResult.m_generic_result.m_is_encrypted)
|
||||
{
|
||||
@@ -322,8 +311,10 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
if (!inspectResult)
|
||||
return nullptr;
|
||||
|
||||
const auto variant = IGameVariant::GetVariantById(inspectResult->m_generic_result.m_variant_id);
|
||||
|
||||
// Create new zone
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, GameId::T6, inspectResult->m_generic_result.m_platform);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, inspectResult->m_generic_result.m_variant_id);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_language = GetZoneLanguage(fileName);
|
||||
|
||||
@@ -342,9 +333,9 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneDataPee
|
||||
ISignatureProvider* signatureProvider = AddAuthHeaderSteps(inspectResult->m_generic_result.m_is_signed, *zoneLoader, fileName);
|
||||
|
||||
// Setup loading XChunks from the zone from this point on.
|
||||
ICapturedDataProvider* signatureDataProvider = AddXChunkProcessor(*inspectResult, *zoneLoader, fileName);
|
||||
ICapturedDataProvider* signatureDataProvider = AddXChunkProcessor(*inspectResult, *variant, *zoneLoader, fileName);
|
||||
|
||||
if (inspectResult->m_generic_result.m_endianness == GameEndianness::LE)
|
||||
if (variant->GetEndianness() == GameEndianness::LE)
|
||||
{
|
||||
// Start of the XFile struct
|
||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneSizes());
|
||||
|
||||
@@ -13,12 +13,9 @@ struct ZoneLoaderInspectionResult
|
||||
{
|
||||
// The game this zone is created for.
|
||||
GameId m_game_id;
|
||||
// Whether the zone is meant for a little-endian or big-endian loader.
|
||||
GameEndianness m_endianness;
|
||||
// Whether the zone is meant for a 32bit or 64bit loader.
|
||||
GameWordSize m_word_size;
|
||||
// The platform this zone is for.
|
||||
GamePlatform m_platform;
|
||||
// The id of the game variant of this zone.
|
||||
// The game variant informs about more architectural background like endianness, word size and platform.
|
||||
GameVariantId m_variant_id;
|
||||
// Whether this zone is confirmed official. False if not official or unknown.
|
||||
bool m_is_official;
|
||||
// Whether this zone contains a signature confirming the identity of the creator.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IGame.h"
|
||||
#include "Game/GameVariant.h"
|
||||
#include "Loading/StreamProcessor.h"
|
||||
#include "Zone/XChunk/IXChunkProcessor.h"
|
||||
|
||||
|
||||
Reference in new issue
Block a user