Merge pull request #291 from Laupetin/refactor/game-based-interfaces

refactor: interfaces with game implementations
This commit is contained in:
Jan 2024-10-19 15:12:28 +02:00 committed by GitHub
commit 3aaa821b74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
69 changed files with 343 additions and 470 deletions

View File

@ -36,6 +36,7 @@ public:
IGame& operator=(const IGame& other) = default; IGame& operator=(const IGame& other) = default;
IGame& operator=(IGame&& other) noexcept = default; IGame& operator=(IGame&& other) noexcept = default;
virtual GameId GetId() = 0;
virtual std::string GetFullName() = 0; virtual std::string GetFullName() = 0;
virtual std::string GetShortName() = 0; virtual std::string GetShortName() = 0;
virtual void AddZone(Zone* zone) = 0; virtual void AddZone(Zone* zone) = 0;

View File

@ -8,6 +8,11 @@ using namespace IW3;
GameIW3 g_GameIW3; GameIW3 g_GameIW3;
GameId GameIW3::GetId()
{
return GameId::IW3;
}
std::string GameIW3::GetFullName() std::string GameIW3::GetFullName()
{ {
return "Call Of Duty 4: Modern Warfare"; return "Call Of Duty 4: Modern Warfare";

View File

@ -1,17 +1,19 @@
#pragma once #pragma once
#include "Game/IGame.h" #include "Game/IGame.h"
class GameIW3 : public IGame class GameIW3 final : public IGame
{ {
std::vector<Zone*> m_zones;
public: public:
GameId GetId() override;
std::string GetFullName() override; std::string GetFullName() override;
std::string GetShortName() override; std::string GetShortName() override;
void AddZone(Zone* zone) override; void AddZone(Zone* zone) override;
void RemoveZone(Zone* zone) override; void RemoveZone(Zone* zone) override;
std::vector<Zone*> GetZones() override; std::vector<Zone*> GetZones() override;
std::vector<GameLanguagePrefix> GetLanguagePrefixes() override; std::vector<GameLanguagePrefix> GetLanguagePrefixes() override;
private:
std::vector<Zone*> m_zones;
}; };
extern GameIW3 g_GameIW3; extern GameIW3 g_GameIW3;

View File

@ -8,6 +8,11 @@ using namespace IW4;
GameIW4 g_GameIW4; GameIW4 g_GameIW4;
GameId GameIW4::GetId()
{
return GameId::IW4;
}
std::string GameIW4::GetFullName() std::string GameIW4::GetFullName()
{ {
return "Call Of Duty: Modern Warfare 2"; return "Call Of Duty: Modern Warfare 2";

View File

@ -1,17 +1,19 @@
#pragma once #pragma once
#include "Game/IGame.h" #include "Game/IGame.h"
class GameIW4 : public IGame class GameIW4 final : public IGame
{ {
std::vector<Zone*> m_zones;
public: public:
GameId GetId() override;
std::string GetFullName() override; std::string GetFullName() override;
std::string GetShortName() override; std::string GetShortName() override;
void AddZone(Zone* zone) override; void AddZone(Zone* zone) override;
void RemoveZone(Zone* zone) override; void RemoveZone(Zone* zone) override;
std::vector<Zone*> GetZones() override; std::vector<Zone*> GetZones() override;
std::vector<GameLanguagePrefix> GetLanguagePrefixes() override; std::vector<GameLanguagePrefix> GetLanguagePrefixes() override;
private:
std::vector<Zone*> m_zones;
}; };
extern GameIW4 g_GameIW4; extern GameIW4 g_GameIW4;

View File

@ -8,6 +8,11 @@ using namespace IW5;
GameIW5 g_GameIW5; GameIW5 g_GameIW5;
GameId GameIW5::GetId()
{
return GameId::IW5;
}
std::string GameIW5::GetFullName() std::string GameIW5::GetFullName()
{ {
return "Call Of Duty: Modern Warfare 3"; return "Call Of Duty: Modern Warfare 3";

View File

@ -1,17 +1,19 @@
#pragma once #pragma once
#include "Game/IGame.h" #include "Game/IGame.h"
class GameIW5 : public IGame class GameIW5 final : public IGame
{ {
std::vector<Zone*> m_zones;
public: public:
GameId GetId() override;
std::string GetFullName() override; std::string GetFullName() override;
std::string GetShortName() override; std::string GetShortName() override;
void AddZone(Zone* zone) override; void AddZone(Zone* zone) override;
void RemoveZone(Zone* zone) override; void RemoveZone(Zone* zone) override;
std::vector<Zone*> GetZones() override; std::vector<Zone*> GetZones() override;
std::vector<GameLanguagePrefix> GetLanguagePrefixes() override; std::vector<GameLanguagePrefix> GetLanguagePrefixes() override;
private:
std::vector<Zone*> m_zones;
}; };
extern GameIW5 g_GameIW5; extern GameIW5 g_GameIW5;

View File

@ -8,6 +8,11 @@ using namespace T5;
GameT5 g_GameT5; GameT5 g_GameT5;
GameId GameT5::GetId()
{
return GameId::T5;
}
std::string GameT5::GetFullName() std::string GameT5::GetFullName()
{ {
return "Call Of Duty: Black Ops"; return "Call Of Duty: Black Ops";

View File

@ -1,17 +1,19 @@
#pragma once #pragma once
#include "Game/IGame.h" #include "Game/IGame.h"
class GameT5 : public IGame class GameT5 final : public IGame
{ {
std::vector<Zone*> m_zones;
public: public:
GameId GetId() override;
std::string GetFullName() override; std::string GetFullName() override;
std::string GetShortName() override; std::string GetShortName() override;
void AddZone(Zone* zone) override; void AddZone(Zone* zone) override;
void RemoveZone(Zone* zone) override; void RemoveZone(Zone* zone) override;
std::vector<Zone*> GetZones() override; std::vector<Zone*> GetZones() override;
std::vector<GameLanguagePrefix> GetLanguagePrefixes() override; std::vector<GameLanguagePrefix> GetLanguagePrefixes() override;
private:
std::vector<Zone*> m_zones;
}; };
extern GameT5 g_GameT5; extern GameT5 g_GameT5;

View File

@ -8,6 +8,11 @@ using namespace T6;
GameT6 g_GameT6; GameT6 g_GameT6;
GameId GameT6::GetId()
{
return GameId::T6;
}
std::string GameT6::GetFullName() std::string GameT6::GetFullName()
{ {
return "Call Of Duty: Black Ops II"; return "Call Of Duty: Black Ops II";

View File

@ -1,17 +1,19 @@
#pragma once #pragma once
#include "Game/IGame.h" #include "Game/IGame.h"
class GameT6 : public IGame class GameT6 final : public IGame
{ {
std::vector<Zone*> m_zones;
public: public:
GameId GetId() override;
std::string GetFullName() override; std::string GetFullName() override;
std::string GetShortName() override; std::string GetShortName() override;
void AddZone(Zone* zone) override; void AddZone(Zone* zone) override;
void RemoveZone(Zone* zone) override; void RemoveZone(Zone* zone) override;
std::vector<Zone*> GetZones() override; std::vector<Zone*> GetZones() override;
std::vector<GameLanguagePrefix> GetLanguagePrefixes() override; std::vector<GameLanguagePrefix> GetLanguagePrefixes() override;
private:
std::vector<Zone*> m_zones;
}; };
extern GameT6 g_GameT6; extern GameT6 g_GameT6;

View File

@ -3,6 +3,7 @@
#include "AssetLoading/AssetLoadingContext.h" #include "AssetLoading/AssetLoadingContext.h"
#include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/GameIW3.h" #include "Game/IW3/GameIW3.h"
#include "IObjLoader.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "Utils/StringUtils.h" #include "Utils/StringUtils.h"
@ -53,13 +54,14 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context)); const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
ApplyIgnoredAssets(context, *assetLoadingContext); ApplyIgnoredAssets(context, *assetLoadingContext);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::IW3);
for (const auto& assetEntry : context.m_definition->m_assets) for (const auto& assetEntry : context.m_definition->m_assets)
{ {
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name)) if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
return nullptr; return nullptr;
} }
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext); objLoader->FinalizeAssetsForZone(*assetLoadingContext);
return zone; return zone;
} }

View File

@ -2,6 +2,7 @@
#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/GameIW4.h" #include "Game/IW4/GameIW4.h"
#include "IObjLoader.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "Utils/StringUtils.h" #include "Utils/StringUtils.h"
@ -52,13 +53,14 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context)); const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
ApplyIgnoredAssets(context, *assetLoadingContext); ApplyIgnoredAssets(context, *assetLoadingContext);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::IW4);
for (const auto& assetEntry : context.m_definition->m_assets) for (const auto& assetEntry : context.m_definition->m_assets)
{ {
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name)) if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
return nullptr; return nullptr;
} }
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext); objLoader->FinalizeAssetsForZone(*assetLoadingContext);
return zone; return zone;
} }

