Skip to content

Commit 2e3ede1

Browse files
committed
Shared Gen/ZH changes.
1 parent 64e1686 commit 2e3ede1

File tree

8 files changed

+10
-12
lines changed

8 files changed

+10
-12
lines changed

Generals/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Int ScoreKeeper::getTotalObjectsBuilt( const ThingTemplate *pTemplate )
174174
for (ObjectCountMapIt it = m_objectsBuilt.begin(); it != m_objectsBuilt.end(); ++it)
175175
{
176176
const ThingTemplate *theTemplate = it->first;
177-
if (theTemplate->isEquivalentTo(pTemplate))
177+
if (theTemplate && theTemplate->isEquivalentTo(pTemplate))
178178
++count;
179179
}
180180
return count;

Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,9 +1218,8 @@ Bool BuildAssistant::isPossibleToMakeUnit( Object *builder, const ThingTemplate
12181218
// get this button
12191219
commandButton = commandSet->getCommandButton(i);
12201220
if( commandButton &&
1221-
(commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD ||
1222-
commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) &&
1223-
commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) )
1221+
(commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD || commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) &&
1222+
commandButton->getThingTemplate() && commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) )
12241223
foundCommand = commandButton;
12251224

12261225
} // end for i

Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ const AudioEventRTS *ThingTemplate::getPerUnitSound(const AsciiString& soundName
13191319
Bool ThingTemplate::isEquivalentTo(const ThingTemplate* tt) const
13201320
{
13211321
// sanity
1322-
if (!(this && tt))
1322+
if (!tt)
13231323
return false;
13241324

13251325
// sanity

Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
17381738
if (beacon)
17391739
{
17401740
const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() );
1741-
if (thing->isEquivalentTo(beacon->getTemplate()))
1741+
if (thing && thing->isEquivalentTo(beacon->getTemplate()))
17421742
{
17431743
if (beacon->getControllingPlayer() == thisPlayer)
17441744
{

GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Int ScoreKeeper::getTotalObjectsBuilt( const ThingTemplate *pTemplate )
174174
for (ObjectCountMapIt it = m_objectsBuilt.begin(); it != m_objectsBuilt.end(); ++it)
175175
{
176176
const ThingTemplate *theTemplate = it->first;
177-
if (theTemplate->isEquivalentTo(pTemplate))
177+
if (theTemplate && theTemplate->isEquivalentTo(pTemplate))
178178
++count;
179179
}
180180
return count;

GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,8 @@ Bool BuildAssistant::isPossibleToMakeUnit( Object *builder, const ThingTemplate
12711271
// get this button
12721272
commandButton = commandSet->getCommandButton(i);
12731273
if( commandButton &&
1274-
(commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD ||
1275-
commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) &&
1276-
commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) )
1274+
(commandButton->getCommandType() == GUI_COMMAND_UNIT_BUILD || commandButton->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT) &&
1275+
commandButton->getThingTemplate() && commandButton->getThingTemplate()->isEquivalentTo(whatToBuild) )
12771276
foundCommand = commandButton;
12781277

12791278
} // end for i

GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ UnsignedInt ThingTemplate::getMaxSimultaneousOfType() const
14741474
Bool ThingTemplate::isEquivalentTo(const ThingTemplate* tt) const
14751475
{
14761476
// sanity
1477-
if (!(this && tt))
1477+
if (!tt)
14781478
return false;
14791479

14801480
// sanity

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
17661766
if (beacon)
17671767
{
17681768
const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() );
1769-
if (thing->isEquivalentTo(beacon->getTemplate()))
1769+
if (thing && thing->isEquivalentTo(beacon->getTemplate()))
17701770
{
17711771
if (beacon->getControllingPlayer() == thisPlayer)
17721772
{

0 commit comments

Comments
 (0)