mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 05:12:05 +00:00
chore: replace explicit nullptr checks with negation checks
This commit is contained in:
@@ -27,18 +27,18 @@ namespace BSP
|
|||||||
|
|
||||||
bool BSPLinker::addDefaultRequiredAssets(const BSPData& bsp) const
|
bool BSPLinker::addDefaultRequiredAssets(const BSPData& bsp) const
|
||||||
{
|
{
|
||||||
if (m_context.LoadDependency<AssetScript>(std::format("maps/mp/{}.gsc", bsp.name)) == nullptr)
|
if (!m_context.LoadDependency<AssetScript>(std::format("maps/mp/{}.gsc", bsp.name)))
|
||||||
return false;
|
return false;
|
||||||
if (m_context.LoadDependency<AssetScript>(std::format("maps/mp/{}_amb.gsc", bsp.name)) == nullptr)
|
if (!m_context.LoadDependency<AssetScript>(std::format("maps/mp/{}_amb.gsc", bsp.name)))
|
||||||
return false;
|
return false;
|
||||||
if (m_context.LoadDependency<AssetScript>(std::format("maps/mp/{}_fx.gsc", bsp.name)) == nullptr)
|
if (!m_context.LoadDependency<AssetScript>(std::format("maps/mp/{}_fx.gsc", bsp.name)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_context.LoadDependency<AssetScript>(std::format("clientscripts/mp/{}.csc", bsp.name)) == nullptr)
|
if (!m_context.LoadDependency<AssetScript>(std::format("clientscripts/mp/{}.csc", bsp.name)))
|
||||||
return false;
|
return false;
|
||||||
if (m_context.LoadDependency<AssetScript>(std::format("clientscripts/mp/{}_amb.csc", bsp.name)) == nullptr)
|
if (!m_context.LoadDependency<AssetScript>(std::format("clientscripts/mp/{}_amb.csc", bsp.name)))
|
||||||
return false;
|
return false;
|
||||||
if (m_context.LoadDependency<AssetScript>(std::format("clientscripts/mp/{}_fx.csc", bsp.name)) == nullptr)
|
if (!m_context.LoadDependency<AssetScript>(std::format("clientscripts/mp/{}_fx.csc", bsp.name)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
addEmptyFootstepTableAsset("default_1st_person");
|
addEmptyFootstepTableAsset("default_1st_person");
|
||||||
@@ -48,7 +48,7 @@ namespace BSP
|
|||||||
addEmptyFootstepTableAsset("default_3rd_person_loud");
|
addEmptyFootstepTableAsset("default_3rd_person_loud");
|
||||||
addEmptyFootstepTableAsset("default_ai");
|
addEmptyFootstepTableAsset("default_ai");
|
||||||
|
|
||||||
if (m_context.LoadDependency<AssetRawFile>("animtrees/fxanim_props.atr") == nullptr)
|
if (!m_context.LoadDependency<AssetRawFile>("animtrees/fxanim_props.atr"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -74,32 +74,32 @@ namespace BSP
|
|||||||
SkinnedVertsLinker skinnedVertsLinker(m_memory, m_search_path, m_context);
|
SkinnedVertsLinker skinnedVertsLinker(m_memory, m_search_path, m_context);
|
||||||
|
|
||||||
auto* comWorld = comWorldLinker.linkComWorld(bsp);
|
auto* comWorld = comWorldLinker.linkComWorld(bsp);
|
||||||
if (comWorld == nullptr)
|
if (!comWorld)
|
||||||
return false;
|
return false;
|
||||||
m_context.AddAsset<AssetComWorld>(comWorld->name, comWorld);
|
m_context.AddAsset<AssetComWorld>(comWorld->name, comWorld);
|
||||||
|
|
||||||
auto* mapEnts = mapEntsLinker.linkMapEnts(bsp);
|
auto* mapEnts = mapEntsLinker.linkMapEnts(bsp);
|
||||||
if (mapEnts == nullptr)
|
if (!mapEnts)
|
||||||
return false;
|
return false;
|
||||||
m_context.AddAsset<AssetMapEnts>(mapEnts->name, mapEnts);
|
m_context.AddAsset<AssetMapEnts>(mapEnts->name, mapEnts);
|
||||||
|
|
||||||
auto* gameWorldMp = gameWorldMpLinker.linkGameWorldMp(bsp);
|
auto* gameWorldMp = gameWorldMpLinker.linkGameWorldMp(bsp);
|
||||||
if (gameWorldMp == nullptr)
|
if (!gameWorldMp)
|
||||||
return false;
|
return false;
|
||||||
m_context.AddAsset<AssetGameWorldMp>(gameWorldMp->name, gameWorldMp);
|
m_context.AddAsset<AssetGameWorldMp>(gameWorldMp->name, gameWorldMp);
|
||||||
|
|
||||||
auto* skinnedVerts = skinnedVertsLinker.linkSkinnedVerts(bsp);
|
auto* skinnedVerts = skinnedVertsLinker.linkSkinnedVerts(bsp);
|
||||||
if (skinnedVerts == nullptr)
|
if (!skinnedVerts)
|
||||||
return false;
|
return false;
|
||||||
m_context.AddAsset<AssetSkinnedVerts>(skinnedVerts->name, skinnedVerts);
|
m_context.AddAsset<AssetSkinnedVerts>(skinnedVerts->name, skinnedVerts);
|
||||||
|
|
||||||
auto* gfxWorld = gfxWorldLinker.linkGfxWorld(bsp); // requires mapents asset
|
auto* gfxWorld = gfxWorldLinker.linkGfxWorld(bsp); // requires mapents asset
|
||||||
if (gfxWorld == nullptr)
|
if (!gfxWorld)
|
||||||
return false;
|
return false;
|
||||||
m_context.AddAsset<AssetGfxWorld>(gfxWorld->name, gfxWorld);
|
m_context.AddAsset<AssetGfxWorld>(gfxWorld->name, gfxWorld);
|
||||||
|
|
||||||
auto* clipMap = clipMapLinker.linkClipMap(bsp); // requires gfxworld and mapents asset
|
auto* clipMap = clipMapLinker.linkClipMap(bsp); // requires gfxworld and mapents asset
|
||||||
if (clipMap == nullptr)
|
if (!clipMap)
|
||||||
return false;
|
return false;
|
||||||
m_context.AddAsset<AssetClipMap>(clipMap->name, clipMap);
|
m_context.AddAsset<AssetClipMap>(clipMap->name, clipMap);
|
||||||
|
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ namespace BSP
|
|||||||
surfMaterialName = BSPLinkingConstants::COLOR_ONLY_IMAGE_NAME;
|
surfMaterialName = BSPLinkingConstants::COLOR_ONLY_IMAGE_NAME;
|
||||||
|
|
||||||
auto surfMaterialAsset = m_context.LoadDependency<AssetMaterial>(surfMaterialName);
|
auto surfMaterialAsset = m_context.LoadDependency<AssetMaterial>(surfMaterialName);
|
||||||
if (surfMaterialAsset == nullptr)
|
if (!surfMaterialAsset)
|
||||||
{
|
{
|
||||||
std::string missingImageName = BSPLinkingConstants::MISSING_IMAGE_NAME;
|
std::string missingImageName = BSPLinkingConstants::MISSING_IMAGE_NAME;
|
||||||
surfMaterialAsset = m_context.LoadDependency<AssetMaterial>(missingImageName);
|
surfMaterialAsset = m_context.LoadDependency<AssetMaterial>(missingImageName);
|
||||||
if (surfMaterialAsset == nullptr)
|
if (!surfMaterialAsset)
|
||||||
{
|
{
|
||||||
con::error("unable to load the missing image texture {}!", missingImageName);
|
con::error("unable to load the missing image texture {}!", missingImageName);
|
||||||
return false;
|
return false;
|
||||||
@@ -174,7 +174,7 @@ namespace BSP
|
|||||||
customMapModel* inModel = &projInfo->models[i];
|
customMapModel* inModel = &projInfo->models[i];
|
||||||
|
|
||||||
auto xModelAsset = m_context.LoadDependency<AssetXModel>(inModel->name);
|
auto xModelAsset = m_context.LoadDependency<AssetXModel>(inModel->name);
|
||||||
if (xModelAsset == nullptr)
|
if (!xModelAsset)
|
||||||
{
|
{
|
||||||
printf("XModel %s not found!\n", inModel->name.c_str());
|
printf("XModel %s not found!\n", inModel->name.c_str());
|
||||||
currModel->model = nullptr;
|
currModel->model = nullptr;
|
||||||
@@ -616,7 +616,7 @@ namespace BSP
|
|||||||
|
|
||||||
std::string probeImageName = "reflection_probe0";
|
std::string probeImageName = "reflection_probe0";
|
||||||
auto probeImageAsset = m_context.LoadDependency<AssetImage>(probeImageName);
|
auto probeImageAsset = m_context.LoadDependency<AssetImage>(probeImageName);
|
||||||
if (probeImageAsset == nullptr)
|
if (!probeImageAsset)
|
||||||
{
|
{
|
||||||
con::error("ERROR! unable to find reflection probe image {}!", probeImageName);
|
con::error("ERROR! unable to find reflection probe image {}!", probeImageName);
|
||||||
return false;
|
return false;
|
||||||
@@ -635,7 +635,7 @@ namespace BSP
|
|||||||
|
|
||||||
std::string secondaryTexture = "lightmap0_secondary";
|
std::string secondaryTexture = "lightmap0_secondary";
|
||||||
auto secondaryTextureAsset = m_context.LoadDependency<AssetImage>(secondaryTexture);
|
auto secondaryTextureAsset = m_context.LoadDependency<AssetImage>(secondaryTexture);
|
||||||
if (secondaryTextureAsset == nullptr)
|
if (!secondaryTextureAsset)
|
||||||
{
|
{
|
||||||
con::error("ERROR! unable to find lightmap image {}!", secondaryTexture);
|
con::error("ERROR! unable to find lightmap image {}!", secondaryTexture);
|
||||||
return false;
|
return false;
|
||||||
@@ -652,7 +652,7 @@ namespace BSP
|
|||||||
const auto skyBoxName = std::format("skybox_{}", projInfo.name);
|
const auto skyBoxName = std::format("skybox_{}", projInfo.name);
|
||||||
gfxWorld.skyBoxModel = m_memory.Dup(skyBoxName.c_str());
|
gfxWorld.skyBoxModel = m_memory.Dup(skyBoxName.c_str());
|
||||||
|
|
||||||
if (m_context.LoadDependency<AssetXModel>(skyBoxName) == nullptr)
|
if (!m_context.LoadDependency<AssetXModel>(skyBoxName))
|
||||||
{
|
{
|
||||||
con::warn("WARN: Unable to load the skybox xmodel {}!", skyBoxName);
|
con::warn("WARN: Unable to load the skybox xmodel {}!", skyBoxName);
|
||||||
}
|
}
|
||||||
@@ -719,7 +719,7 @@ namespace BSP
|
|||||||
|
|
||||||
const std::string outdoorImageName = std::string("$outdoor");
|
const std::string outdoorImageName = std::string("$outdoor");
|
||||||
auto outdoorImageAsset = m_context.LoadDependency<AssetImage>(outdoorImageName);
|
auto outdoorImageAsset = m_context.LoadDependency<AssetImage>(outdoorImageName);
|
||||||
if (outdoorImageAsset == nullptr)
|
if (!outdoorImageAsset)
|
||||||
{
|
{
|
||||||
con::error("ERROR! unable to find outdoor image $outdoor!");
|
con::error("ERROR! unable to find outdoor image $outdoor!");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace
|
|||||||
bool FinalizeZone(AssetCreationContext& context) override
|
bool FinalizeZone(AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
const auto 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)
|
if (!bsp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BSPLinker linker(m_memory, m_search_path, context);
|
BSPLinker linker(m_memory, m_search_path, context);
|
||||||
|
|||||||
Reference in New Issue
Block a user