refactor: use variants in zone instead of only game

This commit is contained in:
Jan Laupetin committed 2026-10-22 20:01:05 +02:00
1 parent 041501fb5d
commit 594bf41eaf
138 files changed
+542 -549

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
#include "GameVariant.h"
#include <cassert>
#include <utility>
GameVariant::GameVariant(
const GameVariantId id, const GameId gameId, std::string name, const GameEndianness endianness, const GameWordSize wordSize, const GamePlatform platform)
: m_id(id),
m_game_id(gameId),
m_name(std::move(name)),
m_endianness(endianness),
m_word_size(wordSize),
m_platform(platform)
{
}
GameVariantId GameVariant::GetId() const
{
return m_id;
}
GameId GameVariant::GetGameId() const
{
return m_game_id;
}
const std::string& GameVariant::GetName() const
{
return m_name;
}
GameEndianness GameVariant::GetEndianness() const
{
return m_endianness;
}
GameWordSize GameVariant::GetWordSize() const
{
return m_word_size;
}
GamePlatform GameVariant::GetPlatform() const
{
return m_platform;
}
IGameVariant* IGameVariant::GetVariantById(const GameVariantId variantId)
{
static IGameVariant* variants[]{
new GameVariant(GameVariantId::IW3_PC, GameId::IW3, "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::IW3_XBOX, GameId::IW3, "xbox", GameEndianness::BE, GameWordSize::ARCH_32, GamePlatform::XBOX),
new GameVariant(GameVariantId::IW4_PC32, GameId::IW4, "pc32", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::IW4_PC64, GameId::IW4, "pc64", GameEndianness::LE, GameWordSize::ARCH_64, GamePlatform::PC),
new GameVariant(GameVariantId::IW4_XBOX, GameId::IW4, "xbox", GameEndianness::BE, GameWordSize::ARCH_32, GamePlatform::XBOX),
new GameVariant(GameVariantId::IW5_PC32, GameId::IW5, "pc32", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::IW5_PC64, GameId::IW5, "pc64", GameEndianness::LE, GameWordSize::ARCH_64, GamePlatform::PC),
new GameVariant(GameVariantId::IW5_XBOX, GameId::IW5, "xbox", GameEndianness::BE, GameWordSize::ARCH_32, GamePlatform::XBOX),
new GameVariant(GameVariantId::QOS_PC, GameId::QOS, "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::T4_PC, GameId::T4, "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::T5_PC, GameId::T5, "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::T6_PC, GameId::T6, "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(GameVariantId::T6_XBOX, GameId::T6, "xbox", GameEndianness::BE, GameWordSize::ARCH_32, GamePlatform::XBOX),
new GameVariant(GameVariantId::T6_PS3, GameId::T6, "ps3", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PS3),
new GameVariant(GameVariantId::T6_WIIU, GameId::T6, "wiiu", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::WIIU),
};
static_assert(std::size(variants) == std::to_underlying(GameVariantId::COUNT));
assert(std::to_underlying(variantId) < std::to_underlying(GameVariantId::COUNT));
auto* result = variants[std::to_underlying(variantId)];
assert(result);
return result;
}
+96
View File
@@ -0,0 +1,96 @@
#pragma once
#include "IGame.h"
#include <cstdint>
#include <string>
/*
* A game variant is a specific game version or platform files are created for.
* This determines the layout of the structs, endianness/wordsize in the zone and informs about the target platform.
*/
enum class GameVariantId : std::uint8_t
{
IW3_PC,
IW3_XBOX,
IW4_PC32,
IW4_PC64,
IW4_XBOX,
IW5_PC32,
IW5_PC64,
IW5_XBOX,
QOS_PC,
T4_PC,
T5_PC,
T6_PC,
T6_XBOX,
T6_PS3,
T6_WIIU,
COUNT
};
// The full uppercase names are macros in the standard lib
// So unfortunately not usable as values in the enum
enum class GameEndianness : std::uint8_t
{
/* Little endian */
LE,
/* Big endian */
BE
};
enum class GameWordSize : std::uint8_t
{
ARCH_32,
ARCH_64
};
enum class GamePlatform : std::uint8_t
{
PC,
XBOX,
PS3,
WIIU
};
class IGameVariant
{
public:
IGameVariant() = default;
virtual ~IGameVariant() = default;
IGameVariant(const IGameVariant& other) = default;
IGameVariant(IGameVariant&& other) noexcept = default;
IGameVariant& operator=(const IGameVariant& other) = default;
IGameVariant& operator=(IGameVariant&& other) noexcept = default;
static IGameVariant* GetVariantById(GameVariantId variantId);
[[nodiscard]] virtual GameVariantId GetId() const = 0;
[[nodiscard]] virtual GameId GetGameId() const = 0;
[[nodiscard]] virtual const std::string& GetName() const = 0;
[[nodiscard]] virtual GameEndianness GetEndianness() const = 0;
[[nodiscard]] virtual GameWordSize GetWordSize() const = 0;
[[nodiscard]] virtual GamePlatform GetPlatform() const = 0;
};
class GameVariant : public IGameVariant
{
public:
GameVariant(GameVariantId id, GameId gameId, std::string name, GameEndianness endianness, GameWordSize wordSize, GamePlatform platform);
[[nodiscard]] GameVariantId GetId() const override;
[[nodiscard]] GameId GetGameId() const override;
[[nodiscard]] const std::string& GetName() const override;
[[nodiscard]] GameEndianness GetEndianness() const override;
[[nodiscard]] GameWordSize GetWordSize() const override;
[[nodiscard]] GamePlatform GetPlatform() const override;
private:
GameVariantId m_id;
GameId m_game_id;
std::string m_name;
GameEndianness m_endianness;
GameWordSize m_word_size;
GamePlatform m_platform;
};
+1 -44
View File
@@ -11,41 +11,7 @@
#include <cassert>
GameVariant::GameVariant(const GameVariantId id, std::string name, const GameEndianness endianness, const GameWordSize wordSize, const GamePlatform platform)
: m_id(id),
m_name(std::move(name)),
m_endianness(endianness),
m_word_size(wordSize),
m_platform(platform)
{
}
GameVariantId GameVariant::GetId() const
{
return m_id;
}
const std::string& GameVariant::GetName() const
{
return m_name;
}
GameEndianness GameVariant::GetEndianness() const
{
return m_endianness;
}
GameWordSize GameVariant::GetWordSize() const
{
return m_word_size;
}
GamePlatform GameVariant::GetPlatform() const
{
return m_platform;
}
IGame* IGame::GetGameById(GameId gameId)
IGame* IGame::GetGameById(const GameId gameId)
{
static IGame* games[]{
new IW3::Game(),
@@ -87,15 +53,6 @@ const std::vector<GameLanguagePrefix>& AbstractGame::GetLanguagePrefixes() const
return prefixes;
}
const IGameVariant* AbstractGame::GetVariantById(const GameVariantId id) const
{
const auto& variants = GetVariants();
assert(id < variants.size());
return variants[id];
}
asset_type_t AbstractGame::GetAssetTypeCount() const
{
return m_asset_type_count;
-79
View File
@@ -6,7 +6,6 @@
#include <cstdint>
#include <optional>
#include <type_traits>
#include <unordered_map>
#include <vector>
@@ -23,79 +22,6 @@ enum class GameId : std::uint8_t
COUNT
};
typedef std::uint8_t GameVariantId;
// The full uppercase names are macros in the standard lib
// So unfortunately not usable as values in the enum
enum class GameEndianness : std::uint8_t
{
/* Little endian */
LE,
/* Big endian */
BE
};
enum class GameWordSize : std::uint8_t
{
ARCH_32,
ARCH_64
};
enum class GamePlatform : std::uint8_t
{
PC,
XBOX,
PS3,
WIIU
};
static constexpr const char* GameId_Names[]{
"IW3",
"IW4",
"IW5",
"QOS",
"T4",
"T5",
"T6",
};
static_assert(std::extent_v<decltype(GameId_Names)> == static_cast<unsigned>(GameId::COUNT));
class IGameVariant
{
public:
IGameVariant() = default;
virtual ~IGameVariant() = default;
IGameVariant(const IGameVariant& other) = default;
IGameVariant(IGameVariant&& other) noexcept = default;
IGameVariant& operator=(const IGameVariant& other) = default;
IGameVariant& operator=(IGameVariant&& other) noexcept = default;
[[nodiscard]] virtual GameVariantId GetId() const = 0;
[[nodiscard]] virtual const std::string& GetName() const = 0;
[[nodiscard]] virtual GameEndianness GetEndianness() const = 0;
[[nodiscard]] virtual GameWordSize GetWordSize() const = 0;
[[nodiscard]] virtual GamePlatform GetPlatform() const = 0;
};
class GameVariant : public IGameVariant
{
public:
GameVariant(GameVariantId id, std::string name, GameEndianness endianness, GameWordSize wordSize, GamePlatform platform);
[[nodiscard]] GameVariantId GetId() const override;
[[nodiscard]] const std::string& GetName() const override;
[[nodiscard]] GameEndianness GetEndianness() const override;
[[nodiscard]] GameWordSize GetWordSize() const override;
[[nodiscard]] GamePlatform GetPlatform() const override;
private:
GameVariantId m_id;
std::string m_name;
GameEndianness m_endianness;
GameWordSize m_word_size;
GamePlatform m_platform;
};
class IGame
{
public:
@@ -111,9 +37,6 @@ public:
[[nodiscard]] virtual const std::string& GetShortName() const = 0;
[[nodiscard]] virtual const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const = 0;
[[nodiscard]] virtual const IGameVariant* GetVariantById(GameVariantId id) const = 0;
[[nodiscard]] virtual const std::vector<IGameVariant*>& GetVariants() const = 0;
[[nodiscard]] virtual asset_type_t GetAssetTypeCount() const = 0;
[[nodiscard]] virtual std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const = 0;
[[nodiscard]] virtual std::optional<asset_type_t> FindAssetTypeByName(const std::string& potentialAssetTypeName) const = 0;
@@ -131,8 +54,6 @@ public:
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
[[nodiscard]] const IGameVariant* GetVariantById(GameVariantId id) const override;
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
[[nodiscard]] std::optional<asset_type_t> FindAssetTypeByName(const std::string& potentialAssetTypeName) const override;
-8
View File
@@ -51,12 +51,4 @@ namespace IW3
static std::string shortName = "IW3";
return shortName;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC), "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
};
return variants;
}
} // namespace IW3
-6
View File
@@ -4,11 +4,6 @@
namespace IW3
{
enum class VariantId : std::uint8_t
{
PC,
};
class Game final : public AbstractGame
{
public:
@@ -17,6 +12,5 @@ namespace IW3
[[nodiscard]] GameId GetId() const override;
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace IW3
-9
View File
@@ -54,13 +54,4 @@ namespace IW4
static std::string shortName = "IW4";
return shortName;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC32), "pc32", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(std::to_underlying(VariantId::PC32), "pc64", GameEndianness::LE, GameWordSize::ARCH_64, GamePlatform::PC),
};
return variants;
}
} // namespace IW4
-7
View File
@@ -4,12 +4,6 @@
namespace IW4
{
enum class VariantId : std::uint8_t
{
PC32,
PC64,
};
class Game final : public AbstractGame
{
public:
@@ -18,6 +12,5 @@ namespace IW4
[[nodiscard]] GameId GetId() const override;
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace IW4
-9
View File
@@ -90,13 +90,4 @@ namespace IW5
static std::string shortName = "IW5";
return shortName;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC32), "pc32", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
new GameVariant(std::to_underlying(VariantId::PC32), "pc64", GameEndianness::LE, GameWordSize::ARCH_64, GamePlatform::PC),
};
return variants;
}
} // namespace IW5
-7
View File
@@ -4,12 +4,6 @@
namespace IW5
{
enum class VariantId : std::uint8_t
{
PC32,
PC64,
};
class Game final : public AbstractGame
{
public:
@@ -18,6 +12,5 @@ namespace IW5
[[nodiscard]] GameId GetId() const override;
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace IW5
-8
View File
@@ -85,12 +85,4 @@ namespace QOS
static std::string shortName = "QOS";
return shortName;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC), "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
};
return variants;
}
} // namespace QOS
-6
View File
@@ -4,11 +4,6 @@
namespace QOS
{
enum class VariantId : std::uint8_t
{
PC,
};
class Game final : public AbstractGame
{
public:
@@ -17,6 +12,5 @@ namespace QOS
[[nodiscard]] GameId GetId() const override;
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace QOS
-8
View File
@@ -92,12 +92,4 @@ namespace T4
static std::string shortName = "T4";
return shortName;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC), "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
};
return variants;
}
} // namespace T4
-6
View File
@@ -4,11 +4,6 @@
namespace T4
{
enum class VariantId : std::uint8_t
{
PC,
};
class Game final : public AbstractGame
{
public:
@@ -17,6 +12,5 @@ namespace T4
[[nodiscard]] GameId GetId() const override;
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace T4
-8
View File
@@ -76,12 +76,4 @@ namespace T5
return prefixes;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC), "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
};
return variants;
}
} // namespace T5
-6
View File
@@ -4,11 +4,6 @@
namespace T5
{
enum class VariantId : std::uint8_t
{
PC,
};
class Game final : public AbstractGame
{
public:
@@ -18,6 +13,5 @@ namespace T5
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace T5
-8
View File
@@ -132,12 +132,4 @@ namespace T6
return prefixes;
}
const std::vector<IGameVariant*>& Game::GetVariants() const
{
static std::vector<IGameVariant*> variants = {
new GameVariant(std::to_underlying(VariantId::PC), "pc", GameEndianness::LE, GameWordSize::ARCH_32, GamePlatform::PC),
};
return variants;
}
} // namespace T6
-6
View File
@@ -4,11 +4,6 @@
namespace T6
{
enum class VariantId : std::uint8_t
{
PC,
};
class Game final : public AbstractGame
{
public:
@@ -18,6 +13,5 @@ namespace T6
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
[[nodiscard]] const std::vector<IGameVariant*>& GetVariants() const override;
};
} // namespace T6
+5 -5
View File
@@ -268,7 +268,7 @@ namespace
if (ignore == targetName)
continue;
if (!ReadIgnoreEntries(paths, ignore, context.m_definition->m_game, context.m_ignored_assets))
if (!ReadIgnoreEntries(paths, ignore, context.m_definition->GetGameId(), context.m_ignored_assets))
{
con::error("Failed to read asset listing for ignoring assets of project \"{}\".", ignore);
return false;
@@ -311,7 +311,7 @@ namespace
if (!LoadGdtFilesFromZoneDefinition(context.m_gdt_files, zoneDefinition, &paths.m_gdt_paths.GetSearchPaths()))
return nullptr;
return zone_creator::CreateZoneForDefinition(zoneDefinition.m_game, context);
return zone_creator::CreateZoneForDefinition(zoneDefinition.GetGameId(), zoneDefinition.m_variant, context);
}
static bool WriteZoneToFile(IOutputPath& outPath, const Zone& zone)
@@ -338,11 +338,11 @@ namespace
bool BuildFastFile(LinkerPathManager& paths, const std::string& projectName, const std::string& targetName, ZoneDefinition& zoneDefinition) const
{
const fs::path outDir(paths.m_linker_paths->BuildOutputFolderPath(projectName, zoneDefinition.m_game));
const fs::path outDir(paths.m_linker_paths->BuildOutputFolderPath(projectName, zoneDefinition.GetGameId()));
OutputPathFilesystem outputPath(outDir);
const fs::path cacheDir(paths.m_linker_paths->BuildCacheFolderPath(projectName, zoneDefinition.m_game));
const fs::path cacheDir(paths.m_linker_paths->BuildCacheFolderPath(projectName, zoneDefinition.GetGameId()));
SoundBankWriter::OutputPath = outDir;
const auto zone = CreateZoneForDefinition(paths, outDir, cacheDir, targetName, zoneDefinition);
@@ -372,7 +372,7 @@ namespace
if (!zoneDefinition)
return false;
PathGameContext gameContext(paths, projectName, zoneDefinition->m_game);
PathGameContext gameContext(paths, projectName, zoneDefinition->GetGameId());
if (!zoneDefinition->m_assets.empty())
{
+6 -6
View File
@@ -207,7 +207,7 @@ namespace
return {};
}
[[nodiscard]] std::unique_ptr<ISearchPath> BuildSearchPathsSpecificToProjectAndGame(const std::string& projectName, GameId game) const override
[[nodiscard]] std::unique_ptr<ISearchPath> BuildSearchPathsSpecificToProjectAndGame(const std::string& projectName, GameId gameId) const override
{
SearchPaths searchPaths;
std::unordered_set<std::string> addedSearchPaths;
@@ -217,7 +217,7 @@ namespace
{
if (!curTemplate.CanRender(PROJECT_MASK) && curTemplate.CanRender(GAME_MASK))
{
std::string gameName(GameId_Names[static_cast<unsigned>(game)]);
std::string gameName(IGame::GetGameById(gameId)->GetShortName());
utils::MakeStringLowerCase(gameName);
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, gameName);
@@ -292,14 +292,14 @@ namespace
return m_source_search_paths;
}
[[nodiscard]] std::string BuildCacheFolderPath(const std::string& projectName, GameId game) const override
[[nodiscard]] std::string BuildCacheFolderPath(const std::string& projectName, GameId gameId) const override
{
return m_cache_template.Render(m_bin_dir, m_base_dir, projectName, GameId_Names[static_cast<unsigned>(game)]);
return m_cache_template.Render(m_bin_dir, m_base_dir, projectName, IGame::GetGameById(gameId)->GetShortName());
}
[[nodiscard]] std::string BuildOutputFolderPath(const std::string& projectName, GameId game) const override
[[nodiscard]] std::string BuildOutputFolderPath(const std::string& projectName, GameId gameId) const override
{
return m_out_template.Render(m_bin_dir, m_base_dir, projectName, GameId_Names[static_cast<unsigned>(game)]);
return m_out_template.Render(m_bin_dir, m_base_dir, projectName, IGame::GetGameById(gameId)->GetShortName());
}
private:
+4 -4
View File
@@ -9,9 +9,9 @@
namespace
{
std::unique_ptr<Zone> CreateZone(const ZoneCreationContext& context, const GameId gameId)
std::unique_ptr<Zone> CreateZone(const ZoneCreationContext& context, const GameVariantId variantId)
{
return std::make_unique<Zone>(context.m_definition->m_name, 0, gameId, GamePlatform::PC);
return std::make_unique<Zone>(context.m_definition->m_name, 0, variantId);
}
std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context)
@@ -51,9 +51,9 @@ namespace zone_creator
lookup.Initialize(gdtFiles);
}
std::unique_ptr<Zone> CreateZoneForDefinition(GameId gameId, ZoneCreationContext& context)
std::unique_ptr<Zone> CreateZoneForDefinition(const GameId gameId, const GameVariantId variantId, ZoneCreationContext& context)
{
auto zone = CreateZone(context, gameId);
auto zone = CreateZone(context, variantId);
IgnoreReferencesFromAssets(context);
IgnoredAssetLookup ignoredAssetLookup(context.m_ignored_assets);
+1 -1
View File
@@ -5,5 +5,5 @@
namespace zone_creator
{
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(GameId game, ZoneCreationContext& context);
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(GameId gameId, GameVariantId variantId, ZoneCreationContext& context);
}
@@ -87,7 +87,7 @@ namespace
assert(image);
assert(zone);
const auto gameName = GameId_Names[std::to_underlying(zone->m_game_id)];
const auto gameName = IGame::GetGameById(zone->m_game_id)->GetShortName();
const auto toCommonConverter = ToCommonConverter::GetForGame(zone->m_game_id);
if (!toCommonConverter)
{
@@ -63,7 +63,7 @@ namespace
assert(model);
assert(zone);
const auto gameName = GameId_Names[std::to_underlying(zone->m_game_id)];
const auto gameName = IGame::GetGameById(zone->m_game_id)->GetShortName();
const auto converter = ToCommonConverter::GetForGame(zone->m_game_id);
if (!converter)
{
+1 -1
View File
@@ -68,7 +68,7 @@ namespace
.name = loadedZone.GetZone().m_name,
.filePath = loadedZone.GetFilePath(),
.game = loadedZone.GetZone().m_game_id,
.platform = loadedZone.GetZone().m_platform,
.platform = IGameVariant::GetVariantById(loadedZone.GetZone().m_variant_id)->GetPlatform(),
};
}
@@ -16,7 +16,7 @@ SequenceZoneDefinitionAssetList::SequenceZoneDefinitionAssetList()
void SequenceZoneDefinitionAssetList::ProcessMatch(ZoneDefinitionParserState* state, SequenceResult<ZoneDefinitionParserValue>& result) const
{
if (state->m_definition->m_game == GameId::COUNT)
if (!state->m_game)
{
const auto& assetListKeywordToken = result.NextCapture(CAPTURE_ASSET_LIST_KEYWORD);
throw ParsingException(assetListKeywordToken.GetPos(), "Must define game before using assetlist");
@@ -24,7 +24,7 @@ void SequenceZoneDefinitionAssetList::ProcessMatch(ZoneDefinitionParserState* st
const auto& assetListNameToken = result.NextCapture(CAPTURE_ASSET_LIST_NAME);
AssetListReader assetListReader(state->m_search_path, state->m_definition->m_game);
const AssetListReader assetListReader(state->m_search_path, (*state->m_game)->GetId());
const auto maybeAssetList = assetListReader.ReadAssetList(assetListNameToken.FieldValue());
if (!maybeAssetList)
@@ -7,10 +7,12 @@
#include <cstdint>
#include <format>
#include <optional>
#include <utility>
namespace
{
constexpr auto METADATA_GAME = "game";
constexpr auto METADATA_VARIANT = "variant";
constexpr auto METADATA_GDT = "gdt";
constexpr auto METADATA_NAME = "name";
constexpr auto METADATA_TYPE = "type";
@@ -23,10 +25,32 @@ namespace
auto upperGameName = gameName;
utils::MakeStringUpperCase(upperGameName);
for (auto i = 0u; i < static_cast<unsigned>(GameId::COUNT); i++)
for (auto curGameIdNum = 0u; curGameIdNum < std::to_underlying(GameId::COUNT); curGameIdNum++)
{
if (upperGameName == GameId_Names[i])
return static_cast<GameId>(i);
const auto curGameId = static_cast<GameId>(curGameIdNum);
const auto& curGameName = IGame::GetGameById(curGameId)->GetShortName();
if (upperGameName == curGameName)
return curGameId;
}
return std::nullopt;
}
std::optional<GameVariantId> GetVariantByName(const GameId gameId, const std::string& variantName)
{
auto lowerVariantName = variantName;
utils::MakeStringLowerCase(lowerVariantName);
for (auto curVariantIdNum = 0u; curVariantIdNum < std::to_underlying(GameVariantId::COUNT); curVariantIdNum++)
{
const auto curVariantId = static_cast<GameVariantId>(curVariantIdNum);
const auto* variant = IGameVariant::GetVariantById(curVariantId);
if (variant->GetGameId() != gameId)
continue;
const auto& curVariantName = variant->GetName();
if (lowerVariantName == curVariantName)
return curVariantId;
}
return std::nullopt;
@@ -82,11 +106,25 @@ namespace
if (!game)
throw ParsingException(valueToken.GetPos(), "Unknown game name");
const auto previousGame = state->m_definition->m_game;
if (previousGame != GameId::COUNT && previousGame != *game)
throw ParsingException(valueToken.GetPos(), std::format("Game was previously defined as: {}", GameId_Names[static_cast<unsigned>(previousGame)]));
if (!state->m_game)
state->SetGame(*game);
else if ((*state->m_game)->GetId() != *game)
throw ParsingException(valueToken.GetPos(), std::format("Game was previously defined as: {}", (*state->m_game)->GetShortName()));
}
state->SetGame(*game);
void ProcessMetaDataVariant(ZoneDefinitionParserState* state, const ZoneDefinitionParserValue& valueToken, const std::string& value)
{
if (!state->m_game)
throw ParsingException(valueToken.GetPos(), "The game must be specified before the variant");
const auto variantId = GetVariantByName((*state->m_game)->GetId(), value);
if (!variantId)
throw ParsingException(valueToken.GetPos(), "Unknown variant name");
if (!state->m_variant)
state->SetVariant(*variantId);
else if ((*state->m_variant)->GetId() != *variantId)
throw ParsingException(valueToken.GetPos(), std::format("Variant was previously defined as: {}", (*state->m_variant)->GetName()));
}
void ProcessMetaDataType(ZoneDefinitionParserState* state, const ZoneDefinitionParserValue& keyToken, const ZoneDefinitionParserValue& valueToken)
@@ -134,6 +172,10 @@ void SequenceZoneDefinitionMetaData::ProcessMatch(ZoneDefinitionParserState* sta
{
ProcessMetaDataGame(state, valueToken, value);
}
else if (key == METADATA_VARIANT)
{
ProcessMetaDataVariant(state, valueToken, value);
}
else if (key == METADATA_GDT)
{
state->m_definition->m_gdts.emplace_back(value);
@@ -2,6 +2,20 @@
#include <algorithm>
namespace
{
constexpr GameVariantId DEFAULT_VARIANT_FOR_GAME[]{
GameVariantId::IW3_PC,
GameVariantId::IW4_PC32,
GameVariantId::IW5_PC32,
GameVariantId::QOS_PC,
GameVariantId::T4_PC,
GameVariantId::T5_PC,
GameVariantId::T6_PC,
};
static_assert(std::size(DEFAULT_VARIANT_FOR_GAME) == std::to_underlying(GameId::COUNT));
} // namespace
ZoneDefinitionParserState::ZoneDefinitionParserState(std::string targetName, ISearchPath& searchPath, IParserLineStream& underlyingStream)
: m_search_path(searchPath),
m_underlying_stream(underlyingStream),
@@ -14,10 +28,16 @@ ZoneDefinitionParserState::ZoneDefinitionParserState(std::string targetName, ISe
void ZoneDefinitionParserState::SetGame(const GameId gameId)
{
m_definition->m_game = gameId;
m_definition->m_variant = DEFAULT_VARIANT_FOR_GAME[static_cast<unsigned>(gameId)];
m_game = IGame::GetGameById(gameId);
}
void ZoneDefinitionParserState::SetVariant(const GameVariantId variantId)
{
m_definition->m_variant = variantId;
m_variant = IGameVariant::GetVariantById(variantId);
}
namespace
{
void AddCurrentObjContainerToDefinitionIfNecessary(ZoneDefinition& zoneDefinition, std::optional<ZoneDefinitionObjContainer>& maybeObjContainer)
@@ -15,6 +15,7 @@ public:
ZoneDefinitionParserState(std::string targetName, ISearchPath& searchPath, IParserLineStream& underlyingStream);
void SetGame(GameId gameId);
void SetVariant(GameVariantId variantId);
void StartIPak(std::string ipakName);
void StartIwd(std::string iwdName);
@@ -26,6 +27,7 @@ public:
std::unordered_set<std::string> m_inclusions;
std::optional<IGame*> m_game;
std::optional<IGameVariant*> m_variant;
std::optional<ZoneDefinitionObjContainer> m_current_ipak;
std::optional<ZoneDefinitionObjContainer> m_current_iwd;
@@ -34,6 +34,14 @@ void ZoneDefinitionProperties::Include(const ZoneDefinitionProperties& otherProp
}
ZoneDefinition::ZoneDefinition()
: m_game(GameId::COUNT)
: m_variant(GameVariantId::COUNT)
{
}
GameId ZoneDefinition::GetGameId() const
{
if (m_variant < GameVariantId::COUNT)
return IGameVariant::GetVariantById(m_variant)->GetGameId();
return GameId::COUNT;
}
@@ -1,5 +1,6 @@
#pragma once
#include "Game/GameVariant.h"
#include "Game/IGame.h"
#include "Zone/AssetList/AssetList.h"
#include "Zone/ZoneTypes.h"
@@ -61,8 +62,10 @@ class ZoneDefinition
public:
ZoneDefinition();
[[nodiscard]] GameId GetGameId() const;
std::string m_name;
GameId m_game;
GameVariantId m_variant;
ZoneDefinitionProperties m_properties;
std::vector<std::string> m_ignores;
std::vector<std::string> m_targets_to_build;
+3 -3
View File
@@ -2,12 +2,12 @@
#include "ZoneRegistry.h"
Zone::Zone(std::string name, const zone_priority_t priority, const GameId gameId, const GamePlatform platform)
Zone::Zone(std::string name, const zone_priority_t priority, const GameVariantId variantId)
: m_name(std::move(name)),
m_priority(priority),
m_language(GameLanguage::LANGUAGE_NONE),
m_game_id(gameId),
m_platform(platform),
m_game_id(IGameVariant::GetVariantById(variantId)->GetGameId()),
m_variant_id(variantId),
m_pools(*this, priority),
m_memory(std::make_unique<ZoneMemory>()),
m_registered(false)
+3 -2
View File
@@ -1,6 +1,7 @@
#pragma once
#include "Game/GameLanguage.h"
#include "Game/GameVariant.h"
#include "Game/IGame.h"
#include "Pool/AssetPool.h"
#include "Zone/ZoneTypes.h"
@@ -13,7 +14,7 @@
class Zone
{
public:
Zone(std::string name, zone_priority_t priority, GameId gameId, GamePlatform platform);
Zone(std::string name, zone_priority_t priority, GameVariantId variantId);
~Zone();
Zone(const Zone& other) = delete;
Zone(Zone&& other) noexcept = delete;
@@ -28,7 +29,7 @@ public:
zone_priority_t m_priority;
GameLanguage m_language;
GameId m_game_id;
GamePlatform m_platform;
GameVariantId m_variant_id;
ZoneScriptStrings m_script_strings;
ZoneAssetPools m_pools;
@@ -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;
+78 -87
View File
@@ -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());
+3 -6
View File
@@ -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"
@@ -56,7 +56,7 @@ namespace
TEST_CASE("TechniqueCompilerIW3", "[iw3][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.Register();
MemoryManager memory;
@@ -31,7 +31,7 @@ namespace
TEST_CASE("TechsetCompilerIW3", "[techset][iw3][compiler]")
{
Zone zone("test", 0, GameId::IW3, GamePlatform::PC);
Zone zone("test", 0, GameVariantId::IW3_PC);
AssetCreatorCollection creators(zone);
IgnoredAssetLookup ignoredAssets;
AssetCreationContext context(zone, &creators, &ignoredAssets);
@@ -11,7 +11,7 @@ using namespace std::literals;
TEST_CASE("VertexDeclCompilerIW3", "[iw3][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.Register();
MemoryManager memory;
@@ -56,7 +56,7 @@ namespace
TEST_CASE("TechniqueCompilerIW4", "[iw4][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW4_PC32);
zone.Register();
MemoryManager memory;
@@ -28,7 +28,7 @@ namespace
TEST_CASE("TechsetCompilerIW4", "[techset][iw4][compiler]")
{
Zone zone("test", 0, GameId::IW4, GamePlatform::PC);
Zone zone("test", 0, GameVariantId::IW4_PC32);
AssetCreatorCollection creators(zone);
IgnoredAssetLookup ignoredAssets;
AssetCreationContext context(zone, &creators, &ignoredAssets);
@@ -11,7 +11,7 @@ using namespace std::literals;
TEST_CASE("VertexDeclCompilerIW4", "[iw4][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW4_PC32);
zone.Register();
MemoryManager memory;
@@ -56,7 +56,7 @@ namespace
TEST_CASE("TechniqueCompilerIW5", "[iw5][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW5_PC32);
zone.Register();
MemoryManager memory;
@@ -28,7 +28,7 @@ namespace
TEST_CASE("TechsetCompilerIW5", "[techset][iw5][compiler]")
{
Zone zone("test", 0, GameId::IW5, GamePlatform::PC);
Zone zone("test", 0, GameVariantId::IW5_PC32);
AssetCreatorCollection creators(zone);
IgnoredAssetLookup ignoredAssets;
AssetCreationContext context(zone, &creators, &ignoredAssets);
@@ -1,5 +1,6 @@
#include "Game/IW5/Techset/VertexDeclCompilerIW5.h"
#include "Game/IW5/GameIW5.h"
#include "Game/IW5/IW5.h"
#include "Utils/MemoryManager.h"
@@ -11,7 +12,7 @@ using namespace std::literals;
TEST_CASE("VertexDeclCompilerIW5", "[iw5][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW5_PC32);
zone.Register();
MemoryManager memory;
@@ -56,7 +56,7 @@ namespace
TEST_CASE("TechniqueCompilerT5", "[t5][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
zone.Register();
MemoryManager memory;
@@ -28,7 +28,7 @@ namespace
TEST_CASE("TechsetCompilerT5", "[techset][t5][compiler]")
{
Zone zone("test", 0, GameId::T5, GamePlatform::PC);
Zone zone("test", 0, GameVariantId::T5_PC);
AssetCreatorCollection creators(zone);
IgnoredAssetLookup ignoredAssets;
AssetCreationContext context(zone, &creators, &ignoredAssets);
@@ -11,7 +11,7 @@ using namespace std::literals;
TEST_CASE("VertexDeclCompilerT5", "[t5][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::T5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T5_PC);
zone.Register();
MemoryManager memory;
@@ -19,7 +19,7 @@ namespace
public:
TestContext()
: m_memory(),
m_zone("test", 0, GameId::T6, GamePlatform::PC),
m_zone("test", 0, GameVariantId::T6_PC),
m_zone_definition(),
m_zone_states(m_zone),
m_creators(m_zone),
@@ -56,7 +56,7 @@ namespace
TEST_CASE("TechniqueCompilerT6", "[t6][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
zone.Register();
MemoryManager memory;
@@ -28,7 +28,7 @@ namespace
TEST_CASE("TechsetCompilerT6", "[techset][t6][compiler]")
{
Zone zone("test", 0, GameId::T6, GamePlatform::PC);
Zone zone("test", 0, GameVariantId::T6_PC);
AssetCreatorCollection creators(zone);
IgnoredAssetLookup ignoredAssets;
AssetCreationContext context(zone, &creators, &ignoredAssets);
@@ -11,7 +11,7 @@ using namespace std::literals;
TEST_CASE("VertexDeclCompilerT6", "[t6][techset][compiler]")
{
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
zone.Register();
MemoryManager memory;
@@ -20,7 +20,7 @@ namespace
{
public:
TestContext()
: m_zone("test", 0, GameId::T6, GamePlatform::PC),
: m_zone("test", 0, GameVariantId::T6_PC),
m_zone_states(m_zone),
m_out_dir()
{
@@ -20,7 +20,7 @@ namespace
{
public:
TestContext()
: m_zone("test", 0, GameId::T6, GamePlatform::PC),
: m_zone("test", 0, GameVariantId::T6_PC),
m_zone_definition(),
m_zone_definition_context(m_zone_definition),
m_zone_states(m_zone),
@@ -19,7 +19,7 @@ namespace
{
public:
TestContext()
: m_zone("test", 0, GameId::T6, GamePlatform::PC),
: m_zone("test", 0, GameVariantId::T6_PC),
m_zone_definition(),
m_zone_definition_context(m_zone_definition),
m_zone_states(m_zone),
@@ -23,7 +23,7 @@ namespace
{
public:
TestContext()
: m_zone("test", 0, GameId::T6, GamePlatform::PC),
: m_zone("test", 0, GameVariantId::T6_PC),
m_zone_states(m_zone),
m_out_dir()
{
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/_testimage.dds", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/testimage.iwi", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -274,7 +274,7 @@ namespace
]
})MATERIAL");
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -20,7 +20,7 @@ namespace
{
public:
MenuLoadingTestHelper()
: m_zone("MockZone", 0, GameId::IW3, GamePlatform::PC),
: m_zone("MockZone", 0, GameVariantId::IW3_PC),
m_creator_collection(m_zone),
m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup)
{
@@ -21,7 +21,7 @@ namespace
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("physic/test_phys_preset", RAW_PHYS_PRESET);
Zone loadingZone("LoadingZone", 0, GameId::IW3, GamePlatform::PC);
Zone loadingZone("LoadingZone", 0, GameVariantId::IW3_PC);
AssetCreatorCollection creatorCollection(loadingZone);
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext loadingContext(loadingZone, &creatorCollection, &ignoredAssetLookup);
@@ -18,7 +18,7 @@ namespace
"test,data,lol\n"
"lorem,ipsum");
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/_testimage.dds", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW4_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/testimage.iwi", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW4_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -277,7 +277,7 @@ namespace
]
})MATERIAL");
Zone zone("MockZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW4_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -30,7 +30,7 @@ namespace test::game::iw4::menu::parsing::it
public:
MenuParsingItHelper()
: m_zone("MockZone", 0, GameId::IW4, GamePlatform::PC),
: m_zone("MockZone", 0, GameVariantId::IW4_PC32),
m_creator_collection(m_zone),
m_ignored_asset_lookup(),
m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup)
@@ -21,7 +21,7 @@ namespace
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("physic/test_phys_preset", RAW_PHYS_PRESET);
Zone loadingZone("LoadingZone", 0, GameId::IW4, GamePlatform::PC);
Zone loadingZone("LoadingZone", 0, GameVariantId::IW4_PC32);
AssetCreatorCollection creatorCollection(loadingZone);
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext loadingContext(loadingZone, &creatorCollection, &ignoredAssetLookup);
@@ -20,7 +20,7 @@ namespace
"test,data,lol\n"
"lorem,ipsum");
Zone zone("MockZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW4_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -85,7 +85,7 @@ tag_trophy_04_fx)"
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("vehicles/test_vehicle", RAW_VEHICLE);
Zone zone("LoadingZone", 0, GameId::IW4, GamePlatform::PC);
Zone zone("LoadingZone", 0, GameVariantId::IW4_PC32);
auto* physPresetInfo = GivenTestPhysPreset("vehicle_tank", zone);
auto* weaponInfo = GivenTestWeapon("sp/bradley_turret", zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/_testimage.dds", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW5_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/testimage.iwi", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW5_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -301,7 +301,7 @@ namespace
]
})MATERIAL");
Zone zone("MockZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW5_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -24,7 +24,7 @@ namespace
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("physic/test_phys_preset", RAW_PHYS_PRESET);
Zone loadingZone("LoadingZone", 0, GameId::IW5, GamePlatform::PC);
Zone loadingZone("LoadingZone", 0, GameVariantId::IW5_PC32);
AssetCreatorCollection creatorCollection(loadingZone);
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext loadingContext(loadingZone, &creatorCollection, &ignoredAssetLookup);
@@ -19,7 +19,7 @@ namespace
"test,data,lol\n"
"lorem,ipsum");
Zone zone("MockZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW5_PC32);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -111,7 +111,7 @@ tag_trophy_04_fx\trophyExplodeFx\testfx1\trophyFlashFx\testfx2)"
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("vehicles/test_vehicle", RAW_VEHICLE);
Zone zone("LoadingZone", 0, GameId::IW5, GamePlatform::PC);
Zone zone("LoadingZone", 0, GameVariantId::IW5_PC32);
auto* physPresetInfo = GivenTestPhysPreset("vehicle_tank", zone);
auto* weaponInfo = GivenTestWeapon("sp/bradley_turret", zone);
@@ -20,7 +20,7 @@ namespace
{
public:
MenuLoadingTestHelper()
: m_zone("MockZone", 0, GameId::T4, GamePlatform::PC),
: m_zone("MockZone", 0, GameVariantId::T4_PC),
m_creator_collection(m_zone),
m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup)
{
@@ -22,7 +22,7 @@ namespace
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("physic/test_phys_preset", RAW_PHYS_PRESET);
Zone loadingZone("LoadingZone", 0, GameId::T4, GamePlatform::PC);
Zone loadingZone("LoadingZone", 0, GameVariantId::T4_PC);
AssetCreatorCollection creatorCollection(loadingZone);
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext loadingContext(loadingZone, &creatorCollection, &ignoredAssetLookup);
@@ -19,7 +19,7 @@ namespace
"test,data,lol\n"
"lorem,ipsum");
Zone zone("MockZone", 0, GameId::T4, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T4_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/_testimage.dds", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::T5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T5_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/testimage.iwi", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::T5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T5_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -358,7 +358,7 @@ namespace
]
})MATERIAL");
Zone zone("MockZone", 0, GameId::T5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T5_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -24,7 +24,7 @@ namespace
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("physic/test_phys_preset", RAW_PHYS_PRESET);
Zone loadingZone("LoadingZone", 0, GameId::T5, GamePlatform::PC);
Zone loadingZone("LoadingZone", 0, GameVariantId::T5_PC);
AssetCreatorCollection creatorCollection(loadingZone);
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext loadingContext(loadingZone, &creatorCollection, &ignoredAssetLookup);
@@ -19,7 +19,7 @@ namespace
"test,data,lol\n"
"lorem,ipsum");
Zone zone("MockZone", 0, GameId::T5, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T5_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -79,7 +79,7 @@ namespace
]
})FONT_ICON");
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/_testimage.dds", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -32,7 +32,7 @@ namespace
searchPath.AddFileData("images/testimage.iwi", std::string(data.get(), fileSize));
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -241,7 +241,7 @@ namespace
]
})MATERIAL");
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -24,7 +24,7 @@ namespace
MockSearchPath loadingSearchPath;
loadingSearchPath.AddFileData("physic/test_phys_preset", RAW_PHYS_PRESET);
Zone loadingZone("LoadingZone", 0, GameId::T6, GamePlatform::PC);
Zone loadingZone("LoadingZone", 0, GameVariantId::T6_PC);
AssetCreatorCollection creatorCollection(loadingZone);
IgnoredAssetLookup ignoredAssetLookup;
AssetCreationContext loadingContext(loadingZone, &creatorCollection, &ignoredAssetLookup);
@@ -19,7 +19,7 @@ namespace
"test,data,lol\n"
"lorem,ipsum");
Zone zone("MockZone", 0, GameId::T6, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::T6_PC);
MemoryManager memory;
AssetCreatorCollection creatorCollection(zone);
@@ -550,7 +550,7 @@ namespace
]
})MATERIAL");
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
MemoryManager memory;
MockSearchPath mockObjPath;
@@ -212,7 +212,7 @@ namespace
menu.itemCount = static_cast<int>(std::size(items));
menu.items = items;
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<menuDef_t>>(ASSET_TYPE_MENU, menu.window.name, &menu));
MockSearchPath mockObjPath;
@@ -377,7 +377,7 @@ namespace
menu.itemCount = static_cast<int>(std::size(items));
menu.items = items;
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<menuDef_t>>(ASSET_TYPE_MENU, menu.window.name, &menu));
MockSearchPath mockObjPath;
@@ -426,7 +426,7 @@ namespace
menuList.menuCount = static_cast<int>(std::size(menus));
menuList.menus = menus;
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<menuDef_t>>(ASSET_TYPE_MENU, menu.window.name, &menu));
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<MenuList>>(ASSET_TYPE_MENULIST, menuList.name, &menuList));
@@ -531,7 +531,7 @@ namespace
menu.itemCount = static_cast<int>(std::size(items));
menu.items = items;
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<menuDef_t>>(ASSET_TYPE_MENU, menu.window.name, &menu));
MockSearchPath mockObjPath;
@@ -29,7 +29,7 @@ namespace
menuList.menuCount = static_cast<int>(std::size(menus));
menuList.menus = menus;
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.m_pools.AddAsset(std::make_unique<XAssetInfo<MenuList>>(ASSET_TYPE_MENULIST, menuList.name, &menuList));
MockSearchPath mockObjPath;
@@ -32,7 +32,7 @@ namespace
std::string DumpPhysPreset(PhysPreset& physPreset)
{
Zone dumpingZone("DumpingZone", 0, GameId::IW3, GamePlatform::PC);
Zone dumpingZone("DumpingZone", 0, GameVariantId::IW3_PC);
dumpingZone.m_pools.AddAsset(std::make_unique<XAssetInfo<PhysPreset>>(ASSET_TYPE_PHYSPRESET, physPreset.name, &physPreset));
MockSearchPath dumpingObjPath;
@@ -255,7 +255,7 @@ namespace
TEST_CASE("TechsetDumperIW3", "[iw3][techset][dumper]")
{
Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC);
Zone zone("MockZone", 0, GameVariantId::IW3_PC);
zone.Register();
MemoryManager memory;
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff. Show more