mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
add explicit null pointer checks
This commit is contained in:
@@ -307,6 +307,9 @@ bool compareArtifacts(const CArtifactInstance * a1, const CArtifactInstance * a2
|
|||||||
|
|
||||||
bool isWeeklyRevisitable(const CGObjectInstance * obj)
|
bool isWeeklyRevisitable(const CGObjectInstance * obj)
|
||||||
{
|
{
|
||||||
|
if(!obj)
|
||||||
|
return false;
|
||||||
|
|
||||||
//TODO: allow polling of remaining creatures in dwelling
|
//TODO: allow polling of remaining creatures in dwelling
|
||||||
if(dynamic_cast<const CGVisitableOPW *>(obj)) // ensures future compatibility, unlike IDs
|
if(dynamic_cast<const CGVisitableOPW *>(obj)) // ensures future compatibility, unlike IDs
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1327,7 +1327,7 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
|
|||||||
ki->townChanged(townObj);
|
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))
|
|| town->ID == Obj::CREATURE_GENERATOR4 || town->ID == Obj::WAR_MACHINE_FACTORY))
|
||||||
{
|
{
|
||||||
CRecruitmentWindow *crw = dynamic_cast<CRecruitmentWindow*>(GH.topInt().get());
|
CRecruitmentWindow *crw = dynamic_cast<CRecruitmentWindow*>(GH.topInt().get());
|
||||||
|
@@ -196,7 +196,7 @@ bool CDefenceAnimation::init()
|
|||||||
}
|
}
|
||||||
//unit reversed
|
//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)
|
for(std::list<ProjectileInfo>::const_iterator it = owner->projectiles.begin(); it != owner->projectiles.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@@ -315,6 +315,9 @@ int InfoBoxHeroData::getSubID()
|
|||||||
|
|
||||||
si64 InfoBoxHeroData::getValue()
|
si64 InfoBoxHeroData::getValue()
|
||||||
{
|
{
|
||||||
|
if(!hero)
|
||||||
|
return 0;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case HERO_PRIMARY_SKILL:
|
case HERO_PRIMARY_SKILL:
|
||||||
|
@@ -463,7 +463,7 @@ std::vector<int3> CPathfinderHelper::getAllowedTeleportChannelExits(TeleportChan
|
|||||||
allowedExits.push_back(p);
|
allowedExits.push_back(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(CGTeleport::isExitPassable(gs, hero, obj))
|
else if(obj && CGTeleport::isExitPassable(gs, hero, obj))
|
||||||
allowedExits.push_back(obj->visitablePos());
|
allowedExits.push_back(obj->visitablePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user