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:
parent
659be89a01
commit
72feb538ce
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -315,6 +315,9 @@ int InfoBoxHeroData::getSubID()
|
||||
|
||||
si64 InfoBoxHeroData::getValue()
|
||||
{
|
||||
if(!hero)
|
||||
return 0;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case HERO_PRIMARY_SKILL:
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user