Преглед изворни кода

add explicit null pointer checks

Andrey Filipenkov пре 3 година
родитељ
комит
72feb538ce

+ 3 - 0
AI/Nullkiller/AIUtility.cpp

@@ -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;

+ 1 - 1
client/CPlayerInterface.cpp

@@ -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());

+ 1 - 1
client/battle/CBattleAnimations.cpp

@@ -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)
 		{
 		{

+ 3 - 0
client/windows/CKingdomInterface.cpp

@@ -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:

+ 1 - 1
lib/CPathfinder.cpp

@@ -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());
 	}
 	}