2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 05:12:05 +00:00

Updated BSP linker to load assets on the FinalizeZone step.

This commit is contained in:
LJW-Dev
2025-11-01 17:06:08 +08:00
parent 3d2e890e34
commit 81e0331252
17 changed files with 87 additions and 66 deletions

View File

@@ -1,13 +1,14 @@
#include "LoaderBSP_T6.h"
#include "BSPCreator.h"
#include "BSPUtil.h"
#include "Linker/BSPLinker.h"
#include "LoaderBSP_T6.h"
namespace
{
using namespace BSP;
class BSPLoader final : public AssetCreator<AssetGfxWorld>
class BSPLoader final : public IAssetCreator
{
public:
BSPLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
@@ -17,20 +18,35 @@ namespace
{
}
std::optional<asset_type_t> GetHandlingAssetType() const override
{
// don't handle any asset types
return std::nullopt;
}
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
// BSP assets are added in the finalize zone step
return AssetCreationResult::NoAction();
}
void FinalizeZone(AssetCreationContext& context) override
{
// custom maps must have a map_gfx file
std::string mapGfxFileName = "map_gfx.fbx";
auto mapGfxFile = m_search_path.Open(BSPUtil::getFileNameForBSPAsset(mapGfxFileName));
if (!mapGfxFile.IsOpen())
return AssetCreationResult::NoAction();
return;
std::unique_ptr<BSPData> bsp = BSP::createBSPData(m_zone.m_name, m_search_path);
if (bsp == nullptr)
return AssetCreationResult::Failure();
return;
BSPLinker linker(m_memory, m_search_path, context);
return linker.linkBSP(bsp.get());
if (!linker.linkBSP(bsp.get()))
con::error("BSP link has failed.");
return;
}
private:
@@ -42,7 +58,7 @@ namespace
namespace BSP
{
std::unique_ptr<AssetCreator<AssetGfxWorld>> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
std::unique_ptr<IAssetCreator> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
{
return std::make_unique<BSPLoader>(memory, searchPath, zone);
}