2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-10-23 06:46:00 +00:00

refactor: only refer to game id in zone

This commit is contained in:
Jan Laupetin
2025-08-30 16:49:09 +02:00
parent 495e85f945
commit 734173066b
56 changed files with 145 additions and 193 deletions

View File

@@ -4,6 +4,7 @@
#include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/GameIW3.h"
#include "ObjWriting.h"
#include "Zone/ZoneRegistry.h"
namespace IW3
{
@@ -199,7 +200,7 @@ namespace IW3
void MaterialConstantZoneState::ExtractNamesFromZoneInternal()
{
for (const auto* zone : IGame::GetGameById(GameId::IW3)->GetZones())
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW3)->Zones())
{
const auto* assetPools = dynamic_cast<const GameAssetPoolIW3*>(zone->m_pools.get());
if (!assetPools)

View File

@@ -4,6 +4,7 @@
#include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/GameIW4.h"
#include "ObjWriting.h"
#include "Zone/ZoneRegistry.h"
namespace IW4
{
@@ -199,7 +200,7 @@ namespace IW4
void MaterialConstantZoneState::ExtractNamesFromZoneInternal()
{
for (const auto* zone : IGame::GetGameById(GameId::IW4)->GetZones())
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW4)->Zones())
{
const auto* assetPools = dynamic_cast<const GameAssetPoolIW4*>(zone->m_pools.get());
if (!assetPools)

View File

@@ -4,6 +4,7 @@
#include "Game/IW5/GameAssetPoolIW5.h"
#include "Game/IW5/GameIW5.h"
#include "ObjWriting.h"
#include "Zone/ZoneRegistry.h"
namespace IW5
{
@@ -199,7 +200,7 @@ namespace IW5
void MaterialConstantZoneState::ExtractNamesFromZoneInternal()
{
for (const auto* zone : IGame::GetGameById(GameId::IW5)->GetZones())
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::IW5)->Zones())
{
const auto* iw5AssetPools = dynamic_cast<const GameAssetPoolIW5*>(zone->m_pools.get());
if (!iw5AssetPools)

View File

@@ -4,6 +4,7 @@
#include "Game/T5/GameAssetPoolT5.h"
#include "Game/T5/GameT5.h"
#include "ObjWriting.h"
#include "Zone/ZoneRegistry.h"
namespace T5
{
@@ -473,7 +474,7 @@ namespace T5
void MaterialConstantZoneState::ExtractNamesFromZoneInternal()
{
for (const auto* zone : IGame::GetGameById(GameId::T6)->GetZones())
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::T5)->Zones())
{
const auto* assetPools = dynamic_cast<const GameAssetPoolT5*>(zone->m_pools.get());
if (!assetPools)

View File

@@ -4,6 +4,7 @@
#include "Game/T6/GameAssetPoolT6.h"
#include "Game/T6/GameT6.h"
#include "ObjWriting.h"
#include "Zone/ZoneRegistry.h"
namespace T6
{
@@ -473,7 +474,7 @@ namespace T6
void MaterialConstantZoneState::ExtractNamesFromZoneInternal()
{
for (const auto* zone : IGame::GetGameById(GameId::T6)->GetZones())
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::T6)->Zones())
{
const auto* t6AssetPools = dynamic_cast<const GameAssetPoolT6*>(zone->m_pools.get());
if (!t6AssetPools)

View File

@@ -7,13 +7,14 @@
#include "Game/T6/SoundConstantsT6.h"
#include "ObjContainer/SoundBank/SoundBank.h"
#include "Sound/WavWriter.h"
#include "nlohmann/json.hpp"
#include "Zone/ZoneRegistry.h"
#include <algorithm>
#include <cmath>
#include <filesystem>
#include <format>
#include <fstream>
#include <nlohmann/json.hpp>
#include <sstream>
#include <unordered_set>
@@ -201,7 +202,7 @@ namespace
public:
void Initialize()
{
for (const auto& zone : IGame::GetGameById(GameId::T6)->GetZones())
for (const auto& zone : ZoneRegistry::GetRegistryForGame(GameId::T6)->Zones())
{
auto& sndBankPool = *dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get())->m_sound_bank;
for (auto* entry : sndBankPool)

View File

@@ -562,7 +562,8 @@ namespace
if (!mtlFile)
return;
const auto writer = obj::CreateMtlWriter(*mtlFile, context.m_zone.m_game->GetShortName(), context.m_zone.m_name);
const auto* game = IGame::GetGameById(context.m_zone.m_game_id);
const auto writer = obj::CreateMtlWriter(*mtlFile, game->GetShortName(), context.m_zone.m_name);
DistinctMapper<Material*> materialMapper(model->numsurfs);
writer->Write(common);
@@ -576,8 +577,9 @@ namespace
if (!assetFile)
return;
const auto* game = IGame::GetGameById(context.m_zone.m_game_id);
const auto writer =
obj::CreateObjWriter(*assetFile, std::format("{}.mtl", model->name), context.m_zone.m_game->GetShortName(), context.m_zone.m_name);
obj::CreateObjWriter(*assetFile, std::format("{}.mtl", model->name), game->GetShortName(), context.m_zone.m_name);
DistinctMapper<Material*> materialMapper(model->numsurfs);
writer->Write(common);
@@ -591,7 +593,8 @@ namespace
if (!assetFile)
return;
const auto writer = xmodel_export::CreateWriterForVersion6(*assetFile, context.m_zone.m_game->GetShortName(), context.m_zone.m_name);
const auto* game = IGame::GetGameById(context.m_zone.m_game_id);
const auto writer = xmodel_export::CreateWriterForVersion6(*assetFile, game->GetShortName(), context.m_zone.m_name);
writer->Write(common);
}
@@ -603,7 +606,8 @@ namespace
if (!assetFile)
return;
const auto writer = xmodel_bin::CreateWriterForVersion7(*assetFile, context.m_zone.m_game->GetShortName(), context.m_zone.m_name);
const auto* game = IGame::GetGameById(context.m_zone.m_game_id);
const auto writer = xmodel_bin::CreateWriterForVersion7(*assetFile, game->GetShortName(), context.m_zone.m_name);
writer->Write(common);
}
@@ -617,8 +621,9 @@ namespace
if (!assetFile)
return;
const auto* game = IGame::GetGameById(context.m_zone.m_game_id);
const auto output = std::make_unique<T>(*assetFile);
const auto writer = gltf::Writer::CreateWriter(output.get(), context.m_zone.m_game->GetShortName(), context.m_zone.m_name);
const auto writer = gltf::Writer::CreateWriter(output.get(), game->GetShortName(), context.m_zone.m_name);
writer->Write(common);
}