diff --git a/Generals/Code/GameEngine/Include/GameLogic/PartitionManager.h b/Generals/Code/GameEngine/Include/GameLogic/PartitionManager.h index 091b139935..aa8f6044b6 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/PartitionManager.h +++ b/Generals/Code/GameEngine/Include/GameLogic/PartitionManager.h @@ -1090,7 +1090,9 @@ class PartitionFilterThing : public PartitionFilter Bool m_match; public: - PartitionFilterThing(const ThingTemplate *thing, Bool match) : m_tThing(thing), m_match(match) {} + PartitionFilterThing(const ThingTemplate *thing, Bool match) : m_tThing(thing), m_match(match) { + DEBUG_ASSERTCRASH(m_tThing != NULL, ("ThingTemplate for PartitionFilterThing is NULL")); + } protected: virtual Bool allow( Object *other ); #if defined(RTS_DEBUG) diff --git a/Generals/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp b/Generals/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp index 27c6824482..c6fc5d1d06 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp @@ -174,7 +174,7 @@ Int ScoreKeeper::getTotalObjectsBuilt( const ThingTemplate *pTemplate ) for (ObjectCountMapIt it = m_objectsBuilt.begin(); it != m_objectsBuilt.end(); ++it) { const ThingTemplate *theTemplate = it->first; - if (theTemplate->isEquivalentTo(pTemplate)) + if (theTemplate && theTemplate->isEquivalentTo(pTemplate)) ++count; } return count; diff --git a/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp b/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp index a833bce0ed..afaa2d3425 100644 --- a/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp @@ -1218,9 +1218,8 @@ Bool BuildAssistant::isPossibleToMakeUnit( Object *builder, const ThingTemplate // get this button commandButton = commandSet->getCommandButton(i); if( commandButton && - (commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD || - commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) && - commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) ) + (commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD || commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) && + commandButton->getThingTemplate() && commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) ) foundCommand = commandButton; } // end for i diff --git a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp index bfa6a90533..bfa52f547e 100644 --- a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -1319,7 +1319,7 @@ const AudioEventRTS *ThingTemplate::getPerUnitSound(const AsciiString& soundName Bool ThingTemplate::isEquivalentTo(const ThingTemplate* tt) const { // sanity - if (!(this && tt)) + if (!tt) return false; // sanity diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index a90c6141d1..c8ff78568a 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -232,7 +232,7 @@ void AISkirmishPlayer::processBaseBuilding( void ) } } } - if (powerPlan && powerInfo && !powerPlan->isEquivalentTo(bldgPlan)) { + if (powerInfo && powerPlan && !powerPlan->isEquivalentTo(bldgPlan)) { if (!powerUnderConstruction) { bldgPlan = powerPlan; bldgInfo = powerInfo; diff --git a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp index 8b6c56b855..32fca872c1 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp @@ -1738,7 +1738,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (beacon) { const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() ); - if (thing->isEquivalentTo(beacon->getTemplate())) + if (thing && thing->isEquivalentTo(beacon->getTemplate())) { if (beacon->getControllingPlayer() == thisPlayer) { diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h index aae710f2b5..7caf5dac68 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h @@ -1127,7 +1127,9 @@ class PartitionFilterThing : public PartitionFilter Bool m_match; public: - PartitionFilterThing(const ThingTemplate *thing, Bool match) : m_tThing(thing), m_match(match) {} + PartitionFilterThing(const ThingTemplate *thing, Bool match) : m_tThing(thing), m_match(match) { + DEBUG_ASSERTCRASH(m_tThing != NULL, ("ThingTemplate for PartitionFilterThing is NULL")); + } protected: virtual Bool allow( Object *other ); #if defined(RTS_DEBUG) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp index 34ab9806b1..87854745c3 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp @@ -1377,7 +1377,7 @@ static void doFindMostReadyWeaponForThing( Object *obj, void *userData ) return; } - if( info->thing->isEquivalentTo( obj->getTemplate() ) ) + if( info->thing && info->thing->isEquivalentTo( obj->getTemplate() ) ) { if( !obj->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) && !obj->testStatus( OBJECT_STATUS_SOLD ) @@ -1409,7 +1409,7 @@ static void doFindMostReadySpecialPowerForThing( Object *obj, void *userData ) return; } - if( info->thing->isEquivalentTo( obj->getTemplate() ) ) + if( info->thing && info->thing->isEquivalentTo( obj->getTemplate() ) ) { if( !obj->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) && !obj->testStatus( OBJECT_STATUS_SOLD ) @@ -1445,7 +1445,7 @@ static void doFindExistingObjectWithThingTemplate( Object *obj, void *userData ) return; } - if( info->thing->isEquivalentTo( obj->getTemplate() ) ) + if( info->thing && info->thing->isEquivalentTo( obj->getTemplate() ) ) { if( !obj->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) && !obj->testStatus( OBJECT_STATUS_SOLD ) @@ -2863,7 +2863,7 @@ static void countExisting( Object *obj, void *userData ) TypeCountData *typeCountData = (TypeCountData *)userData; // Compare templates - if ( typeCountData->type->isEquivalentTo( obj->getTemplate() ) || + if ( ( typeCountData->type && typeCountData->type->isEquivalentTo( obj->getTemplate() ) ) || ( typeCountData->linkKey != NAMEKEY_INVALID && obj->getTemplate() != NULL && typeCountData->linkKey == obj->getTemplate()->getMaxSimultaneousLinkKey() ) ) { typeCountData->count++; diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp index 7fcb1079f8..64eed70f7c 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp @@ -174,7 +174,7 @@ Int ScoreKeeper::getTotalObjectsBuilt( const ThingTemplate *pTemplate ) for (ObjectCountMapIt it = m_objectsBuilt.begin(); it != m_objectsBuilt.end(); ++it) { const ThingTemplate *theTemplate = it->first; - if (theTemplate->isEquivalentTo(pTemplate)) + if (theTemplate && theTemplate->isEquivalentTo(pTemplate)) ++count; } return count; diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp index 823c0af886..4523159cd8 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp @@ -1271,9 +1271,8 @@ Bool BuildAssistant::isPossibleToMakeUnit( Object *builder, const ThingTemplate // get this button commandButton = commandSet->getCommandButton(i); if( commandButton && - (commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD || - commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) && - commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) ) + (commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD || commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) && + commandButton->getThingTemplate() && commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) ) foundCommand = commandButton; } // end for i diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp index fbf5f99fb8..4c4621b8f8 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -1474,7 +1474,7 @@ UnsignedInt ThingTemplate::getMaxSimultaneousOfType() const Bool ThingTemplate::isEquivalentTo(const ThingTemplate* tt) const { // sanity - if (!(this && tt)) + if (!tt) return false; // sanity diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index 9eccc23c26..20453afdef 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -239,7 +239,7 @@ void AISkirmishPlayer::processBaseBuilding( void ) } } } - if (powerPlan && powerInfo && !powerPlan->isEquivalentTo(bldgPlan)) { + if (powerInfo && powerPlan && !powerPlan->isEquivalentTo(bldgPlan)) { if (!powerUnderConstruction) { bldgPlan = powerPlan; bldgInfo = powerInfo; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp index 96aa3edcec..032dda3f96 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp @@ -170,7 +170,7 @@ Bool RiderChangeContain::isValidContainerFor(const Object* rider, Bool checkCapa for( int i = 0; i < MAX_RIDERS; i++ ) { const ThingTemplate *thing = TheThingFactory->findTemplate( data->m_riders[ i ].m_templateName ); - if( thing->isEquivalentTo( rider->getTemplate() ) ) + if( thing && thing->isEquivalentTo( rider->getTemplate() ) ) { //We found a valid rider, so return success. return TRUE; @@ -211,7 +211,7 @@ void RiderChangeContain::onContaining( Object *rider, Bool wasSelected ) for( int i = 0; i < MAX_RIDERS; i++ ) { const ThingTemplate *thing = TheThingFactory->findTemplate( data->m_riders[ i ].m_templateName ); - if( thing->isEquivalentTo( rider->getTemplate() ) ) + if( thing && thing->isEquivalentTo( rider->getTemplate() ) ) { //This is our rider, so set the correct model condition. @@ -282,7 +282,7 @@ void RiderChangeContain::onRemoving( Object *rider ) for( int i = 0; i < MAX_RIDERS; i++ ) { const ThingTemplate *thing = TheThingFactory->findTemplate( data->m_riders[ i ].m_templateName ); - if( thing->isEquivalentTo( rider->getTemplate() ) ) + if( thing && thing->isEquivalentTo( rider->getTemplate() ) ) { //This is our rider, so clear the current model condition. bike->clearModelConditionFlags( MAKE_MODELCONDITION_MASK2( data->m_riders[ i ].m_modelConditionFlagType, MODELCONDITION_DOOR_1_CLOSING ) ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp index 7c51aba5b2..9f9771faa8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp @@ -1766,7 +1766,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) if (beacon) { const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() ); - if (thing->isEquivalentTo(beacon->getTemplate())) + if (thing && thing->isEquivalentTo(beacon->getTemplate())) { if (beacon->getControllingPlayer() == thisPlayer) {