mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
chore: always build fastfile when there are assets defined
This commit is contained in:
parent
2182196730
commit
f9e0bdaa7b
@ -1,71 +1,14 @@
|
|||||||
#include "ZoneCreatorIW3.h"
|
#include "ZoneCreatorIW3.h"
|
||||||
|
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
#include "Game/IW3/IW3.h"
|
||||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
|
||||||
#include "Game/IW3/GameIW3.h"
|
|
||||||
#include "IObjLoader.h"
|
|
||||||
#include "ObjLoading.h"
|
|
||||||
#include "Utils/StringUtils.h"
|
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
|
||||||
{
|
|
||||||
std::vector<Gdt*> gdtList;
|
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
|
||||||
for (const auto& gdt : context.m_gdt_files)
|
|
||||||
gdtList.push_back(gdt.get());
|
|
||||||
|
|
||||||
return gdtList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext)
|
|
||||||
{
|
|
||||||
for (const auto& ignoreEntry : creationContext.m_ignored_assets.m_entries)
|
|
||||||
loadingContext.m_ignored_asset_map[ignoreEntry.m_name] = ignoreEntry.m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
|
||||||
{
|
|
||||||
zone->m_pools = std::make_unique<GameAssetPoolIW3>(zone, zone->m_priority);
|
|
||||||
|
|
||||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameId ZoneCreator::GetGameId() const
|
GameId ZoneCreator::GetGameId() const
|
||||||
{
|
{
|
||||||
return GameId::IW3;
|
return GameId::IW3;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
|
||||||
{
|
|
||||||
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(GameId::IW3));
|
|
||||||
CreateZoneAssetPools(zone.get());
|
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!assetEntry.m_is_reference)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
|
|
||||||
ApplyIgnoredAssets(context, *assetLoadingContext);
|
|
||||||
|
|
||||||
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::IW3);
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
objLoader->FinalizeAssetsForZone(*assetLoadingContext);
|
|
||||||
|
|
||||||
return zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
asset_type_t ZoneCreator::GetImageAssetType() const
|
asset_type_t ZoneCreator::GetImageAssetType() const
|
||||||
{
|
{
|
||||||
return ASSET_TYPE_IMAGE;
|
return ASSET_TYPE_IMAGE;
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
|
||||||
#include "Zone/ZoneTypes.h"
|
|
||||||
#include "ZoneCreation/ZoneCreator.h"
|
#include "ZoneCreation/ZoneCreator.h"
|
||||||
|
|
||||||
namespace IW3
|
namespace IW3
|
||||||
{
|
{
|
||||||
class ZoneCreator final : public IZoneCreator
|
class ZoneCreator final : public IZoneCreator
|
||||||
{
|
{
|
||||||
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
|
||||||
static void ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext);
|
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] GameId GetGameId() const override;
|
[[nodiscard]] GameId GetGameId() const override;
|
||||||
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
|
||||||
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
||||||
};
|
};
|
||||||
} // namespace IW3
|
} // namespace IW3
|
||||||
|
@ -1,70 +1,14 @@
|
|||||||
#include "ZoneCreatorIW4.h"
|
#include "ZoneCreatorIW4.h"
|
||||||
|
|
||||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
#include "Game/IW4/IW4.h"
|
||||||
#include "Game/IW4/GameIW4.h"
|
|
||||||
#include "IObjLoader.h"
|
|
||||||
#include "ObjLoading.h"
|
|
||||||
#include "Utils/StringUtils.h"
|
|
||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
|
||||||
{
|
|
||||||
std::vector<Gdt*> gdtList;
|
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
|
||||||
for (const auto& gdt : context.m_gdt_files)
|
|
||||||
gdtList.push_back(gdt.get());
|
|
||||||
|
|
||||||
return gdtList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext)
|
|
||||||
{
|
|
||||||
for (const auto& ignoreEntry : creationContext.m_ignored_assets.m_entries)
|
|
||||||
loadingContext.m_ignored_asset_map[ignoreEntry.m_name] = ignoreEntry.m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
|
||||||
{
|
|
||||||
zone->m_pools = std::make_unique<GameAssetPoolIW4>(zone, zone->m_priority);
|
|
||||||
|
|
||||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameId ZoneCreator::GetGameId() const
|
GameId ZoneCreator::GetGameId() const
|
||||||
{
|
{
|
||||||
return GameId::IW4;
|
return GameId::IW4;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
|
||||||
{
|
|
||||||
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(GameId::IW4));
|
|
||||||
CreateZoneAssetPools(zone.get());
|
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!assetEntry.m_is_reference)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
|
|
||||||
ApplyIgnoredAssets(context, *assetLoadingContext);
|
|
||||||
|
|
||||||
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::IW4);
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
objLoader->FinalizeAssetsForZone(*assetLoadingContext);
|
|
||||||
|
|
||||||
return zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
asset_type_t ZoneCreator::GetImageAssetType() const
|
asset_type_t ZoneCreator::GetImageAssetType() const
|
||||||
{
|
{
|
||||||
return ASSET_TYPE_IMAGE;
|
return ASSET_TYPE_IMAGE;
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
|
||||||
#include "Zone/ZoneTypes.h"
|
|
||||||
#include "ZoneCreation/ZoneCreator.h"
|
#include "ZoneCreation/ZoneCreator.h"
|
||||||
|
|
||||||
namespace IW4
|
namespace IW4
|
||||||
{
|
{
|
||||||
class ZoneCreator final : public IZoneCreator
|
class ZoneCreator final : public IZoneCreator
|
||||||
{
|
{
|
||||||
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
|
||||||
static void ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext);
|
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] GameId GetGameId() const override;
|
[[nodiscard]] GameId GetGameId() const override;
|
||||||
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
|
||||||
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
||||||
};
|
};
|
||||||
} // namespace IW4
|
} // namespace IW4
|
||||||
|
@ -1,70 +1,14 @@
|
|||||||
#include "ZoneCreatorIW5.h"
|
#include "ZoneCreatorIW5.h"
|
||||||
|
|
||||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
#include "Game/IW5/IW5.h"
|
||||||
#include "Game/IW5/GameIW5.h"
|
|
||||||
#include "IObjLoader.h"
|
|
||||||
#include "ObjLoading.h"
|
|
||||||
#include "Utils/StringUtils.h"
|
|
||||||
|
|
||||||
using namespace IW5;
|
using namespace IW5;
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
|
||||||
{
|
|
||||||
std::vector<Gdt*> gdtList;
|
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
|
||||||
for (const auto& gdt : context.m_gdt_files)
|
|
||||||
gdtList.push_back(gdt.get());
|
|
||||||
|
|
||||||
return gdtList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext)
|
|
||||||
{
|
|
||||||
for (const auto& ignoreEntry : creationContext.m_ignored_assets.m_entries)
|
|
||||||
loadingContext.m_ignored_asset_map[ignoreEntry.m_name] = ignoreEntry.m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
|
||||||
{
|
|
||||||
zone->m_pools = std::make_unique<GameAssetPoolIW5>(zone, zone->m_priority);
|
|
||||||
|
|
||||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameId ZoneCreator::GetGameId() const
|
GameId ZoneCreator::GetGameId() const
|
||||||
{
|
{
|
||||||
return GameId::IW5;
|
return GameId::IW5;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
|
||||||
{
|
|
||||||
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(GameId::IW5));
|
|
||||||
CreateZoneAssetPools(zone.get());
|
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!assetEntry.m_is_reference)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
|
|
||||||
ApplyIgnoredAssets(context, *assetLoadingContext);
|
|
||||||
|
|
||||||
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::IW5);
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
objLoader->FinalizeAssetsForZone(*assetLoadingContext);
|
|
||||||
|
|
||||||
return zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
asset_type_t ZoneCreator::GetImageAssetType() const
|
asset_type_t ZoneCreator::GetImageAssetType() const
|
||||||
{
|
{
|
||||||
return ASSET_TYPE_IMAGE;
|
return ASSET_TYPE_IMAGE;
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
|
||||||
#include "Zone/ZoneTypes.h"
|
|
||||||
#include "ZoneCreation/ZoneCreator.h"
|
#include "ZoneCreation/ZoneCreator.h"
|
||||||
|
|
||||||
namespace IW5
|
namespace IW5
|
||||||
{
|
{
|
||||||
class ZoneCreator final : public IZoneCreator
|
class ZoneCreator final : public IZoneCreator
|
||||||
{
|
{
|
||||||
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
|
||||||
static void ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext);
|
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] GameId GetGameId() const override;
|
[[nodiscard]] GameId GetGameId() const override;
|
||||||
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
|
||||||
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
||||||
};
|
};
|
||||||
} // namespace IW5
|
} // namespace IW5
|
||||||
|
@ -1,71 +1,14 @@
|
|||||||
#include "ZoneCreatorT5.h"
|
#include "ZoneCreatorT5.h"
|
||||||
|
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
#include "Game/T5/T5.h"
|
||||||
#include "Game/T5/GameAssetPoolT5.h"
|
|
||||||
#include "Game/T5/GameT5.h"
|
|
||||||
#include "IObjLoader.h"
|
|
||||||
#include "ObjLoading.h"
|
|
||||||
#include "Utils/StringUtils.h"
|
|
||||||
|
|
||||||
using namespace T5;
|
using namespace T5;
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
|
||||||
{
|
|
||||||
std::vector<Gdt*> gdtList;
|
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
|
||||||
for (const auto& gdt : context.m_gdt_files)
|
|
||||||
gdtList.push_back(gdt.get());
|
|
||||||
|
|
||||||
return gdtList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext)
|
|
||||||
{
|
|
||||||
for (const auto& ignoreEntry : creationContext.m_ignored_assets.m_entries)
|
|
||||||
loadingContext.m_ignored_asset_map[ignoreEntry.m_name] = ignoreEntry.m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
|
||||||
{
|
|
||||||
zone->m_pools = std::make_unique<GameAssetPoolT5>(zone, zone->m_priority);
|
|
||||||
|
|
||||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameId ZoneCreator::GetGameId() const
|
GameId ZoneCreator::GetGameId() const
|
||||||
{
|
{
|
||||||
return GameId::T5;
|
return GameId::T5;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
|
||||||
{
|
|
||||||
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(GameId::T5));
|
|
||||||
CreateZoneAssetPools(zone.get());
|
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!assetEntry.m_is_reference)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
|
|
||||||
ApplyIgnoredAssets(context, *assetLoadingContext);
|
|
||||||
|
|
||||||
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::T5);
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
objLoader->FinalizeAssetsForZone(*assetLoadingContext);
|
|
||||||
|
|
||||||
return zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
asset_type_t ZoneCreator::GetImageAssetType() const
|
asset_type_t ZoneCreator::GetImageAssetType() const
|
||||||
{
|
{
|
||||||
return ASSET_TYPE_IMAGE;
|
return ASSET_TYPE_IMAGE;
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
|
||||||
#include "Zone/ZoneTypes.h"
|
|
||||||
#include "ZoneCreation/ZoneCreator.h"
|
#include "ZoneCreation/ZoneCreator.h"
|
||||||
|
|
||||||
namespace T5
|
namespace T5
|
||||||
{
|
{
|
||||||
class ZoneCreator final : public IZoneCreator
|
class ZoneCreator final : public IZoneCreator
|
||||||
{
|
{
|
||||||
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
|
||||||
static void ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext);
|
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] GameId GetGameId() const override;
|
[[nodiscard]] GameId GetGameId() const override;
|
||||||
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
|
||||||
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
||||||
};
|
};
|
||||||
} // namespace T5
|
} // namespace T5
|
||||||
|
@ -1,42 +1,26 @@
|
|||||||
#include "ZoneCreatorT6.h"
|
#include "ZoneCreatorT6.h"
|
||||||
|
|
||||||
#include "Game/T6/CommonT6.h"
|
#include "Game/T6/CommonT6.h"
|
||||||
#include "Game/T6/GameAssetPoolT6.h"
|
|
||||||
#include "Game/T6/GameT6.h"
|
|
||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
#include "IObjLoader.h"
|
#include "IObjLoader.h"
|
||||||
#include "ObjLoading.h"
|
#include "ObjLoading.h"
|
||||||
#include "Utils/StringUtils.h"
|
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
GameId ZoneCreator::GetGameId() const
|
||||||
{
|
{
|
||||||
std::vector<Gdt*> gdtList;
|
return GameId::T6;
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
|
||||||
for (const auto& gdt : context.m_gdt_files)
|
|
||||||
gdtList.push_back(gdt.get());
|
|
||||||
|
|
||||||
return gdtList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneCreator::ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext)
|
asset_type_t ZoneCreator::GetImageAssetType() const
|
||||||
{
|
{
|
||||||
for (const auto& ignoreEntry : creationContext.m_ignored_assets.m_entries)
|
return ASSET_TYPE_IMAGE;
|
||||||
loadingContext.m_ignored_asset_map[ignoreEntry.m_name] = ignoreEntry.m_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
void ZoneCreator::HandleMetadata(Zone& zone, const ZoneCreationContext& context) const
|
||||||
{
|
|
||||||
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, zone->m_priority);
|
|
||||||
|
|
||||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneCreator::HandleMetadata(Zone* zone, const ZoneCreationContext& context) const
|
|
||||||
{
|
{
|
||||||
std::vector<KeyValuePair> kvpList;
|
std::vector<KeyValuePair> kvpList;
|
||||||
|
|
||||||
@ -56,7 +40,7 @@ void ZoneCreator::HandleMetadata(Zone* zone, const ZoneCreationContext& context)
|
|||||||
|
|
||||||
if (endPtr != &strValue[strValue.size()])
|
if (endPtr != &strValue[strValue.size()])
|
||||||
{
|
{
|
||||||
std::cout << "Could not parse metadata key \"" << metaData.first << "\" as hash\n";
|
std::cerr << std::format("Could not parse metadata key \"{}\" as hash\n", metaData.first);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,61 +49,21 @@ void ZoneCreator::HandleMetadata(Zone* zone, const ZoneCreationContext& context)
|
|||||||
keyHash = Common::Com_HashKey(strValue.c_str(), 64);
|
keyHash = Common::Com_HashKey(strValue.c_str(), 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValuePair kvp{keyHash, Common::Com_HashKey(zone->m_name.c_str(), 64), zone->GetMemory()->Dup(metaData.second.c_str())};
|
KeyValuePair kvp{keyHash, Common::Com_HashKey(zone.m_name.c_str(), 64), zone.GetMemory()->Dup(metaData.second.c_str())};
|
||||||
kvpList.push_back(kvp);
|
kvpList.push_back(kvp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!kvpList.empty())
|
if (!kvpList.empty())
|
||||||
{
|
{
|
||||||
auto* kvps = zone->GetMemory()->Create<KeyValuePairs>();
|
auto* kvps = zone.GetMemory()->Create<KeyValuePairs>();
|
||||||
kvps->name = zone->GetMemory()->Dup(zone->m_name.c_str());
|
kvps->name = zone.GetMemory()->Dup(zone.m_name.c_str());
|
||||||
kvps->numVariables = kvpList.size();
|
kvps->numVariables = static_cast<int>(kvpList.size());
|
||||||
kvps->keyValuePairs = zone->GetMemory()->Alloc<KeyValuePair>(kvpList.size());
|
kvps->keyValuePairs = zone.GetMemory()->Alloc<KeyValuePair>(kvpList.size());
|
||||||
|
|
||||||
for (auto i = 0u; i < kvpList.size(); i++)
|
for (auto i = 0u; i < kvpList.size(); i++)
|
||||||
kvps->keyValuePairs[i] = kvpList[i];
|
kvps->keyValuePairs[i] = kvpList[i];
|
||||||
|
|
||||||
zone->m_pools->AddAsset(std::make_unique<XAssetInfo<KeyValuePairs>>(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps));
|
zone.m_pools->AddAsset(std::make_unique<XAssetInfo<KeyValuePairs>>(ASSET_TYPE_KEYVALUEPAIRS, zone.m_name, kvps));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameId ZoneCreator::GetGameId() const
|
|
||||||
{
|
|
||||||
return GameId::T6;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
|
||||||
{
|
|
||||||
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(GameId::T6));
|
|
||||||
CreateZoneAssetPools(zone.get());
|
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!assetEntry.m_is_reference)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
|
|
||||||
ApplyIgnoredAssets(context, *assetLoadingContext);
|
|
||||||
|
|
||||||
HandleMetadata(zone.get(), context);
|
|
||||||
|
|
||||||
const auto* objLoader = IObjLoader::GetObjLoaderForGame(GameId::T6);
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
|
||||||
{
|
|
||||||
if (!objLoader->LoadAssetForZone(*assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
objLoader->FinalizeAssetsForZone(*assetLoadingContext);
|
|
||||||
|
|
||||||
return zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
asset_type_t ZoneCreator::GetImageAssetType() const
|
|
||||||
{
|
|
||||||
return ASSET_TYPE_IMAGE;
|
|
||||||
}
|
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "AssetLoading/AssetLoadingContext.h"
|
|
||||||
#include "Zone/ZoneTypes.h"
|
|
||||||
#include "ZoneCreation/ZoneCreator.h"
|
#include "ZoneCreation/ZoneCreator.h"
|
||||||
|
|
||||||
namespace T6
|
namespace T6
|
||||||
{
|
{
|
||||||
class ZoneCreator final : public IZoneCreator
|
class ZoneCreator final : public IZoneCreator
|
||||||
{
|
{
|
||||||
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
|
||||||
static void ApplyIgnoredAssets(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext);
|
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
|
||||||
void HandleMetadata(Zone* zone, const ZoneCreationContext& context) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] GameId GetGameId() const override;
|
[[nodiscard]] GameId GetGameId() const override;
|
||||||
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
|
||||||
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
[[nodiscard]] asset_type_t GetImageAssetType() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void HandleMetadata(Zone& zone, const ZoneCreationContext& context) const override;
|
||||||
};
|
};
|
||||||
} // namespace T6
|
} // namespace T6
|
||||||
|
@ -217,14 +217,14 @@ class LinkerImpl final : public Linker
|
|||||||
ISearchPath* gdtSearchPath,
|
ISearchPath* gdtSearchPath,
|
||||||
ISearchPath* sourceSearchPath) const
|
ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
const auto context = std::make_unique<ZoneCreationContext>(&zoneDefinition, assetSearchPath);
|
ZoneCreationContext context(&zoneDefinition, assetSearchPath);
|
||||||
if (!ProcessZoneDefinitionIgnores(targetName, *context, sourceSearchPath))
|
if (!ProcessZoneDefinitionIgnores(targetName, context, sourceSearchPath))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (!LoadGdtFilesFromZoneDefinition(context->m_gdt_files, zoneDefinition, gdtSearchPath))
|
if (!LoadGdtFilesFromZoneDefinition(context.m_gdt_files, zoneDefinition, gdtSearchPath))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const auto* creator = IZoneCreator::GetCreatorForGame(zoneDefinition.m_game);
|
const auto* creator = IZoneCreator::GetCreatorForGame(zoneDefinition.m_game);
|
||||||
return creator->CreateZoneForDefinition(*context);
|
return creator->CreateZoneForDefinition(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteZoneToFile(const std::string& projectName, Zone* zone) const
|
bool WriteZoneToFile(const std::string& projectName, Zone* zone) const
|
||||||
@ -334,11 +334,16 @@ class LinkerImpl final : public Linker
|
|||||||
if (!zoneDefinition)
|
if (!zoneDefinition)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto result = true;
|
||||||
|
|
||||||
|
if (!zoneDefinition->m_assets.empty())
|
||||||
|
{
|
||||||
const auto& gameName = GameId_Names[static_cast<unsigned>(zoneDefinition->m_game)];
|
const auto& gameName = GameId_Names[static_cast<unsigned>(zoneDefinition->m_game)];
|
||||||
auto assetSearchPaths = m_search_paths.GetAssetSearchPathsForProject(gameName, projectName);
|
auto assetSearchPaths = m_search_paths.GetAssetSearchPathsForProject(gameName, projectName);
|
||||||
auto gdtSearchPaths = m_search_paths.GetGdtSearchPathsForProject(gameName, projectName);
|
auto gdtSearchPaths = m_search_paths.GetGdtSearchPathsForProject(gameName, projectName);
|
||||||
|
|
||||||
auto result = BuildFastFile(projectName, targetName, *zoneDefinition, assetSearchPaths, gdtSearchPaths, sourceSearchPaths);
|
result = result && BuildFastFile(projectName, targetName, *zoneDefinition, assetSearchPaths, gdtSearchPaths, sourceSearchPaths);
|
||||||
|
}
|
||||||
|
|
||||||
m_search_paths.UnloadProjectSpecificSearchPaths();
|
m_search_paths.UnloadProjectSpecificSearchPaths();
|
||||||
|
|
||||||
@ -362,8 +367,8 @@ class LinkerImpl final : public Linker
|
|||||||
zoneDirectory = fs::current_path();
|
zoneDirectory = fs::current_path();
|
||||||
auto absoluteZoneDirectory = absolute(zoneDirectory).string();
|
auto absoluteZoneDirectory = absolute(zoneDirectory).string();
|
||||||
|
|
||||||
auto zone = std::unique_ptr<Zone>(ZoneLoading::LoadZone(zonePath));
|
auto zone = ZoneLoading::LoadZone(zonePath);
|
||||||
if (zone == nullptr)
|
if (!zone)
|
||||||
{
|
{
|
||||||
std::cerr << std::format("Failed to load zone \"{}\".\n", zonePath);
|
std::cerr << std::format("Failed to load zone \"{}\".\n", zonePath);
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Game/IW5/ZoneCreatorIW5.h"
|
#include "Game/IW5/ZoneCreatorIW5.h"
|
||||||
#include "Game/T5/ZoneCreatorT5.h"
|
#include "Game/T5/ZoneCreatorT5.h"
|
||||||
#include "Game/T6/ZoneCreatorT6.h"
|
#include "Game/T6/ZoneCreatorT6.h"
|
||||||
|
#include "IObjLoader.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ const IZoneCreator* IZoneCreator::GetCreatorForGame(GameId game)
|
|||||||
new T5::ZoneCreator(),
|
new T5::ZoneCreator(),
|
||||||
new T6::ZoneCreator(),
|
new T6::ZoneCreator(),
|
||||||
};
|
};
|
||||||
|
static_assert(std::extent_v<decltype(zoneCreators)> == static_cast<unsigned>(GameId::COUNT));
|
||||||
|
|
||||||
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
|
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
|
||||||
const auto* result = zoneCreators[static_cast<unsigned>(game)];
|
const auto* result = zoneCreators[static_cast<unsigned>(game)];
|
||||||
@ -25,3 +27,71 @@ const IZoneCreator* IZoneCreator::GetCreatorForGame(GameId game)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::unique_ptr<Zone> CreateZone(const ZoneCreationContext& context, const GameId gameId)
|
||||||
|
{
|
||||||
|
return std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(gameId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitializeAssetPools(Zone& zone, const GameId gameId)
|
||||||
|
{
|
||||||
|
zone.m_pools = ZoneAssetPools::CreateForGame(gameId, &zone, zone.m_priority);
|
||||||
|
const auto assetTypeCount = zone.m_pools->GetAssetTypeCount();
|
||||||
|
for (auto assetType = 0; assetType < assetTypeCount; assetType++)
|
||||||
|
zone.m_pools->InitPoolDynamic(assetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context)
|
||||||
|
{
|
||||||
|
std::vector<Gdt*> gdtList;
|
||||||
|
gdtList.reserve(context.m_gdt_files.size());
|
||||||
|
for (const auto& gdt : context.m_gdt_files)
|
||||||
|
gdtList.push_back(gdt.get());
|
||||||
|
|
||||||
|
return gdtList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IgnoreReferencesFromAssets(ZoneCreationContext& context)
|
||||||
|
{
|
||||||
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
{
|
||||||
|
if (!assetEntry.m_is_reference)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyIgnoredAssetsToLoadingContext(const ZoneCreationContext& creationContext, AssetLoadingContext& loadingContext)
|
||||||
|
{
|
||||||
|
for (const auto& ignoreEntry : creationContext.m_ignored_assets.m_entries)
|
||||||
|
loadingContext.m_ignored_asset_map[ignoreEntry.m_name] = ignoreEntry.m_type;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
std::unique_ptr<Zone> IZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||||
|
{
|
||||||
|
const auto gameId = GetGameId();
|
||||||
|
|
||||||
|
auto zone = CreateZone(context, gameId);
|
||||||
|
InitializeAssetPools(*zone, gameId);
|
||||||
|
|
||||||
|
AssetLoadingContext assetLoadingContext(*zone, *context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
IgnoreReferencesFromAssets(context);
|
||||||
|
ApplyIgnoredAssetsToLoadingContext(context, assetLoadingContext);
|
||||||
|
|
||||||
|
HandleMetadata(*zone, context);
|
||||||
|
|
||||||
|
const auto* objLoader = IObjLoader::GetObjLoaderForGame(gameId);
|
||||||
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
{
|
||||||
|
if (!objLoader->LoadAssetForZone(assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
objLoader->FinalizeAssetsForZone(assetLoadingContext);
|
||||||
|
|
||||||
|
return zone;
|
||||||
|
}
|
||||||
|
@ -14,8 +14,12 @@ public:
|
|||||||
IZoneCreator& operator=(IZoneCreator&& other) noexcept = default;
|
IZoneCreator& operator=(IZoneCreator&& other) noexcept = default;
|
||||||
|
|
||||||
[[nodiscard]] virtual GameId GetGameId() const = 0;
|
[[nodiscard]] virtual GameId GetGameId() const = 0;
|
||||||
[[nodiscard]] virtual std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const = 0;
|
|
||||||
[[nodiscard]] virtual asset_type_t GetImageAssetType() const = 0;
|
[[nodiscard]] virtual asset_type_t GetImageAssetType() const = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const;
|
||||||
|
|
||||||
static const IZoneCreator* GetCreatorForGame(GameId game);
|
static const IZoneCreator* GetCreatorForGame(GameId game);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void HandleMetadata(Zone& zone, const ZoneCreationContext& context) const {}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
#include "ZoneAssetPools.h"
|
#include "ZoneAssetPools.h"
|
||||||
|
|
||||||
|
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||||
|
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||||
|
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||||
|
#include "Game/T5/GameAssetPoolT5.h"
|
||||||
|
#include "Game/T6/GameAssetPoolT6.h"
|
||||||
|
#include "Game/T6/ZoneConstantsT6.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <format>
|
#include <format>
|
||||||
|
|
||||||
ZoneAssetPools::ZoneAssetPools(Zone* zone)
|
ZoneAssetPools::ZoneAssetPools(Zone* zone)
|
||||||
@ -52,3 +60,23 @@ ZoneAssetPools::iterator ZoneAssetPools::end() const
|
|||||||
{
|
{
|
||||||
return m_assets_in_order.end();
|
return m_assets_in_order.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ZoneAssetPools> ZoneAssetPools::CreateForGame(const GameId game, Zone* zone, const zone_priority_t priority)
|
||||||
|
{
|
||||||
|
switch (game)
|
||||||
|
{
|
||||||
|
case GameId::IW3:
|
||||||
|
return std::make_unique<GameAssetPoolIW3>(zone, priority);
|
||||||
|
case GameId::IW4:
|
||||||
|
return std::make_unique<GameAssetPoolIW4>(zone, priority);
|
||||||
|
case GameId::IW5:
|
||||||
|
return std::make_unique<GameAssetPoolIW5>(zone, priority);
|
||||||
|
case GameId::T5:
|
||||||
|
return std::make_unique<GameAssetPoolT5>(zone, priority);
|
||||||
|
case GameId::T6:
|
||||||
|
return std::make_unique<GameAssetPoolT6>(zone, priority);
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -52,4 +52,6 @@ public:
|
|||||||
|
|
||||||
_NODISCARD iterator begin() const;
|
_NODISCARD iterator begin() const;
|
||||||
_NODISCARD iterator end() const;
|
_NODISCARD iterator end() const;
|
||||||
|
|
||||||
|
static std::unique_ptr<ZoneAssetPools> CreateForGame(GameId game, Zone* zone, zone_priority_t priority);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user