Skip to content

Commit 8c958f6

Browse files
committed
Replicated in Generals.
1 parent e645451 commit 8c958f6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,8 +1735,15 @@ void AIPlayer::buildUpgrade(const AsciiString &upgrade)
17351735
// ------------------------------------------------------------------------------------------------
17361736
void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName)
17371737
{
1738-
Object *bestSupplyWarehouse = findSupplyCenter(minimumCash);
17391738
const ThingTemplate* tTemplate = TheThingFactory->findTemplate(thingName);
1739+
if (!tTemplate)
1740+
{
1741+
DEBUG_CRASH(("Template %s should exist; check ini and script files.", thingName.str()));
1742+
return;
1743+
}
1744+
1745+
Object *bestSupplyWarehouse = findSupplyCenter(minimumCash);
1746+
17401747
if (!tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) {
17411748
// Build by the current warehouse.
17421749
Object *curWarehouse = TheGameLogic->findObjectByID(m_curWarehouseID);
@@ -1746,7 +1753,7 @@ void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName)
17461753
}
17471754

17481755

1749-
if (bestSupplyWarehouse && tTemplate) {
1756+
if (bestSupplyWarehouse) {
17501757
Coord3D location;
17511758
location = *bestSupplyWarehouse->getPosition();
17521759
// offset back towards the base.

0 commit comments

Comments
 (0)