1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

add explicit null pointer checks

This commit is contained in:
Andrey Filipenkov 2022-09-24 17:29:29 +03:00
parent 659be89a01
commit 72feb538ce
5 changed files with 9 additions and 3 deletions

View File

@ -307,6 +307,9 @@ bool compareArtifacts(const CArtifactInstance * a1, const CArtifactInstance * a2
bool isWeeklyRevisitable(const CGObjectInstance * obj)
{
if(!obj)
return false;
//TODO: allow polling of remaining creatures in dwelling
if(dynamic_cast<const CGVisitableOPW *>(obj)) // ensures future compatibility, unlike IDs
return true;

View File

@ -1327,7 +1327,7 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
ki->townChanged(townObj);
}
}
else if (GH.listInt.size() && (town->ID == Obj::CREATURE_GENERATOR1
else if(town && GH.listInt.size() && (town->ID == Obj::CREATURE_GENERATOR1
|| town->ID == Obj::CREATURE_GENERATOR4 || town->ID == Obj::WAR_MACHINE_FACTORY))
{
CRecruitmentWindow *crw = dynamic_cast<CRecruitmentWindow*>(GH.topInt().get());

View File

@ -196,7 +196,7 @@ bool CDefenceAnimation::init()
}
//unit reversed
if(rangedAttack) //delay hit animation
if(rangedAttack && attacker != nullptr) //delay hit animation
{
for(std::list<ProjectileInfo>::const_iterator it = owner->projectiles.begin(); it != owner->projectiles.end(); ++it)
{

View File

@ -315,6 +315,9 @@ int InfoBoxHeroData::getSubID()
si64 InfoBoxHeroData::getValue()
{
if(!hero)
return 0;
switch(type)
{
case HERO_PRIMARY_SKILL:

View File

@ -463,7 +463,7 @@ std::vector<int3> CPathfinderHelper::getAllowedTeleportChannelExits(TeleportChan
allowedExits.push_back(p);
}
}
else if(CGTeleport::isExitPassable(gs, hero, obj))
else if(obj && CGTeleport::isExitPassable(gs, hero, obj))
allowedExits.push_back(obj->visitablePos());
}