View File

@ -2,6 +2,7 @@
#include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/GameAssetPoolIW5.h"
#include "Game/IW5/GameIW5.h" #include "Game/IW5/GameIW5.h"
#include "IObjLoader.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "Utils/StringUtils.h" #include "Utils/StringUtils.h"
@ -52,13 +53,14 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context)); const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
ApplyIgnoredAssets(context, *assetLoadingContext); ApplyIgnoredAssets(context, *assetLoadingContext);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::IW5);
for (const auto& assetEntry : context.m_definition->m_assets) for (const auto& assetEntry : context.m_definition->m_assets)
{ {
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name)) if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
return nullptr; return nullptr;
} }
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext); objLoader->FinalizeAssetsForZone(*assetLoadingContext);
return zone; return zone;
} }

View File

@ -3,6 +3,7 @@
#include "AssetLoading/AssetLoadingContext.h" #include "AssetLoading/AssetLoadingContext.h"
#include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/GameAssetPoolT5.h"
#include "Game/T5/GameT5.h" #include "Game/T5/GameT5.h"
#include "IObjLoader.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "Utils/StringUtils.h" #include "Utils/StringUtils.h"
@ -53,13 +54,14 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context)); const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
ApplyIgnoredAssets(context, *assetLoadingContext); ApplyIgnoredAssets(context, *assetLoadingContext);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::T5);
for (const auto& assetEntry : context.m_definition->m_assets) for (const auto& assetEntry : context.m_definition->m_assets)
{ {
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name)) if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
return nullptr; return nullptr;
} }
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext); objLoader->FinalizeAssetsForZone(*assetLoadingContext);
return zone; return zone;
} }

View File

@ -4,6 +4,7 @@
#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameAssetPoolT6.h"
#include "Game/T6/GameT6.h" #include "Game/T6/GameT6.h"
#include "Game/T6/T6.h" #include "Game/T6/T6.h"
#include "IObjLoader.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "Utils/StringUtils.h" #include "Utils/StringUtils.h"
@ -106,13 +107,14 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
HandleMetadata(zone.get(), context); HandleMetadata(zone.get(), context);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::T6);
for (const auto& assetEntry : context.m_definition->m_assets) for (const auto& assetEntry : context.m_definition->m_assets)
{ {
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name)) if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
return nullptr; return nullptr;
} }
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext); objLoader->FinalizeAssetsForZone(*assetLoadingContext);
return zone; return zone;
} }

View File

