2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-17 14:02:12 +00:00

feat: initial T4 support (#807)

* feat: initial T4 support

* chore: adjust t4 symbols a bit for accuracy

* chore: add PackIndex asset to T4

* chore: remove unused AssetXModelPieces

* chore: add default and global asset pools loader for T4

* chore: use separate defines for T4 in ImageDumper

* chore: remove unnecessary namespaces in gfximage_actions

* chore: small things

* chore: fix T4 PhysPreset type

* chore: use proper XQuat2 type for T4 xanims

* chore: fix errors on T4 types

* chore: use iw3 like struct for XModelStreamInfo

* docs: add basic docs for T4

* chore: add basic ObjCompiler setup for T4

* chore: adjust loaded sound definition

* chore: make sure t4 material has the correct alignment

* chore: make sure t4 uses similar names for assets as other games

* fix: asset references should not be reusable

* chore: add content writer for t4

* feat: add t4 localize loader

* chore: reorder game ids to be alphabetically ordered

---------

Co-authored-by: Jan Laupetin <jan@laupetin.net>
This commit is contained in:
mo
2026-06-07 13:06:33 +01:00
committed by GitHub
parent 04628fc52c
commit 44d6710991
88 changed files with 6787 additions and 18 deletions
@@ -0,0 +1,33 @@
#include "ZoneDefWriterT4.h"
#include "Game/T4/T4.h"
using namespace T4;
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone& zone) const {}
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone, const ZoneDefFilter& filter) const
{
const auto* game = IGame::GetGameById(zone.m_game_id);
// Localized strings are all collected in one string file. So only add this to the zone file.
auto localizePoolAssets = zone.m_pools.PoolAssets<AssetLocalize>();
if (localizePoolAssets.begin() != localizePoolAssets.end())
stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
for (const auto& asset : zone.m_pools)
{
if (!filter.ShouldWriteAsset(*asset))
continue;
switch (asset->m_type)
{
case ASSET_TYPE_LOCALIZE_ENTRY:
break;
default:
stream.WriteEntry(*game->GetAssetTypeName(asset->m_type), asset->m_name);
break;
}
}
}
@@ -0,0 +1,13 @@
#pragma once
#include "Zone/Definition/ZoneDefWriter.h"
namespace T4
{
class ZoneDefWriter final : public AbstractZoneDefWriter
{
protected:
void WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone& zone) const override;
void WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone, const ZoneDefFilter& filter) const override;
};
} // namespace T4
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include "Game/T4/T4.h"
#include "Zone/ZoneTypes.h"
#include <cstdint>
#include <string>
namespace T4
{
class ZoneConstants final
{
ZoneConstants() = default;
public:
static constexpr const char* MAGIC_UNSIGNED = "IWffu100";
static constexpr int ZONE_VERSION_PC = 387;
static_assert(std::char_traits<char>::length(MAGIC_UNSIGNED) == sizeof(ZoneHeader::m_magic));
static constexpr size_t AUTHED_CHUNK_SIZE = 0x2000;
static constexpr unsigned OFFSET_BLOCK_BIT_COUNT = 3u;
static constexpr block_t INSERT_BLOCK = XFILE_BLOCK_VIRTUAL;
};
} // namespace T4
+3 -1
View File
@@ -196,13 +196,15 @@ XAssetInfoGeneric* GameGlobalAssetPools::GetAsset(const asset_type_t assetType,
GameGlobalAssetPools* GameGlobalAssetPools::GetGlobalPoolsForGame(GameId gameId)
{
static GameGlobalAssetPools* globalAssetPools[static_cast<unsigned>(GameId::COUNT)]{
static GameGlobalAssetPools* globalAssetPools[]{
new GameGlobalAssetPools(GameId::IW3),
new GameGlobalAssetPools(GameId::IW4),
new GameGlobalAssetPools(GameId::IW5),
new GameGlobalAssetPools(GameId::T4),
new GameGlobalAssetPools(GameId::T5),
new GameGlobalAssetPools(GameId::T6),
};
static_assert(std::extent_v<decltype(globalAssetPools)> == static_cast<unsigned>(GameId::COUNT));
assert(static_cast<unsigned>(gameId) < static_cast<unsigned>(GameId::COUNT));
auto* result = globalAssetPools[static_cast<unsigned>(gameId)];
@@ -3,6 +3,7 @@
#include "Game/IW3/Zone/Definition/ZoneDefWriterIW3.h"
#include "Game/IW4/Zone/Definition/ZoneDefWriterIW4.h"
#include "Game/IW5/Zone/Definition/ZoneDefWriterIW5.h"
#include "Game/T4/Zone/Definition/ZoneDefWriterT4.h"
#include "Game/T5/Zone/Definition/ZoneDefWriterT5.h"
#include "Game/T6/Zone/Definition/ZoneDefWriterT6.h"
#include "Pool/XAssetInfo.h"
@@ -43,13 +44,15 @@ bool ZoneDefFilter::ShouldWriteAsset(const XAssetInfoGeneric& asset) const
const IZoneDefWriter* IZoneDefWriter::GetZoneDefWriterForGame(GameId game)
{
static const IZoneDefWriter* zoneDefWriters[static_cast<unsigned>(GameId::COUNT)]{
static const IZoneDefWriter* zoneDefWriters[]{
new IW3::ZoneDefWriter(),
new IW4::ZoneDefWriter(),
new IW5::ZoneDefWriter(),
new T4::ZoneDefWriter(),
new T5::ZoneDefWriter(),
new T6::ZoneDefWriter(),
};
static_assert(std::extent_v<decltype(zoneDefWriters)> == static_cast<unsigned>(GameId::COUNT));
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
const auto* result = zoneDefWriters[static_cast<unsigned>(game)];