From a81944a7bef8191ec95792e6285cdc2f6913eb7d Mon Sep 17 00:00:00 2001 From: LJW-Dev Date: Wed, 22 Oct 2025 16:42:12 +0800 Subject: [PATCH] WIP: Prepared project for updating CustomMapLinker.h --- src/ObjLoading/Game/T6/BSP/BSPCreator.cpp | 7 ++++--- src/ObjLoading/Game/T6/BSP/BSPUtil.cpp | 5 +++++ src/ObjLoading/Game/T6/BSP/BSPUtil.h | 1 + src/ObjLoading/Game/T6/BSP/CustomMapLinker.h | 2 +- src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp | 10 +++++----- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp index 322d940f..c8173089 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp @@ -1,4 +1,5 @@ #include "BSPCreator.h" +#include "BSPUtil.h" #include "fbx/ufbx.h" namespace @@ -192,7 +193,7 @@ namespace BSP { std::unique_ptr createBSPData(std::string& mapName, ISearchPath& searchPath) { - std::string gfxFbxPath = "BSP/map_gfx.fbx"; + std::string gfxFbxPath = BSPUtil::getFileNameForBSPAsset("map_gfx.fbx"); auto gfxFile = searchPath.Open(gfxFbxPath); if (!gfxFile.IsOpen()) { @@ -221,7 +222,7 @@ namespace BSP } ufbx_scene* colScene; - std::string colFbxPath = "BSP/map_col.fbx"; + std::string colFbxPath = BSPUtil::getFileNameForBSPAsset("map_col.fbx"); auto colFile = searchPath.Open(colFbxPath); if (!colFile.IsOpen()) { @@ -252,7 +253,7 @@ namespace BSP } } - std::unique_ptr bsp; + std::unique_ptr bsp = std::make_unique(); bsp->name = mapName; bsp->bspName = "maps/mp/" + mapName + ".d3dbsp"; diff --git a/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp b/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp index a6a1b8f4..118594bb 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp @@ -5,6 +5,11 @@ #include "BSPUtil.h" +std::string BSPUtil::getFileNameForBSPAsset(std::string assetName) +{ + return std::format("BSP/{}", assetName); +} + // BO2 uses a different coordinate system, so this converts it back from OpenGLs default vec3_t BSPUtil::convertToBO2Coords(vec3_t OGL_coordinate) { diff --git a/src/ObjLoading/Game/T6/BSP/BSPUtil.h b/src/ObjLoading/Game/T6/BSP/BSPUtil.h index ddbcd58e..7bad527f 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPUtil.h +++ b/src/ObjLoading/Game/T6/BSP/BSPUtil.h @@ -6,6 +6,7 @@ class BSPUtil { public: + static std::string getFileNameForBSPAsset(std::string assetName); static vec3_t convertToBO2Coords(vec3_t OGL_coordinate); static vec3_t convertFromBO2Coords(vec3_t bo2_coordinate); static void calcNewBounds(vec3_t* newmins, vec3_t* newmaxs, vec3_t* currmins, vec3_t* currmaxs); diff --git a/src/ObjLoading/Game/T6/BSP/CustomMapLinker.h b/src/ObjLoading/Game/T6/BSP/CustomMapLinker.h index 9b11e348..33ea1dce 100644 --- a/src/ObjLoading/Game/T6/BSP/CustomMapLinker.h +++ b/src/ObjLoading/Game/T6/BSP/CustomMapLinker.h @@ -1168,7 +1168,7 @@ namespace BSP // converting OGL -> BO2 Z coords negates the z coords and sets it to the y coord. // convert the z normal to the y normal, but don't negate it. Negative normals don't do // what is expected when the game uses them - _ASSERT(node->u.node->axis == AXIS_Z); + _ASSERT(node->node->axis == AXIS_Z); currPlane->normal = normalY; // converting OGL -> BO2 Z coords negates the z coords and sets it to the y coord. diff --git a/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp b/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp index 708602f1..b3a02399 100644 --- a/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp +++ b/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp @@ -19,20 +19,20 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { // custom maps must have a map_gfx file - auto mapGfxFile = m_search_path.Open("BSP/map_gfx.fbx"); + auto mapGfxFile = m_search_path.Open(BSPUtil::getFileNameForBSPAsset("map_gfx.fbx")); if (!mapGfxFile.IsOpen()) return AssetCreationResult::NoAction(); - BSPData* BSP = BSP::createBSPData(m_zone.m_name, m_search_path); - if (BSP == nullptr) + std::unique_ptr bsp = BSP::createBSPData(m_zone.m_name, m_search_path); + if (bsp == nullptr) return AssetCreationResult::Failure(); CustomMapLinker linker(m_memory, m_search_path, m_zone, context); - bool result = linker.linkCustomMap(BSP); + bool result = linker.linkCustomMap(bsp.get()); if (result) { - auto gfxWorldAsset = context.LoadDependency(BSP->bspName); + auto gfxWorldAsset = context.LoadDependency(bsp->bspName); _ASSERT(gfxWorldAsset != nullptr); return AssetCreationResult::Success(gfxWorldAsset); }