From f9738f0d0b2f954da70cd2d8518567d61076fa4e Mon Sep 17 00:00:00 2001 From: SoundSSGood <87084363+SoundSSGood@users.noreply.github.com> Date: Sun, 13 Nov 2022 16:24:23 +0200 Subject: [PATCH] nullptr checks --- lib/CArtHandler.cpp | 2 +- server/CGameHandler.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index ea86da199..1bc68666b 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -1518,7 +1518,7 @@ DLL_LINKAGE bool ArtifactUtils::isArtRemovable(const std::pair>(psrcHero), static_cast>(pdstHero), swap); @@ -3952,7 +3954,9 @@ bool CGameHandler::bulkMoveArtifacts(ObjectInstanceID srcHero, ObjectInstanceID continue; slots.push_back(BulkMoveArtifacts::LinkedSlots(artifact.first, artifact.first)); - if(ArtifactUtils::checkSpellbookIsNeeded(dstHero, artifact.second.getArt()->artType->id, artifact.first)) + auto art = artifact.second.getArt(); + assert(art); + if(ArtifactUtils::checkSpellbookIsNeeded(dstHero, art->artType->id, artifact.first)) giveHeroNewArtifact(dstHero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK); } }; @@ -3984,6 +3988,7 @@ bool CGameHandler::bulkMoveArtifacts(ObjectInstanceID srcHero, ObjectInstanceID auto moveArtifact = [this, &artFittingSet, &slotsSrcDst](const CArtifactInstance * artifact, ArtifactPosition srcSlot, const CGHeroInstance * pdstHero) -> void { + assert(artifact); auto dstSlot = ArtifactUtils::getArtifactDstPosition(artifact, &artFittingSet, pdstHero->bearerType()); artFittingSet.putArtifact(dstSlot, static_cast>(artifact)); slotsSrcDst.push_back(BulkMoveArtifacts::LinkedSlots(srcSlot, dstSlot));