From 9471cbc1f43269648a1ba81baf62f4ea3a90870b Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 9 Nov 2025 22:09:06 +0100 Subject: [PATCH] chore: use auto instead of repeated types --- src/ObjLoading/Game/T6/BSP/BSPCalculation.cpp | 2 +- src/ObjLoading/Game/T6/BSP/BSPCreator.cpp | 2 +- src/ObjLoading/Game/T6/BSP/BSPUtil.cpp | 24 ++++++++--------- .../Game/T6/BSP/Linker/BSPLinker.cpp | 14 +++++----- .../Game/T6/BSP/Linker/ClipMapLinker.cpp | 26 +++++++++---------- .../Game/T6/BSP/Linker/GameWorldMpLinker.cpp | 2 +- .../Game/T6/BSP/Linker/GfxWorldLinker.cpp | 18 ++++++------- .../Game/T6/BSP/Linker/SkinnedVertsLinker.cpp | 2 +- src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp | 4 +-- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/ObjLoading/Game/T6/BSP/BSPCalculation.cpp b/src/ObjLoading/Game/T6/BSP/BSPCalculation.cpp index 4c30274a..99d9f0c5 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPCalculation.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPCalculation.cpp @@ -142,7 +142,7 @@ namespace BSP } else { - const PlaneSide side = node->objectIsInFront(*object); + const auto side = node->objectIsInFront(*object); if (side == SIDE_FRONT) { node->front->addObjectToTree(std::move(object)); diff --git a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp index 27104dd7..0ad40e89 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp @@ -259,7 +259,7 @@ namespace BSP } } - std::unique_ptr bsp = std::make_unique(); + auto 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 80a2288e..c532926c 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp @@ -75,9 +75,9 @@ namespace BSP float BSPUtil::distBetweenPoints(const vec3_t& p1, const vec3_t& p2) { - const float x = p2.x - p1.x; - const float y = p2.y - p1.y; - const float z = p2.z - p1.z; + const auto x = p2.x - p1.x; + const auto y = p2.y - p1.y; + const auto z = p2.z - p1.z; return sqrtf((x * x) + (y * y) + (z * z)); } @@ -85,16 +85,16 @@ namespace BSP // angles are in euler degrees void BSPUtil::convertAnglesToAxis(const vec3_t* angles, vec3_t* axis) { - const float xRadians = angles->x * 0.017453292f; // M_PI / 180.0f - const float yRadians = angles->y * 0.017453292f; // M_PI / 180.0f - const float zRadians = angles->z * 0.017453292f; // M_PI / 180.0f + const auto xRadians = angles->x * 0.017453292f; // M_PI / 180.0f + const auto yRadians = angles->y * 0.017453292f; // M_PI / 180.0f + const auto zRadians = angles->z * 0.017453292f; // M_PI / 180.0f - const float cosX = cos(xRadians); - const float sinX = sin(xRadians); - const float cosY = cos(yRadians); - const float sinY = sin(yRadians); - const float cosZ = cos(zRadians); - const float sinZ = sin(zRadians); + const auto cosX = cos(xRadians); + const auto sinX = sin(xRadians); + const auto cosY = cos(yRadians); + const auto sinY = sin(yRadians); + const auto cosZ = cos(zRadians); + const auto sinZ = sin(zRadians); axis[0].x = cosX * cosY; axis[0].y = cosX * sinY; diff --git a/src/ObjLoading/Game/T6/BSP/Linker/BSPLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/BSPLinker.cpp index fe006dc7..ced11ee0 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/BSPLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/BSPLinker.cpp @@ -16,7 +16,7 @@ namespace BSP if (assetName.length() == 0) return nullptr; - FootstepTableDef* footstepTable = m_memory.Alloc(); + auto* footstepTable = m_memory.Alloc(); footstepTable->name = m_memory.Dup(assetName.c_str()); memset(footstepTable->sndAliasTable, 0, sizeof(footstepTable->sndAliasTable)); @@ -73,32 +73,32 @@ namespace BSP MapEntsLinker mapEntsLinker(m_memory, m_search_path, m_context); SkinnedVertsLinker skinnedVertsLinker(m_memory, m_search_path, m_context); - ComWorld* comWorld = comWorldLinker.linkComWorld(bsp); + auto* comWorld = comWorldLinker.linkComWorld(bsp); if (comWorld == nullptr) return false; m_context.AddAsset(comWorld->name, comWorld); - MapEnts* mapEnts = mapEntsLinker.linkMapEnts(bsp); + auto* mapEnts = mapEntsLinker.linkMapEnts(bsp); if (mapEnts == nullptr) return false; m_context.AddAsset(mapEnts->name, mapEnts); - GameWorldMp* gameWorldMp = gameWorldMpLinker.linkGameWorldMp(bsp); + auto* gameWorldMp = gameWorldMpLinker.linkGameWorldMp(bsp); if (gameWorldMp == nullptr) return false; m_context.AddAsset(gameWorldMp->name, gameWorldMp); - SkinnedVertsDef* skinnedVerts = skinnedVertsLinker.linkSkinnedVerts(bsp); + auto* skinnedVerts = skinnedVertsLinker.linkSkinnedVerts(bsp); if (skinnedVerts == nullptr) return false; m_context.AddAsset(skinnedVerts->name, skinnedVerts); - GfxWorld* gfxWorld = gfxWorldLinker.linkGfxWorld(bsp); // requires mapents asset + auto* gfxWorld = gfxWorldLinker.linkGfxWorld(bsp); // requires mapents asset if (gfxWorld == nullptr) return false; m_context.AddAsset(gfxWorld->name, gfxWorld); - clipMap_t* clipMap = clipMapLinker.linkClipMap(bsp); // requires gfxworld and mapents asset + auto* clipMap = clipMapLinker.linkClipMap(bsp); // requires gfxworld and mapents asset if (clipMap == nullptr) return false; m_context.AddAsset(clipMap->name, clipMap); diff --git a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp index cca93af1..9fe2a787 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp @@ -129,7 +129,7 @@ namespace BSP // Submodels are used for the world and map ent collision (triggers, bomb zones, etc) auto gfxWorldAsset = m_context.LoadDependency(bsp.bspName); assert(gfxWorldAsset != nullptr); - GfxWorld* gfxWorld = gfxWorldAsset->Asset(); + auto* gfxWorld = gfxWorldAsset->Asset(); // Right now there is only one submodel, the world sub model assert(gfxWorld->modelCount == 1); @@ -137,7 +137,7 @@ namespace BSP clipMap.numSubModels = 1; clipMap.cmodels = m_memory.Alloc(clipMap.numSubModels); - GfxBrushModel* gfxModel = &gfxWorld->models[0]; + auto* gfxModel = &gfxWorld->models[0]; clipMap.cmodels[0].mins.x = gfxModel->bounds[0].x; clipMap.cmodels[0].mins.y = gfxModel->bounds[0].y; clipMap.cmodels[0].mins.z = gfxModel->bounds[0].z; @@ -420,14 +420,14 @@ namespace BSP } BSPUtil::updateAABBWithPoint(vertex, worldMins, worldMaxs); } - std::unique_ptr tree = std::make_unique(worldMins.x, worldMins.y, worldMins.z, worldMaxs.x, worldMaxs.y, worldMaxs.z, 0); + const auto tree = std::make_unique(worldMins.x, worldMins.y, worldMins.z, worldMaxs.x, worldMaxs.y, worldMaxs.z, 0); assert(!tree->isLeaf); for (int partitionIdx = 0; partitionIdx < clipMap.partitionCount; partitionIdx++) { vec3_t partitionMins; vec3_t partitionMaxs; - CollisionPartition* partition = &clipMap.partitions[partitionIdx]; + auto* partition = &clipMap.partitions[partitionIdx]; for (int uindIdx = 0; uindIdx < partition->nuinds; uindIdx++) { uint16_t uind = clipMap.info.uinds[partition->fuind + uindIdx]; @@ -440,7 +440,7 @@ namespace BSP } BSPUtil::updateAABBWithPoint(vert, partitionMins, partitionMaxs); } - std::shared_ptr currObject = + auto currObject = std::make_shared(partitionMins.x, partitionMins.y, partitionMins.z, partitionMaxs.x, partitionMaxs.y, partitionMaxs.z, partitionIdx); tree->addObjectToTree(std::move(currObject)); } @@ -491,11 +491,11 @@ namespace BSP std::vector triIndexVec; for (const BSPSurface& surface : bsp.colWorld.surfaces) { - const int indexOfFirstIndex = surface.indexOfFirstIndex; - const int indexOfFirstVertex = surface.indexOfFirstVertex; - for (int indexIdx = 0; indexIdx < surface.triCount * 3; indexIdx++) + const auto indexOfFirstIndex = surface.indexOfFirstIndex; + const auto indexOfFirstVertex = surface.indexOfFirstVertex; + for (auto indexIdx = 0; indexIdx < surface.triCount * 3; indexIdx++) { - int triIndex = bsp.colWorld.indices[indexOfFirstIndex + indexIdx] + indexOfFirstVertex; + auto triIndex = bsp.colWorld.indices[indexOfFirstIndex + indexIdx] + indexOfFirstVertex; triIndexVec.emplace_back(triIndex); } } @@ -512,9 +512,9 @@ namespace BSP // partitions are made for each triangle, not one for each surface. // one for each surface causes physics bugs, as the entire bounding box is considered solid instead of the surface itself (for some reason). // so a partition is made for each triangle which removes the physics bugs but likely makes the game run slower - const int indexOfFirstTri = surface.indexOfFirstIndex / 3; - const int indexOfFirstVertex = surface.indexOfFirstVertex; - for (int triIdx = 0; triIdx < surface.triCount; triIdx++) + const auto indexOfFirstTri = surface.indexOfFirstIndex / 3; + const auto indexOfFirstVertex = surface.indexOfFirstVertex; + for (auto triIdx = 0; triIdx < surface.triCount; triIdx++) { CollisionPartition partition; partition.triCount = 1; @@ -524,7 +524,7 @@ namespace BSP partition.fuind = static_cast(uniqueIndicesVec.size()); // All tri indices are unique since there is only one tri per partition - uint16_t* tri = clipMap.triIndices[partition.firstTri]; + auto* tri = clipMap.triIndices[partition.firstTri]; uniqueIndicesVec.emplace_back(tri[0]); uniqueIndicesVec.emplace_back(tri[1]); uniqueIndicesVec.emplace_back(tri[2]); diff --git a/src/ObjLoading/Game/T6/BSP/Linker/GameWorldMpLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/GameWorldMpLinker.cpp index aa3ef109..5c8ee56e 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/GameWorldMpLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/GameWorldMpLinker.cpp @@ -24,7 +24,7 @@ namespace BSP gameWorldMp->path.nodeTreeCount = 0; // The game has 128 empty nodes allocated - const int extraNodeCount = gameWorldMp->path.nodeCount + 128; + const auto extraNodeCount = gameWorldMp->path.nodeCount + 128; gameWorldMp->path.nodes = m_memory.Alloc(extraNodeCount); gameWorldMp->path.basenodes = m_memory.Alloc(extraNodeCount); gameWorldMp->path.pathVis = nullptr; diff --git a/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp index 2f86d8ca..ca9d2eed 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp @@ -675,11 +675,11 @@ namespace BSP gfxWorld.dpvsDyn.dynEntClientWordCount[1] = 0; gfxWorld.dpvsDyn.usageCount = 0; - const int dynEntCellBitsSize = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * gfxWorld.dpvsPlanes.cellCount; + const auto dynEntCellBitsSize = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * gfxWorld.dpvsPlanes.cellCount; gfxWorld.dpvsDyn.dynEntCellBits[0] = m_memory.Alloc(dynEntCellBitsSize); gfxWorld.dpvsDyn.dynEntCellBits[1] = nullptr; - const int dynEntVisData0Size = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * 32; + const auto dynEntVisData0Size = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * 32; gfxWorld.dpvsDyn.dynEntVisData[0][0] = m_memory.Alloc(dynEntVisData0Size); gfxWorld.dpvsDyn.dynEntVisData[0][1] = m_memory.Alloc(dynEntVisData0Size); gfxWorld.dpvsDyn.dynEntVisData[0][2] = m_memory.Alloc(dynEntVisData0Size); @@ -687,7 +687,7 @@ namespace BSP gfxWorld.dpvsDyn.dynEntVisData[1][1] = nullptr; gfxWorld.dpvsDyn.dynEntVisData[1][2] = nullptr; - const unsigned int dynEntShadowVisCount = gfxWorld.dpvsDyn.dynEntClientCount[0] * (gfxWorld.primaryLightCount - gfxWorld.sunPrimaryLightIndex - 1); + const auto dynEntShadowVisCount = gfxWorld.dpvsDyn.dynEntClientCount[0] * (gfxWorld.primaryLightCount - gfxWorld.sunPrimaryLightIndex - 1); gfxWorld.primaryLightDynEntShadowVis[0] = m_memory.Alloc(dynEntShadowVisCount); gfxWorld.primaryLightDynEntShadowVis[1] = nullptr; @@ -697,14 +697,14 @@ namespace BSP bool GfxWorldLinker::loadOutdoors(GfxWorld& gfxWorld) const { - const float xRecip = 1.0f / (gfxWorld.maxs.x - gfxWorld.mins.x); - const float xScale = -(xRecip * gfxWorld.mins.x); + const auto xRecip = 1.0f / (gfxWorld.maxs.x - gfxWorld.mins.x); + const auto xScale = -(xRecip * gfxWorld.mins.x); - const float yRecip = 1.0f / (gfxWorld.maxs.y - gfxWorld.mins.y); - const float yScale = -(yRecip * gfxWorld.mins.y); + const auto yRecip = 1.0f / (gfxWorld.maxs.y - gfxWorld.mins.y); + const auto yScale = -(yRecip * gfxWorld.mins.y); - const float zRecip = 1.0f / (gfxWorld.maxs.z - gfxWorld.mins.z); - const float zScale = -(zRecip * gfxWorld.mins.z); + const auto zRecip = 1.0f / (gfxWorld.maxs.z - gfxWorld.mins.z); + const auto zScale = -(zRecip * gfxWorld.mins.z); memset(gfxWorld.outdoorLookupMatrix, 0, sizeof(gfxWorld.outdoorLookupMatrix)); diff --git a/src/ObjLoading/Game/T6/BSP/Linker/SkinnedVertsLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/SkinnedVertsLinker.cpp index 0946c611..1efcb58d 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/SkinnedVertsLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/SkinnedVertsLinker.cpp @@ -13,7 +13,7 @@ namespace BSP { // Pretty sure maxSkinnedVerts relates to the max amount of xmodel skinned verts a map will have // But setting it to the world vertex count seems to work - T6::SkinnedVertsDef* skinnedVerts = m_memory.Alloc(); + auto* skinnedVerts = m_memory.Alloc(); skinnedVerts->name = m_memory.Dup("skinnedverts"); skinnedVerts->maxSkinnedVerts = static_cast(bsp.gfxWorld.vertices.size()); diff --git a/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp b/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp index d3f80499..0207a40b 100644 --- a/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp +++ b/src/ObjLoading/Game/T6/BSP/LoaderBSP_T6.cpp @@ -32,12 +32,12 @@ namespace bool FinalizeZone(AssetCreationContext& context) override { - const std::unique_ptr bsp = BSP::createBSPData(m_zone.m_name, m_search_path); + const auto bsp = BSP::createBSPData(m_zone.m_name, m_search_path); if (bsp == nullptr) return false; BSPLinker linker(m_memory, m_search_path, context); - const bool result = linker.linkBSP(*bsp); + const auto result = linker.linkBSP(*bsp); if (!result) con::error("BSP link has failed.");