@ -139,7 +139,7 @@ class LinkerImpl final : public Linker
{ {
std::unique_ptr<ZoneDefinition> zoneDefinition; std::unique_ptr<ZoneDefinition> zoneDefinition;
{ {
const auto definitionFileName = targetName + ".zone"; const auto definitionFileName = std::format("{}.zone", targetName);
const auto definitionStream = sourceSearchPath->Open(definitionFileName); const auto definitionStream = sourceSearchPath->Open(definitionFileName);
if (!definitionStream.IsOpen()) if (!definitionStream.IsOpen())
{ {

View File

@ -1,5 +1,6 @@
#include "ZoneCreator.h" #include "ZoneCreator.h"
#include "AssetLoading/AssetLoadingContext.h"
#include "Game/IW3/ZoneCreatorIW3.h" #include "Game/IW3/ZoneCreatorIW3.h"
#include "Game/IW4/ZoneCreatorIW4.h" #include "Game/IW4/ZoneCreatorIW4.h"
#include "Game/IW5/ZoneCreatorIW5.h" #include "Game/IW5/ZoneCreatorIW5.h"

View File

@ -48,11 +48,6 @@ ObjLoader::ObjLoader()
#undef REGISTER_ASSET_LOADER #undef REGISTER_ASSET_LOADER
} }
bool ObjLoader::SupportsZone(const Zone& zone) const
{
return zone.m_game == &g_GameIW3;
}
bool ObjLoader::IsMpZone(const Zone& zone) bool ObjLoader::IsMpZone(const Zone& zone)
{ {
return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0; return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0;

View File

@ -19,8 +19,6 @@ namespace IW3
public: public:
ObjLoader(); ObjLoader();
[[nodiscard]] bool SupportsZone(const Zone& zone) const override;
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override; void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
void UnloadContainersOfZone(Zone& zone) const override; void UnloadContainersOfZone(Zone& zone) const override;

View File

@ -92,11 +92,6 @@ ObjLoader::ObjLoader()
#undef REGISTER_ASSET_LOADER #undef REGISTER_ASSET_LOADER
} }
bool ObjLoader::SupportsZone(const Zone& zone) const
{
return zone.m_game == &g_GameIW4;
}
bool ObjLoader::IsMpZone(const Zone& zone) bool ObjLoader::IsMpZone(const Zone& zone)
{ {
return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0; return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0;

View File

@ -14,8 +14,6 @@ namespace IW4
public: public:
ObjLoader(); ObjLoader();
[[nodiscard]] bool SupportsZone(const Zone& zone) const override;
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override; void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
void UnloadContainersOfZone(Zone& zone) const override; void UnloadContainersOfZone(Zone& zone) const override;

View File

@ -99,11 +99,6 @@ ObjLoader::ObjLoader()
#undef REGISTER_ASSET_LOADER #undef REGISTER_ASSET_LOADER
} }
bool ObjLoader::SupportsZone(const Zone& zone) const
{
return zone.m_game == &g_GameIW5;
}
bool ObjLoader::IsMpZone(const Zone& zone) bool ObjLoader::IsMpZone(const Zone& zone)
{ {
return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0; return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0;

View File

@ -14,8 +14,6 @@ namespace IW5
public: public:
ObjLoader(); ObjLoader();
[[nodiscard]] bool SupportsZone(const Zone& zone) const override;
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override; void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
void UnloadContainersOfZone(Zone& zone) const override; void UnloadContainersOfZone(Zone& zone) const override;

View File

@ -56,11 +56,6 @@ ObjLoader::ObjLoader()
#undef REGISTER_ASSET_LOADER #undef REGISTER_ASSET_LOADER
} }
bool ObjLoader::SupportsZone(const Zone& zone) const
{
return zone.m_game == &g_GameT5;
}
bool ObjLoader::IsMpZone(const Zone& zone) bool ObjLoader::IsMpZone(const Zone& zone)
{ {
return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0; return zone.m_name.compare(0, 3, "mp_") == 0 || zone.m_name.compare(zone.m_name.length() - 3, 3, "_mp") == 0;

View File

@ -14,8 +14,6 @@ namespace T5
public: public:
ObjLoader(); ObjLoader();
bool SupportsZone(const Zone& zone) const override;
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override; void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
void UnloadContainersOfZone(Zone& zone) const override; void UnloadContainersOfZone(Zone& zone) const override;

View File

@ -125,11 +125,6 @@ namespace T6
#undef REGISTER_ASSET_LOADER #undef REGISTER_ASSET_LOADER
} }
bool ObjLoader::SupportsZone(const Zone& zone) const
{
return zone.m_game == &g_GameT6;
}
bool ObjLoader::VerifySoundBankChecksum(const SoundBank& soundBank, const SndRuntimeAssetBank& sndRuntimeAssetBank) bool ObjLoader::VerifySoundBankChecksum(const SoundBank& soundBank, const SndRuntimeAssetBank& sndRuntimeAssetBank)
{ {
SoundAssetBankChecksum checksum{}; SoundAssetBankChecksum checksum{};

View File

@ -19,8 +19,6 @@ namespace T6
public: public:
ObjLoader(); ObjLoader();
[[nodiscard]] bool SupportsZone(const Zone& zone) const override;
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override; void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
void UnloadContainersOfZone(Zone& zone) const override; void UnloadContainersOfZone(Zone& zone) const override;

View File

@ -0,0 +1,27 @@
#include "IObjLoader.h"
#include "Game/IW3/ObjLoaderIW3.h"
#include "Game/IW4/ObjLoaderIW4.h"
#include "Game/IW5/ObjLoaderIW5.h"
#include "Game/T5/ObjLoaderT5.h"
#include "Game/T6/ObjLoaderT6.h"
#include <cassert>
const IObjLoader* IObjLoader::GetObjLoaderForGame(GameId game)
{
static const IObjLoader* zoneCreators[static_cast<unsigned>(GameId::COUNT)]{
new IW3::ObjLoader(),
new IW4::ObjLoader(),
new IW5::ObjLoader(),
new T5::ObjLoader(),
new T6::ObjLoader(),
};
static_assert(std::extent_v<decltype(zoneCreators)> == static_cast<unsigned>(GameId::COUNT));
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
const auto* result = zoneCreators[static_cast<unsigned>(game)];
assert(result);
return result;
}

View File

@ -14,13 +14,6 @@ public:
IObjLoader& operator=(const IObjLoader& other) = default; IObjLoader& operator=(const IObjLoader& other) = default;
IObjLoader& operator=(IObjLoader&& other) noexcept = default; IObjLoader& operator=(IObjLoader&& other) noexcept = default;
/**
* \brief Checks whether this ObjLoader supports a specified zone.
* \param zone The zone to check.
* \return \c true if the specified zone is supported.
*/
[[nodiscard]] virtual bool SupportsZone(const Zone& zone) const = 0;
/** /**
* \brief Loads all containers that are referenced by a specified zone. * \brief Loads all containers that are referenced by a specified zone.
* \param searchPath The search path object to use to find the referenced containers. * \param searchPath The search path object to use to find the referenced containers.
@ -36,4 +29,6 @@ public:
virtual bool LoadAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const = 0; virtual bool LoadAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const = 0;
virtual void FinalizeAssetsForZone(AssetLoadingContext& context) const = 0; virtual void FinalizeAssetsForZone(AssetLoadingContext& context) const = 0;
static const IObjLoader* GetObjLoaderForGame(GameId game);
}; };

View File

@ -1,10 +1,5 @@
#include "ObjLoading.h" #include "ObjLoading.h"
#include "Game/IW3/ObjLoaderIW3.h"
#include "Game/IW4/ObjLoaderIW4.h"
#include "Game/IW5/ObjLoaderIW5.h"
#include "Game/T5/ObjLoaderT5.h"
#include "Game/T6/ObjLoaderT6.h"
#include "IObjLoader.h" #include "IObjLoader.h"
#include "ObjContainer/IWD/IWD.h" #include "ObjContainer/IWD/IWD.h"
#include "SearchPath/SearchPaths.h" #include "SearchPath/SearchPaths.h"
@ -14,38 +9,6 @@
ObjLoading::Configuration_t ObjLoading::Configuration; ObjLoading::Configuration_t ObjLoading::Configuration;
const IObjLoader* const OBJ_LOADERS[]{
new IW3::ObjLoader(),
new IW4::ObjLoader(),
new IW5::ObjLoader(),
new T5::ObjLoader(),
new T6::ObjLoader(),
};
void ObjLoading::LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone)
{
for (const auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(zone))
{
loader->LoadReferencedContainersForZone(searchPath, zone);
return;
}
}
}
void ObjLoading::UnloadContainersOfZone(Zone& zone)
{
for (const auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(zone))
{
loader->UnloadContainersOfZone(zone);
return;
}
}
}
void ObjLoading::LoadIWDsInSearchPath(ISearchPath& searchPath) void ObjLoading::LoadIWDsInSearchPath(ISearchPath& searchPath)
{ {
searchPath.Find(SearchPathSearchOptions().IncludeSubdirectories(false).FilterExtensions("iwd"), searchPath.Find(SearchPathSearchOptions().IncludeSubdirectories(false).FilterExtensions("iwd"),
@ -81,28 +44,3 @@ SearchPaths ObjLoading::GetIWDSearchPaths()
return iwdPaths; return iwdPaths;
} }
bool ObjLoading::LoadAssetForZone(AssetLoadingContext& context, const asset_type_t assetType, const std::string& assetName)
{
for (const auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(context.m_zone))
{
return loader->LoadAssetForZone(context, assetType, assetName);
}
}
return false;
}
void ObjLoading::FinalizeAssetsForZone(AssetLoadingContext& context)
{
for (const auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(context.m_zone))
{
loader->FinalizeAssetsForZone(context);
return;
}
}
}

View File

@ -1,9 +1,7 @@
#pragma once #pragma once
#include "AssetLoading/AssetLoadingContext.h"
#include "SearchPath/ISearchPath.h" #include "SearchPath/ISearchPath.h"
#include "SearchPath/SearchPaths.h" #include "SearchPath/SearchPaths.h"
#include "Zone/Zone.h"
class ObjLoading class ObjLoading
{ {
@ -16,19 +14,6 @@ public:
bool MenuNoOptimization = false; bool MenuNoOptimization = false;
} Configuration; } Configuration;
/**
* \brief Loads all containers that are being referenced by the specified zone.
* \param searchPath The search path to use to find the referenced containers.
* \param zone The zone to load all referenced containers of.
*/
static void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone);
/**
* \brief Unloads all containers that were referenced by a specified zone. If referenced by more than one zone a container will only be unloaded once all
* referencing zones were unloaded the container. \param zone The zone to unload all referenced containers for.
*/
static void UnloadContainersOfZone(Zone& zone);
/** /**
* \brief Loads all IWDs that can be found in a specified search path. * \brief Loads all IWDs that can be found in a specified search path.
* \param searchPath The search path that contains IWDs to be loaded. * \param searchPath The search path that contains IWDs to be loaded.
@ -46,7 +31,4 @@ public:
* \return A \c SearchPaths object containing all IWDs that are currently loaded. * \return A \c SearchPaths object containing all IWDs that are currently loaded.
*/ */
static SearchPaths GetIWDSearchPaths(); static SearchPaths GetIWDSearchPaths();
static bool LoadAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName);
static void FinalizeAssetsForZone(AssetLoadingContext& context);
}; };

View File

@ -1,17 +0,0 @@
#pragma once
#include "AssetDumpingContext.h"
class IZoneDumper
{
public:
IZoneDumper() = default;
virtual ~IZoneDumper() = default;
IZoneDumper(const IZoneDumper& other) = default;
IZoneDumper(IZoneDumper&& other) noexcept = default;
IZoneDumper& operator=(const IZoneDumper& other) = default;
IZoneDumper& operator=(IZoneDumper&& other) noexcept = default;
virtual bool CanHandleZone(AssetDumpingContext& assetDumpingContext) const = 0;
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
};

View File

@ -1,4 +1,4 @@
#include "ZoneDumperIW3.h" #include "ObjWriterIW3.h"
#include "AssetDumpers/AssetDumperGfxImage.h" #include "AssetDumpers/AssetDumperGfxImage.h"
#include "AssetDumpers/AssetDumperLoadedSound.h" #include "AssetDumpers/AssetDumperLoadedSound.h"
@ -10,17 +10,11 @@
#include "AssetDumpers/AssetDumperWeapon.h" #include "AssetDumpers/AssetDumperWeapon.h"
#include "AssetDumpers/AssetDumperXModel.h" #include "AssetDumpers/AssetDumperXModel.h"
#include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/GameIW3.h"
#include "ObjWriting.h" #include "ObjWriting.h"
using namespace IW3; using namespace IW3;
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
return context.m_zone->m_game == &g_GameIW3;
}
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
{ {
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ #define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \

View File

@ -0,0 +1,11 @@
#pragma once
#include "IObjWriter.h"
namespace IW3
{
class ObjWriter final : public IObjWriter
{
public:
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace IW3

View File

@ -1,12 +0,0 @@
#pragma once
#include "Dumping/IZoneDumper.h"
namespace IW3
{
class ZoneDumper final : public IZoneDumper
{
public:
bool CanHandleZone(AssetDumpingContext& context) const override;
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace IW3

View File

@ -1,4 +1,4 @@
#include "ZoneDumperIW4.h" #include "ObjWriterIW4.h"
#include "AssetDumpers/AssetDumperAddonMapEnts.h" #include "AssetDumpers/AssetDumperAddonMapEnts.h"
#include "AssetDumpers/AssetDumperGfxImage.h" #include "AssetDumpers/AssetDumperGfxImage.h"
@ -23,17 +23,11 @@
#include "AssetDumpers/AssetDumperWeapon.h" #include "AssetDumpers/AssetDumperWeapon.h"
#include "AssetDumpers/AssetDumperXModel.h" #include "AssetDumpers/AssetDumperXModel.h"
#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/GameIW4.h"
#include "ObjWriting.h" #include "ObjWriting.h"
using namespace IW4; using namespace IW4;
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
return context.m_zone->m_game == &g_GameIW4;
}
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
{ {
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ #define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \

View File

@ -0,0 +1,11 @@
#pragma once
#include "IObjWriter.h"
namespace IW4
{
class ObjWriter final : public IObjWriter
{
public:
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace IW4

View File

@ -1,12 +0,0 @@
#pragma once
#include "Dumping/IZoneDumper.h"
namespace IW4
{
class ZoneDumper final : public IZoneDumper
{
public:
bool CanHandleZone(AssetDumpingContext& context) const override;
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace IW4

View File

@ -1,4 +1,4 @@
#include "ZoneDumperIW5.h" #include "ObjWriterIW5.h"
#include "AssetDumpers/AssetDumperAddonMapEnts.h" #include "AssetDumpers/AssetDumperAddonMapEnts.h"
#include "AssetDumpers/AssetDumperGfxImage.h" #include "AssetDumpers/AssetDumperGfxImage.h"
@ -15,17 +15,11 @@
#include "AssetDumpers/AssetDumperWeaponAttachment.h" #include "AssetDumpers/AssetDumperWeaponAttachment.h"
#include "AssetDumpers/AssetDumperXModel.h" #include "AssetDumpers/AssetDumperXModel.h"
#include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/GameAssetPoolIW5.h"
#include "Game/IW5/GameIW5.h"
#include "ObjWriting.h" #include "ObjWriting.h"
using namespace IW5; using namespace IW5;
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
return context.m_zone->m_game == &g_GameIW5;
}
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
{ {
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ #define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \

View File

@ -0,0 +1,11 @@
#pragma once
#include "IObjWriter.h"
namespace IW5
{
class ObjWriter final : public IObjWriter
{
public:
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace IW5

View File

@ -1,12 +0,0 @@
#pragma once
#include "Dumping/IZoneDumper.h"
namespace IW5
{
class ZoneDumper final : public IZoneDumper
{
public:
bool CanHandleZone(AssetDumpingContext& context) const override;
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace IW5

View File

@ -1,4 +1,4 @@
#include "ZoneDumperT5.h" #include "ObjWriterT5.h"
#include "AssetDumpers/AssetDumperGfxImage.h" #include "AssetDumpers/AssetDumperGfxImage.h"
#include "AssetDumpers/AssetDumperLocalizeEntry.h" #include "AssetDumpers/AssetDumperLocalizeEntry.h"
@ -10,17 +10,11 @@
#include "AssetDumpers/AssetDumperWeapon.h" #include "AssetDumpers/AssetDumperWeapon.h"
#include "AssetDumpers/AssetDumperXModel.h" #include "AssetDumpers/AssetDumperXModel.h"
#include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/GameAssetPoolT5.h"
#include "Game/T5/GameT5.h"
#include "ObjWriting.h" #include "ObjWriting.h"
using namespace T5; using namespace T5;
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
return context.m_zone->m_game == &g_GameT5;
}
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
{ {
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ #define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \

View File

@ -0,0 +1,11 @@
#pragma once
#include "IObjWriter.h"
namespace T5
{
class ObjWriter final : public IObjWriter
{
public:
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace T5

View File

@ -1,12 +0,0 @@
#pragma once
#include "Dumping/IZoneDumper.h"
namespace T5
{
class ZoneDumper final : public IZoneDumper
{
public:
bool CanHandleZone(AssetDumpingContext& context) const override;
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace T5

View File

@ -1,4 +1,4 @@
#include "ZoneDumperT6.h" #include "ObjWriterT6.h"
#include "AssetDumpers/AssetDumperFontIcon.h" #include "AssetDumpers/AssetDumperFontIcon.h"
#include "AssetDumpers/AssetDumperGfxImage.h" #include "AssetDumpers/AssetDumperGfxImage.h"
@ -24,17 +24,11 @@
#include "AssetDumpers/AssetDumperXModel.h" #include "AssetDumpers/AssetDumperXModel.h"
#include "AssetDumpers/AssetDumperZBarrier.h" #include "AssetDumpers/AssetDumperZBarrier.h"
#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameAssetPoolT6.h"
#include "Game/T6/GameT6.h"
#include "ObjWriting.h" #include "ObjWriting.h"
using namespace T6; using namespace T6;
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ObjWriter::DumpZone(AssetDumpingContext& context) const
{
return context.m_zone->m_game == &g_GameT6;
}
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
{ {
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ #define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \

View File

@ -0,0 +1,11 @@
#pragma once
#include "IObjWriter.h"
namespace T6
{
class ObjWriter final : public IObjWriter
{
public:
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace T6

View File

@ -1,12 +0,0 @@
#pragma once
#include "Dumping/IZoneDumper.h"
namespace T6
{
class ZoneDumper final : public IZoneDumper
{
public:
bool CanHandleZone(AssetDumpingContext& context) const override;
bool DumpZone(AssetDumpingContext& context) const override;
};
} // namespace T6

View File

@ -0,0 +1,27 @@
#include "IObjWriter.h"
#include "Game/IW3/ObjWriterIW3.h"
#include "Game/IW4/ObjWriterIW4.h"
#include "Game/IW5/ObjWriterIW5.h"
#include "Game/T5/ObjWriterT5.h"
#include "Game/T6/ObjWriterT6.h"
#include <cassert>
const IObjWriter* IObjWriter::GetObjWriterForGame(GameId game)
{
static const IObjWriter* zoneCreators[static_cast<unsigned>(GameId::COUNT)]{
new IW3::ObjWriter(),
new IW4::ObjWriter(),
new IW5::ObjWriter(),
new T5::ObjWriter(),
new T6::ObjWriter(),
};
static_assert(std::extent_v<decltype(zoneCreators)> == static_cast<unsigned>(GameId::COUNT));
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
const auto* result = zoneCreators[static_cast<unsigned>(game)];
assert(result);
return result;
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "Dumping/AssetDumpingContext.h"
class IObjWriter
{
public:
IObjWriter() = default;
virtual ~IObjWriter() = default;
IObjWriter(const IObjWriter& other) = default;
IObjWriter(IObjWriter&& other) noexcept = default;
IObjWriter& operator=(const IObjWriter& other) = default;
IObjWriter& operator=(IObjWriter&& other) noexcept = default;
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
static const IObjWriter* GetObjWriterForGame(GameId game);
};

View File

@ -1,41 +1,7 @@
#include "ObjWriting.h" #include "ObjWriting.h"
#include "Dumping/IZoneDumper.h"
#include "Game/IW3/ZoneDumperIW3.h"
#include "Game/IW4/ZoneDumperIW4.h"
#include "Game/IW5/ZoneDumperIW5.h"
#include "Game/T5/ZoneDumperT5.h"
#include "Game/T6/ZoneDumperT6.h"
ObjWriting::Configuration_t ObjWriting::Configuration; ObjWriting::Configuration_t ObjWriting::Configuration;
const IZoneDumper* const ZONE_DUMPER[]{
new IW3::ZoneDumper(),
new IW4::ZoneDumper(),
new IW5::ZoneDumper(),
new T5::ZoneDumper(),
new T6::ZoneDumper(),
};
bool ObjWriting::DumpZone(AssetDumpingContext& context)
{
for (const auto* dumper : ZONE_DUMPER)
{
if (dumper->CanHandleZone(context))
{
if (dumper->DumpZone(context))
{
return true;
}
printf("Dumper for zone '%s' failed!\n", context.m_zone->m_name.c_str());
return false;
}
}
return false;
}
bool ObjWriting::ShouldHandleAssetType(const asset_type_t assetType) bool ObjWriting::ShouldHandleAssetType(const asset_type_t assetType)
{ {
if (assetType < 0) if (assetType < 0)

View File

@ -34,6 +34,5 @@ public:
} Configuration; } Configuration;
static bool DumpZone(AssetDumpingContext& context);
static bool ShouldHandleAssetType(asset_type_t assetType); static bool ShouldHandleAssetType(asset_type_t assetType);
}; };

View File

@ -3,15 +3,15 @@
#include <format> #include <format>
#include <iostream> #include <iostream>
ContentPrinter::ContentPrinter(Zone* zone) ContentPrinter::ContentPrinter(const Zone& zone)
: m_zone(zone)
{ {
m_zone = zone;
} }
void ContentPrinter::PrintContent() const void ContentPrinter::PrintContent() const
{ {
const auto* pools = m_zone->m_pools.get(); const auto* pools = m_zone.m_pools.get();
std::cout << std::format("Zone '{}' ({})\n", m_zone->m_name, m_zone->m_game->GetShortName()); std::cout << std::format("Zone '{}' ({})\n", m_zone.m_name, m_zone.m_game->GetShortName());
std::cout << "Content:\n"; std::cout << "Content:\n";
for (const auto& asset : *pools) for (const auto& asset : *pools)

View File

@ -4,10 +4,11 @@
class ContentPrinter class ContentPrinter
{ {
Zone* m_zone;
public: public:
explicit ContentPrinter(Zone* zone); explicit ContentPrinter(const Zone& zone);
void PrintContent() const; void PrintContent() const;
private:
const Zone& m_zone;
}; };

View File

@ -1,17 +1,42 @@
#include "ZoneDefWriter.h" #include "ZoneDefWriter.h"
void AbstractZoneDefWriter::WriteZoneDef(std::ostream& stream, const UnlinkerArgs* args, Zone* zone) const #include "Game/IW3/ZoneDefWriterIW3.h"
#include "Game/IW4/ZoneDefWriterIW4.h"
#include "Game/IW5/ZoneDefWriterIW5.h"
#include "Game/T5/ZoneDefWriterT5.h"
#include "Game/T6/ZoneDefWriterT6.h"
#include <cassert>
const IZoneDefWriter* IZoneDefWriter::GetZoneDefWriterForGame(GameId game)
{
static const IZoneDefWriter* zoneDefWriters[static_cast<unsigned>(GameId::COUNT)]{
new IW3::ZoneDefWriter(),
new IW4::ZoneDefWriter(),
new IW5::ZoneDefWriter(),
new T5::ZoneDefWriter(),
new T6::ZoneDefWriter(),
};
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
const auto* result = zoneDefWriters[static_cast<unsigned>(game)];
assert(result);
return result;
}
void AbstractZoneDefWriter::WriteZoneDef(std::ostream& stream, const UnlinkerArgs& args, const Zone& zone) const
{ {
ZoneDefinitionOutputStream out(stream); ZoneDefinitionOutputStream out(stream);
out.WriteComment(zone->m_game->GetFullName()); out.WriteComment(zone.m_game->GetFullName());
out.WriteMetaData(META_DATA_KEY_GAME, zone->m_game->GetShortName()); out.WriteMetaData(META_DATA_KEY_GAME, zone.m_game->GetShortName());
out.EmptyLine(); out.EmptyLine();
if (args->m_use_gdt) if (args.m_use_gdt)
{ {
out.WriteComment("Load asset gdt files"); out.WriteComment("Load asset gdt files");
out.WriteMetaData(META_DATA_KEY_GDT, zone->m_name); out.WriteMetaData(META_DATA_KEY_GDT, zone.m_name);
out.EmptyLine(); out.EmptyLine();
} }

View File

@ -2,7 +2,6 @@
#include "UnlinkerArgs.h" #include "UnlinkerArgs.h"
#include "Zone/Definition/ZoneDefinitionStream.h" #include "Zone/Definition/ZoneDefinitionStream.h"
#include "Zone/Zone.h"
class IZoneDefWriter class IZoneDefWriter
{ {
@ -14,19 +13,20 @@ public:
IZoneDefWriter& operator=(const IZoneDefWriter& other) = default; IZoneDefWriter& operator=(const IZoneDefWriter& other) = default;
IZoneDefWriter& operator=(IZoneDefWriter&& other) noexcept = default; IZoneDefWriter& operator=(IZoneDefWriter&& other) noexcept = default;
virtual bool CanHandleZone(Zone* zone) const = 0; virtual void WriteZoneDef(std::ostream& stream, const UnlinkerArgs& args, const Zone& zone) const = 0;
virtual void WriteZoneDef(std::ostream& stream, const UnlinkerArgs* args, Zone* zone) const = 0;
static const IZoneDefWriter* GetZoneDefWriterForGame(GameId game);
}; };
class AbstractZoneDefWriter : public IZoneDefWriter class AbstractZoneDefWriter : public IZoneDefWriter
{ {
protected: protected:
static constexpr const char* META_DATA_KEY_GAME = "game"; static constexpr auto META_DATA_KEY_GAME = "game";
static constexpr const char* META_DATA_KEY_GDT = "gdt"; static constexpr auto META_DATA_KEY_GDT = "gdt";
virtual void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const = 0; virtual void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const = 0;
virtual void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const = 0; virtual void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const = 0;
public: public:
void WriteZoneDef(std::ostream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteZoneDef(std::ostream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
}; };

View File

@ -1,22 +1,16 @@
#include "ZoneDefWriterIW3.h" #include "ZoneDefWriterIW3.h"
#include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/GameAssetPoolIW3.h"
#include "Game/IW3/GameIW3.h"
#include <cassert> #include <cassert>
using namespace IW3; using namespace IW3;
bool ZoneDefWriter::CanHandleZone(Zone* zone) const void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
{
return zone->m_game == &g_GameIW3;
}
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {} void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
{ {
const auto* pools = dynamic_cast<GameAssetPoolIW3*>(zone->m_pools.get()); const auto* pools = dynamic_cast<GameAssetPoolIW3*>(zone.m_pools.get());
assert(pools); assert(pools);
if (!pools) if (!pools)
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
// Localized strings are all collected in one string file. So only add this to the zone file. // Localized strings are all collected in one string file. So only add this to the zone file.
if (!pools->m_localize->m_asset_lookup.empty()) if (!pools->m_localize->m_asset_lookup.empty())
{ stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
}
for (const auto& asset : *pools) for (const auto& asset : *pools)
{ {

View File

@ -7,10 +7,7 @@ namespace IW3
class ZoneDefWriter final : public AbstractZoneDefWriter class ZoneDefWriter final : public AbstractZoneDefWriter
{ {
protected: protected:
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
public:
bool CanHandleZone(Zone* zone) const override;
}; };
} // namespace IW3 } // namespace IW3

View File

@ -1,22 +1,16 @@
#include "ZoneDefWriterIW4.h" #include "ZoneDefWriterIW4.h"
#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/GameAssetPoolIW4.h"
#include "Game/IW4/GameIW4.h"
#include <cassert> #include <cassert>
using namespace IW4; using namespace IW4;
bool ZoneDefWriter::CanHandleZone(Zone* zone) const void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
{
return zone->m_game == &g_GameIW4;
}
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {} void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
{ {
const auto* pools = dynamic_cast<GameAssetPoolIW4*>(zone->m_pools.get()); const auto* pools = dynamic_cast<GameAssetPoolIW4*>(zone.m_pools.get());
assert(pools); assert(pools);
if (!pools) if (!pools)
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
// Localized strings are all collected in one string file. So only add this to the zone file. // Localized strings are all collected in one string file. So only add this to the zone file.
if (!pools->m_localize->m_asset_lookup.empty()) if (!pools->m_localize->m_asset_lookup.empty())
{ stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
}
for (const auto& asset : *pools) for (const auto& asset : *pools)
{ {

View File

@ -7,10 +7,7 @@ namespace IW4
class ZoneDefWriter final : public AbstractZoneDefWriter class ZoneDefWriter final : public AbstractZoneDefWriter
{ {
protected: protected:
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
public:
bool CanHandleZone(Zone* zone) const override;
}; };
} // namespace IW4 } // namespace IW4

View File

@ -1,22 +1,16 @@
#include "ZoneDefWriterIW5.h" #include "ZoneDefWriterIW5.h"
#include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/GameAssetPoolIW5.h"
#include "Game/IW5/GameIW5.h"
#include <cassert> #include <cassert>
using namespace IW5; using namespace IW5;
bool ZoneDefWriter::CanHandleZone(Zone* zone) const void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
{
return zone->m_game == &g_GameIW5;
}
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {} void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
{ {
const auto* pools = dynamic_cast<GameAssetPoolIW5*>(zone->m_pools.get()); const auto* pools = dynamic_cast<GameAssetPoolIW5*>(zone.m_pools.get());
assert(pools); assert(pools);
if (!pools) if (!pools)
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
// Localized strings are all collected in one string file. So only add this to the zone file. // Localized strings are all collected in one string file. So only add this to the zone file.
if (!pools->m_localize->m_asset_lookup.empty()) if (!pools->m_localize->m_asset_lookup.empty())
{ stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
}
for (const auto& asset : *pools) for (const auto& asset : *pools)
{ {

View File

@ -7,10 +7,7 @@ namespace IW5
class ZoneDefWriter final : public AbstractZoneDefWriter class ZoneDefWriter final : public AbstractZoneDefWriter
{ {
protected: protected:
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
public:
bool CanHandleZone(Zone* zone) const override;
}; };
} // namespace IW5 } // namespace IW5

View File

@ -1,22 +1,16 @@
#include "ZoneDefWriterT5.h" #include "ZoneDefWriterT5.h"
#include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/GameAssetPoolT5.h"
#include "Game/T5/GameT5.h"
#include <cassert> #include <cassert>
using namespace T5; using namespace T5;
bool ZoneDefWriter::CanHandleZone(Zone* zone) const void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const {}
{
return zone->m_game == &g_GameT5;
}
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const {} void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
{ {
const auto* pools = dynamic_cast<GameAssetPoolT5*>(zone->m_pools.get()); const auto* pools = dynamic_cast<GameAssetPoolT5*>(zone.m_pools.get());
assert(pools); assert(pools);
if (!pools) if (!pools)
@ -24,9 +18,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
// Localized strings are all collected in one string file. So only add this to the zone file. // Localized strings are all collected in one string file. So only add this to the zone file.
if (!pools->m_localize->m_asset_lookup.empty()) if (!pools->m_localize->m_asset_lookup.empty())
{ stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
}
for (const auto& asset : *pools) for (const auto& asset : *pools)
{ {

View File

@ -7,10 +7,7 @@ namespace T5
class ZoneDefWriter final : public AbstractZoneDefWriter class ZoneDefWriter final : public AbstractZoneDefWriter
{ {
protected: protected:
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
public:
bool CanHandleZone(Zone* zone) const override;
}; };
} // namespace T5 } // namespace T5

View File

@ -2,7 +2,6 @@
#include "Game/T6/CommonT6.h" #include "Game/T6/CommonT6.h"
#include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameAssetPoolT6.h"
#include "Game/T6/GameT6.h"
#include <cassert> #include <cassert>
#include <iomanip> #include <iomanip>
@ -10,7 +9,7 @@
using namespace T6; using namespace T6;
namespace T6 namespace
{ {
class KeyValuePairKnownKey class KeyValuePairKnownKey
{ {
@ -31,50 +30,43 @@ namespace T6
KeyValuePairKnownKey("initial_xmodels"), KeyValuePairKnownKey("initial_xmodels"),
KeyValuePairKnownKey("initial_materials"), KeyValuePairKnownKey("initial_materials"),
}; };
} // namespace T6
bool ZoneDefWriter::CanHandleZone(Zone* zone) const void WriteKeyValuePair(ZoneDefinitionOutputStream& stream, const KeyValuePair& kvp)
{
return zone->m_game == &g_GameT6;
}
void ZoneDefWriter::WriteKeyValuePair(ZoneDefinitionOutputStream& stream, KeyValuePair* kvp)
{
for (const auto& knownKey : KEY_VALUE_PAIR_KNOWN_KEYS)
{ {
if (knownKey.m_hash == kvp->keyHash) for (const auto& knownKey : KEY_VALUE_PAIR_KNOWN_KEYS)
{ {
stream.WriteMetaData("level." + knownKey.m_key, kvp->value); if (knownKey.m_hash == kvp.keyHash)
return; {
stream.WriteMetaData("level." + knownKey.m_key, kvp.value);
return;
}
} }
std::ostringstream str;
str << "level.@" << std::setfill('0') << std::setw(sizeof(int) * 2) << std::hex << kvp.keyHash;
stream.WriteMetaData(str.str(), kvp.value);
} }
} // namespace
std::ostringstream str; void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
str << "level.@" << std::setfill('0') << std::setw(sizeof(int) * 2) << std::hex << kvp->keyHash;
stream.WriteMetaData(str.str(), kvp->value);
}
void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const
{ {
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get()); const auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone.m_pools.get());
if (assetPoolT6 && !assetPoolT6->m_key_value_pairs->m_asset_lookup.empty()) if (assetPoolT6 && !assetPoolT6->m_key_value_pairs->m_asset_lookup.empty())
{ {
for (const auto* kvpAsset : *assetPoolT6->m_key_value_pairs) for (const auto* kvpAsset : *assetPoolT6->m_key_value_pairs)
{ {
const auto* keyValuePairs = kvpAsset->Asset(); const auto* keyValuePairs = kvpAsset->Asset();
for (auto varIndex = 0; varIndex < keyValuePairs->numVariables; varIndex++) for (auto varIndex = 0; varIndex < keyValuePairs->numVariables; varIndex++)
{ WriteKeyValuePair(stream, keyValuePairs->keyValuePairs[varIndex]);
WriteKeyValuePair(stream, &keyValuePairs->keyValuePairs[varIndex]);
}
} }
stream.EmptyLine(); stream.EmptyLine();
} }
} }
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const
{ {
const auto* pools = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get()); const auto* pools = dynamic_cast<GameAssetPoolT6*>(zone.m_pools.get());
assert(pools); assert(pools);
if (!pools) if (!pools)
@ -82,9 +74,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Unlin
// Localized strings are all collected in one string file. So only add this to the zone file. // Localized strings are all collected in one string file. So only add this to the zone file.
if (!pools->m_localize->m_asset_lookup.empty()) if (!pools->m_localize->m_asset_lookup.empty())
{ stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name);
}
for (const auto& asset : *pools) for (const auto& asset : *pools)
{ {

View File

@ -1,19 +1,13 @@
#pragma once #pragma once
#include "ContentLister/ZoneDefWriter.h" #include "ContentLister/ZoneDefWriter.h"
#include "Game/T6/T6.h"
namespace T6 namespace T6
{ {
class ZoneDefWriter final : public AbstractZoneDefWriter class ZoneDefWriter final : public AbstractZoneDefWriter
{ {
static void WriteKeyValuePair(ZoneDefinitionOutputStream& stream, KeyValuePair* kvp);
protected: protected:
void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs& args, const Zone& zone) const override;
public:
bool CanHandleZone(Zone* zone) const override;
}; };
} // namespace T6 } // namespace T6

View File

@ -2,11 +2,8 @@
#include "ContentLister/ContentPrinter.h" #include "ContentLister/ContentPrinter.h"
#include "ContentLister/ZoneDefWriter.h" #include "ContentLister/ZoneDefWriter.h"
#include "Game/IW3/ZoneDefWriterIW3.h" #include "IObjLoader.h"
#include "Game/IW4/ZoneDefWriterIW4.h" #include "IObjWriter.h"
#include "Game/IW5/ZoneDefWriterIW5.h"
#include "Game/T5/ZoneDefWriterT5.h"
#include "Game/T6/ZoneDefWriterT6.h"
#include "ObjContainer/IWD/IWD.h" #include "ObjContainer/IWD/IWD.h"
#include "ObjLoading.h" #include "ObjLoading.h"
#include "ObjWriting.h" #include "ObjWriting.h"
@ -25,14 +22,6 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
const IZoneDefWriter* const ZONE_DEF_WRITERS[]{
new IW3::ZoneDefWriter(),
new IW4::ZoneDefWriter(),
new IW5::ZoneDefWriter(),
new T5::ZoneDefWriter(),
new T6::ZoneDefWriter(),
};
class Unlinker::Impl class Unlinker::Impl
{ {
public: public:
@ -166,51 +155,41 @@ private:
return true; return true;
} }
bool WriteZoneDefinitionFile(Zone* zone, const fs::path& zoneDefinitionFileFolder) const bool WriteZoneDefinitionFile(const Zone& zone, const fs::path& zoneDefinitionFileFolder) const
{ {
auto zoneDefinitionFilePath(zoneDefinitionFileFolder); auto zoneDefinitionFilePath(zoneDefinitionFileFolder);
zoneDefinitionFilePath.append(zone->m_name); zoneDefinitionFilePath.append(zone.m_name);
zoneDefinitionFilePath.replace_extension(".zone"); zoneDefinitionFilePath.replace_extension(".zone");
std::ofstream zoneDefinitionFile(zoneDefinitionFilePath, std::fstream::out | std::fstream::binary); std::ofstream zoneDefinitionFile(zoneDefinitionFilePath, std::fstream::out | std::fstream::binary);
if (!zoneDefinitionFile.is_open()) if (!zoneDefinitionFile.is_open())
{ {
std::cerr << std::format("Failed to open file for zone definition file of zone \"{}\".\n", zone->m_name); std::cerr << std::format("Failed to open file for zone definition file of zone \"{}\".\n", zone.m_name);
return false; return false;
} }
auto result = false; const auto* zoneDefWriter = IZoneDefWriter::GetZoneDefWriterForGame(zone.m_game->GetId());
for (const auto* zoneDefWriter : ZONE_DEF_WRITERS) zoneDefWriter->WriteZoneDef(zoneDefinitionFile, m_args, zone);
{
if (zoneDefWriter->CanHandleZone(zone))
{
zoneDefWriter->WriteZoneDef(zoneDefinitionFile, &m_args, zone);
result = true;
break;
}
}
if (!result)
std::cerr << std::format("Failed to find writer for zone definition file of zone \"{}\".\n", zone->m_name);
zoneDefinitionFile.close(); zoneDefinitionFile.close();
return result;
return true;
} }
static bool OpenGdtFile(Zone* zone, const fs::path& outputFolder, std::ofstream& stream) static bool OpenGdtFile(const Zone& zone, const fs::path& outputFolder, std::ofstream& stream)
{ {
auto gdtFilePath(outputFolder); auto gdtFilePath(outputFolder);
gdtFilePath.append("source_data"); gdtFilePath.append("source_data");
fs::create_directories(gdtFilePath); fs::create_directories(gdtFilePath);
gdtFilePath.append(zone->m_name); gdtFilePath.append(zone.m_name);
gdtFilePath.replace_extension(".gdt"); gdtFilePath.replace_extension(".gdt");
stream = std::ofstream(gdtFilePath, std::fstream::out | std::fstream::binary); stream = std::ofstream(gdtFilePath, std::fstream::out | std::fstream::binary);
if (!stream.is_open()) if (!stream.is_open())
{ {
std::cerr << std::format("Failed to open file for zone definition file of zone \"{}\".\n", zone->m_name); std::cerr << std::format("Failed to open file for zone definition file of zone \"{}\".\n", zone.m_name);
return false; return false;
} }
@ -274,7 +253,7 @@ private:
* \param zone The zone to handle. * \param zone The zone to handle.
* \return \c true if handling the zone was successful, otherwise \c false. * \return \c true if handling the zone was successful, otherwise \c false.
*/ */
bool HandleZone(ISearchPath& searchPath, Zone* zone) const bool HandleZone(ISearchPath& searchPath, Zone& zone) const
{ {
if (m_args.m_task == UnlinkerArgs::ProcessingTask::LIST) if (m_args.m_task == UnlinkerArgs::ProcessingTask::LIST)
{ {
@ -295,7 +274,7 @@ private:
std::ofstream gdtStream; std::ofstream gdtStream;
AssetDumpingContext context; AssetDumpingContext context;
context.m_zone = zone; context.m_zone = &zone;
context.m_base_path = outputFolderPath; context.m_base_path = outputFolderPath;
context.m_obj_search_path = &searchPath; context.m_obj_search_path = &searchPath;
@ -305,18 +284,27 @@ private:
return false; return false;
auto gdt = std::make_unique<GdtOutputStream>(gdtStream); auto gdt = std::make_unique<GdtOutputStream>(gdtStream);
gdt->BeginStream(); gdt->BeginStream();
gdt->WriteVersion(GdtVersion(zone->m_game->GetShortName(), 1)); gdt->WriteVersion(GdtVersion(zone.m_game->GetShortName(), 1));
context.m_gdt = std::move(gdt); context.m_gdt = std::move(gdt);
} }
UpdateAssetIncludesAndExcludes(context); UpdateAssetIncludesAndExcludes(context);
ObjWriting::DumpZone(context);
const auto* objWriter = IObjWriter::GetObjWriterForGame(zone.m_game->GetId());
auto result = objWriter->DumpZone(context);
if (m_args.m_use_gdt) if (m_args.m_use_gdt)
{ {
context.m_gdt->EndStream(); context.m_gdt->EndStream();
gdtStream.close(); gdtStream.close();
} }
if (!result)
{
std::cerr << "Dumping zone failed!\n";
return false;
}
} }
return true; return true;
@ -348,7 +336,10 @@ private:
std::cout << std::format("Loaded zone \"{}\"\n", zone->m_name); std::cout << std::format("Loaded zone \"{}\"\n", zone->m_name);
if (ShouldLoadObj()) if (ShouldLoadObj())
ObjLoading::LoadReferencedContainersForZone(searchPathsForZone, *zone); {
const auto* objLoader = IObjLoader::GetObjLoaderForGame(zone->m_game->GetId());
objLoader->LoadReferencedContainersForZone(searchPathsForZone, *zone);
}
m_loaded_zones.emplace_back(std::move(zone)); m_loaded_zones.emplace_back(std::move(zone));
} }
@ -366,7 +357,10 @@ private:
const auto zoneName = loadedZone->m_name; const auto zoneName = loadedZone->m_name;
if (ShouldLoadObj()) if (ShouldLoadObj())
ObjLoading::UnloadContainersOfZone(*loadedZone); {
const auto* objLoader = IObjLoader::GetObjLoaderForGame(loadedZone->m_game->GetId());
objLoader->UnloadContainersOfZone(*loadedZone);
}
loadedZone.reset(); loadedZone.reset();
@ -406,14 +400,15 @@ private:
if (m_args.m_verbose) if (m_args.m_verbose)
std::cout << std::format("Loaded zone \"{}\"\n", zoneName); std::cout << std::format("Loaded zone \"{}\"\n", zoneName);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(zone->m_game->GetId());
if (ShouldLoadObj()) if (ShouldLoadObj())
ObjLoading::LoadReferencedContainersForZone(searchPathsForZone, *zone); objLoader->LoadReferencedContainersForZone(searchPathsForZone, *zone);
if (!HandleZone(searchPathsForZone, zone.get())) if (!HandleZone(searchPathsForZone, *zone))
return false; return false;
if (ShouldLoadObj()) if (ShouldLoadObj())
ObjLoading::UnloadContainersOfZone(*zone); objLoader->UnloadContainersOfZone(*zone);
zone.reset(); zone.reset();
if (m_args.m_verbose) if (m_args.m_verbose)

View File

@ -377,7 +377,7 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldCont
return true; return true;
} }
std::string UnlinkerArgs::GetOutputFolderPathForZone(const Zone* zone) const std::string UnlinkerArgs::GetOutputFolderPathForZone(const Zone& zone) const
{ {
return std::regex_replace(m_output_folder, m_zone_pattern, zone->m_name); return std::regex_replace(m_output_folder, m_zone_pattern, zone.m_name);
} }

View File

@ -68,5 +68,5 @@ public:
* \param zone The zone to resolve the path input for. * \param zone The zone to resolve the path input for.
* \return An output path for the zone based on the user input. * \return An output path for the zone based on the user input.
*/ */
std::string GetOutputFolderPathForZone(const Zone* zone) const; std::string GetOutputFolderPathForZone(const Zone& zone) const;
}; };