mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-18 16:37:48 +00:00
Merge pull request #611 from michaeloliverx/iw3-xenon-zone-dumping
feat: dump iw3 xbox unsigned fastfile data
This commit is contained in:
@@ -13,7 +13,8 @@ namespace IW3
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr const char* MAGIC_UNSIGNED = "IWffu100";
|
static constexpr const char* MAGIC_UNSIGNED = "IWffu100";
|
||||||
static constexpr int ZONE_VERSION = 5;
|
static constexpr int ZONE_VERSION_PC = 5;
|
||||||
|
static constexpr int ZONE_VERSION_XENON = 1;
|
||||||
|
|
||||||
static_assert(std::char_traits<char>::length(MAGIC_UNSIGNED) == sizeof(ZoneHeader::m_magic));
|
static_assert(std::char_traits<char>::length(MAGIC_UNSIGNED) == sizeof(ZoneHeader::m_magic));
|
||||||
|
|
||||||
|
|||||||
@@ -9,15 +9,20 @@
|
|||||||
#include "Loading/Processor/ProcessorInflate.h"
|
#include "Loading/Processor/ProcessorInflate.h"
|
||||||
#include "Loading/Steps/StepAddProcessor.h"
|
#include "Loading/Steps/StepAddProcessor.h"
|
||||||
#include "Loading/Steps/StepAllocXBlocks.h"
|
#include "Loading/Steps/StepAllocXBlocks.h"
|
||||||
|
#include "Loading/Steps/StepDumpData.h"
|
||||||
#include "Loading/Steps/StepLoadZoneContent.h"
|
#include "Loading/Steps/StepLoadZoneContent.h"
|
||||||
#include "Loading/Steps/StepLoadZoneSizes.h"
|
#include "Loading/Steps/StepLoadZoneSizes.h"
|
||||||
#include "Utils/ClassUtils.h"
|
#include "Utils/ClassUtils.h"
|
||||||
|
#include "Utils/Endianness.h"
|
||||||
|
#include "Utils/Logging/Log.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -41,9 +46,8 @@ namespace
|
|||||||
|
|
||||||
std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(const ZoneHeader& header) const
|
std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(const ZoneHeader& header) const
|
||||||
{
|
{
|
||||||
if (header.m_version != ZoneConstants::ZONE_VERSION)
|
if (endianness::FromLittleEndian(header.m_version) == ZoneConstants::ZONE_VERSION_PC)
|
||||||
return std::nullopt;
|
{
|
||||||
|
|
||||||
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, std::char_traits<char>::length(ZoneConstants::MAGIC_UNSIGNED)))
|
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, std::char_traits<char>::length(ZoneConstants::MAGIC_UNSIGNED)))
|
||||||
{
|
{
|
||||||
return ZoneLoaderInspectionResult{
|
return ZoneLoaderInspectionResult{
|
||||||
@@ -56,6 +60,22 @@ std::optional<ZoneLoaderInspectionResult> ZoneLoaderFactory::InspectZoneHeader(c
|
|||||||
.m_is_encrypted = false,
|
.m_is_encrypted = false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (endianness::FromBigEndian(header.m_version) == ZoneConstants::ZONE_VERSION_XENON)
|
||||||
|
{
|
||||||
|
if (!memcmp(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, std::char_traits<char>::length(ZoneConstants::MAGIC_UNSIGNED)))
|
||||||
|
{
|
||||||
|
return ZoneLoaderInspectionResult{
|
||||||
|
.m_game_id = GameId::IW3,
|
||||||
|
.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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -81,6 +101,8 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH
|
|||||||
|
|
||||||
zoneLoader->AddLoadingStep(step::CreateStepAddProcessor(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
|
zoneLoader->AddLoadingStep(step::CreateStepAddProcessor(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
|
||||||
|
|
||||||
|
if (inspectResult->m_endianness == GameEndianness::LE)
|
||||||
|
{
|
||||||
// Start of the XFile struct
|
// Start of the XFile struct
|
||||||
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneSizes());
|
zoneLoader->AddLoadingStep(step::CreateStepLoadZoneSizes());
|
||||||
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
zoneLoader->AddLoadingStep(step::CreateStepAllocXBlocks());
|
||||||
@@ -96,6 +118,15 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(const ZoneH
|
|||||||
ZoneConstants::INSERT_BLOCK,
|
ZoneConstants::INSERT_BLOCK,
|
||||||
zonePtr->Memory(),
|
zonePtr->Memory(),
|
||||||
std::move(progressCallback)));
|
std::move(progressCallback)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs::path dumpFileNamePath = fs::path(fileName).filename();
|
||||||
|
dumpFileNamePath.replace_extension(".dat");
|
||||||
|
std::string dumpFileName = dumpFileNamePath.string();
|
||||||
|
con::warn("Dumping xbox assets is not supported, making a full fastfile data dump to {}", dumpFileName);
|
||||||
|
zoneLoader->AddLoadingStep(step::CreateStepDumpData(dumpFileName, 0xFFFFFFFF));
|
||||||
|
}
|
||||||
|
|
||||||
return zoneLoader;
|
return zoneLoader;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace
|
|||||||
ZoneHeader CreateHeaderForParams()
|
ZoneHeader CreateHeaderForParams()
|
||||||
{
|
{
|
||||||
ZoneHeader header{};
|
ZoneHeader header{};
|
||||||
header.m_version = ZoneConstants::ZONE_VERSION;
|
header.m_version = ZoneConstants::ZONE_VERSION_PC;
|
||||||
memcpy(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, sizeof(ZoneHeader::m_magic));
|
memcpy(header.m_magic, ZoneConstants::MAGIC_UNSIGNED, sizeof(ZoneHeader::m_magic));
|
||||||
|
|
||||||
return header;
|
return header;
|
||||||
|
|||||||
Reference in New Issue
Block a user