diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index c0e9e56800..cf8760e41c 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -5612,10 +5612,10 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell * const Object *obj, Int attackDistance) { Bool canPathThroughUnits = false; - if (obj && obj->getAIUpdateInterface()) { + if (obj->getAIUpdateInterface()) { canPathThroughUnits = obj->getAIUpdateInterface()->canPathThroughUnits(); } - Bool isCrusher = obj ? obj->getCrusherLevel() > 0 : false; + Bool isCrusher = obj->getCrusherLevel() > 0; if (attackDistance==NO_ATTACK && !m_isTunneling && !locomotorSet.isDownhillOnly() && goalCell) { ExamineCellsStruct info; info.thePathfinder = this; @@ -8777,7 +8777,7 @@ Bool Pathfinder::isViewBlockedByObstacle(const Object* obj, const Object* objOth ViewBlockedStruct info; info.obj = obj; info.objOther = objOther; - if (objOther && objOther->isSignificantlyAboveTerrain()) { + if (objOther->isSignificantlyAboveTerrain()) { return false; // We don't check los to flying objects. jba. } #if 1 @@ -9592,14 +9592,14 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, Int startTimeMS = ::GetTickCount(); #endif Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } Bool otherCenter; Int otherRadius; getRadiusAndCenter(otherObj, otherRadius, otherCenter); - Bool isCrusher = obj ? obj->getCrusherLevel() > 0 : false; + Bool isCrusher = obj->getCrusherLevel() > 0; m_zoneManager.setAllPassable(); @@ -9677,12 +9677,12 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, bounds.hi.y = cellCenter.y+boxHalfWidth; PathNode *node; Bool overlap = false; - if (obj) { - if (bounds.lo.xgetPosition()->x && bounds.hi.x>obj->getPosition()->x && - bounds.lo.ygetPosition()->y && bounds.hi.y>obj->getPosition()->y) { - //overlap = true; - } + + if (bounds.lo.xgetPosition()->x && bounds.hi.x>obj->getPosition()->x && + bounds.lo.ygetPosition()->y && bounds.hi.y>obj->getPosition()->y) { + //overlap = true; } + for( node = pathToAvoid->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; start.x = node->getPosition()->x; @@ -9694,12 +9694,12 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, break; } } - if (otherObj) { - if (bounds.lo.xgetPosition()->x && bounds.hi.x>otherObj->getPosition()->x && - bounds.lo.ygetPosition()->y && bounds.hi.y>otherObj->getPosition()->y) { - //overlap = true; - } + + if (bounds.lo.xgetPosition()->x && bounds.hi.x>otherObj->getPosition()->x && + bounds.lo.ygetPosition()->y && bounds.hi.y>otherObj->getPosition()->y) { + //overlap = true; } + if (!overlap && pathToAvoid2) { for( node = pathToAvoid2->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; @@ -9771,7 +9771,7 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet Int radius; getRadiusAndCenter(obj, radius, centerInCell); Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } @@ -9983,7 +9983,7 @@ Path *Pathfinder::findAttackPath( const Object *obj, const LocomotorSet& locomot // Int startTimeMS = ::GetTickCount(); #endif - Bool isCrusher = obj ? obj->getCrusherLevel() > 0 : false; + Bool isCrusher = obj->getCrusherLevel() > 0; Int radius; Bool centerInCell; getRadiusAndCenter(obj, radius, centerInCell); @@ -10034,7 +10034,7 @@ Path *Pathfinder::findAttackPath( const Object *obj, const LocomotorSet& locomot const Int ATTACK_CELL_LIMIT = 2500; // this is a rather expensive operation, so limit the search. Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } m_zoneManager.clearPassableFlags(); @@ -10260,7 +10260,7 @@ Path *Pathfinder::findSafePath( const Object *obj, const LocomotorSet& locomotor Real repulsorDistSqr = repulsorRadius*repulsorRadius; Int cellCount = 0; Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index d3563f3cfc..3cc382d4f8 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -2544,7 +2544,7 @@ void AIPlayer::checkQueuedTeams( void ) for ( DLINK_ITERATOR iter = iterate_TeamBuildQueue(); !iter.done(); iter.advance()) { TeamInQueue *team = iter.cur(); - if (team && team->isAllBuilt()) + if (team->isAllBuilt()) { // Move to ready queue removeFrom_TeamBuildQueue(team); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 04cac72bb3..db0eaf3152 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5071,7 +5071,7 @@ StateReturnType AIAttackFireWeaponState::update() rather than addressing the situation, we just punt and wait for it to clear up on its own. */ - if (m_att && !m_att->isWeaponSlotOkToFire(wslot)) + if (!m_att->isWeaponSlotOkToFire(wslot)) { return STATE_FAILURE; } @@ -5091,7 +5091,7 @@ StateReturnType AIAttackFireWeaponState::update() (victim->isDestroyed() || victim->isEffectivelyDead() || (victim->isKindOf(KINDOF_MINE) && victim->testStatus(OBJECT_STATUS_MASKED))) ) { - const Coord3D* originalVictimPos = m_att ? m_att->getOriginalVictimPos() : NULL; + const Coord3D* originalVictimPos = m_att->getOriginalVictimPos(); if (originalVictimPos) { // note that it is important to use getLastCommandSource here; this allows diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index c32a35d0b7..bd01fe3baf 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -6130,10 +6130,10 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell * const Object *obj, Int attackDistance) { Bool canPathThroughUnits = false; - if (obj && obj->getAIUpdateInterface()) { + if (obj->getAIUpdateInterface()) { canPathThroughUnits = obj->getAIUpdateInterface()->canPathThroughUnits(); } - Bool isCrusher = obj ? obj->getCrusherLevel() > 0 : false; + Bool isCrusher = obj->getCrusherLevel() > 0; if (attackDistance==NO_ATTACK && !m_isTunneling && !locomotorSet.isDownhillOnly() && goalCell) { ExamineCellsStruct info; info.thePathfinder = this; @@ -9404,7 +9404,7 @@ Bool Pathfinder::isViewBlockedByObstacle(const Object* obj, const Object* objOth ViewBlockedStruct info; info.obj = obj; info.objOther = objOther; - if (objOther && objOther->isSignificantlyAboveTerrain()) { + if (objOther->isSignificantlyAboveTerrain()) { return false; // We don't check los to flying objects. jba. } #if 1 @@ -10241,14 +10241,14 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, Int startTimeMS = ::GetTickCount(); #endif Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } Bool otherCenter; Int otherRadius; getRadiusAndCenter(otherObj, otherRadius, otherCenter); - Bool isCrusher = obj ? obj->getCrusherLevel() > 0 : false; + Bool isCrusher = obj->getCrusherLevel() > 0; m_zoneManager.setAllPassable(); @@ -10326,12 +10326,12 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, bounds.hi.y = cellCenter.y+boxHalfWidth; PathNode *node; Bool overlap = false; - if (obj) { - if (bounds.lo.xgetPosition()->x && bounds.hi.x>obj->getPosition()->x && - bounds.lo.ygetPosition()->y && bounds.hi.y>obj->getPosition()->y) { - //overlap = true; - } + + if (bounds.lo.xgetPosition()->x && bounds.hi.x>obj->getPosition()->x && + bounds.lo.ygetPosition()->y && bounds.hi.y>obj->getPosition()->y) { + //overlap = true; } + for( node = pathToAvoid->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; start.x = node->getPosition()->x; @@ -10343,12 +10343,12 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, break; } } - if (otherObj) { - if (bounds.lo.xgetPosition()->x && bounds.hi.x>otherObj->getPosition()->x && - bounds.lo.ygetPosition()->y && bounds.hi.y>otherObj->getPosition()->y) { - //overlap = true; - } + + if (bounds.lo.xgetPosition()->x && bounds.hi.x>otherObj->getPosition()->x && + bounds.lo.ygetPosition()->y && bounds.hi.y>otherObj->getPosition()->y) { + //overlap = true; } + if (!overlap && pathToAvoid2) { for( node = pathToAvoid2->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; @@ -10420,7 +10420,7 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet Int radius; getRadiusAndCenter(obj, radius, centerInCell); Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } @@ -10632,7 +10632,7 @@ Path *Pathfinder::findAttackPath( const Object *obj, const LocomotorSet& locomot // Int startTimeMS = ::GetTickCount(); #endif - Bool isCrusher = obj ? obj->getCrusherLevel() > 0 : false; + Bool isCrusher = obj->getCrusherLevel() > 0; Int radius; Bool centerInCell; getRadiusAndCenter(obj, radius, centerInCell); @@ -10683,7 +10683,7 @@ Path *Pathfinder::findAttackPath( const Object *obj, const LocomotorSet& locomot const Int ATTACK_CELL_LIMIT = 2500; // this is a rather expensive operation, so limit the search. Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } m_zoneManager.clearPassableFlags(); @@ -10967,7 +10967,7 @@ Path *Pathfinder::findSafePath( const Object *obj, const LocomotorSet& locomotor Real repulsorDistSqr = repulsorRadius*repulsorRadius; Int cellCount = 0; Bool isHuman = true; - if (obj && obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { + if (obj->getControllingPlayer() && (obj->getControllingPlayer()->getPlayerType()==PLAYER_COMPUTER)) { isHuman = false; // computer gets to cheat. } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 700012ac94..2a1daeee61 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -2873,7 +2873,7 @@ void AIPlayer::checkQueuedTeams( void ) for ( DLINK_ITERATOR iter = iterate_TeamBuildQueue(); !iter.done(); iter.advance()) { TeamInQueue *team = iter.cur(); - if (team && team->isAllBuilt()) + if (team->isAllBuilt()) { // Move to ready queue removeFrom_TeamBuildQueue(team); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 933d24025e..34c9ab1b35 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5226,7 +5226,7 @@ StateReturnType AIAttackFireWeaponState::update() rather than addressing the situation, we just punt and wait for it to clear up on its own. */ - if (m_att && !m_att->isWeaponSlotOkToFire(wslot)) + if (!m_att->isWeaponSlotOkToFire(wslot)) { return STATE_FAILURE; } @@ -5264,7 +5264,7 @@ StateReturnType AIAttackFireWeaponState::update() (victim->isDestroyed() || victim->isEffectivelyDead() || (victim->isKindOf(KINDOF_MINE) && victim->testStatus(OBJECT_STATUS_MASKED))) ) { - const Coord3D* originalVictimPos = m_att ? m_att->getOriginalVictimPos() : NULL; + const Coord3D* originalVictimPos = m_att->getOriginalVictimPos(); if (originalVictimPos) { // note that it is important to use getLastCommandSource here; this allows