diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 9bd88bcb319..1bf37586b92 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -1737,7 +1737,7 @@ void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName) { Object *bestSupplyWarehouse = findSupplyCenter(minimumCash); const ThingTemplate* tTemplate = TheThingFactory->findTemplate(thingName); - if (!tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { + if (tTemplate && !tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { // Build by the current warehouse. Object *curWarehouse = TheGameLogic->findObjectByID(m_curWarehouseID); if (curWarehouse) { diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 14c6cfe36f2..4c25ce73add 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -1857,7 +1857,7 @@ void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName) { Object *bestSupplyWarehouse = findSupplyCenter(minimumCash); const ThingTemplate* tTemplate = TheThingFactory->findTemplate(thingName); - if (!tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { + if (tTemplate && !tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { // Build by the current warehouse. Object *curWarehouse = TheGameLogic->findObjectByID(m_curWarehouseID); if (curWarehouse) {