Skip to content

Commit a8826c6

Browse files
authored
bugfix(script): Fix crash if nearest command button target is not found (#1420)
1 parent 38cd586 commit a8826c6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5534,13 +5534,23 @@ void Object::doCommandButtonAtObject( const CommandButton *commandButton, Object
55345534
switch( commandButton->getCommandType() )
55355535
{
55365536
case GUI_COMMAND_COMBATDROP:
5537+
#if RETAIL_COMPATIBLE_CRC
5538+
if (!obj)
5539+
return;
5540+
#endif
5541+
55375542
if( ai )
55385543
{
55395544
ai->aiCombatDrop( obj, *(obj->getPosition()), cmdSource );
55405545
}
55415546
return;
55425547
case GUI_COMMAND_SPECIAL_POWER:
55435548
{
5549+
#if RETAIL_COMPATIBLE_CRC
5550+
if (!obj)
5551+
return;
5552+
#endif
5553+
55445554
if( commandButton->getSpecialPowerTemplate() )
55455555
{
55465556
CommandOption commandOptions = (CommandOption)(commandButton->getOptions() | COMMAND_FIRED_BY_SCRIPT);

GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5888,10 +5888,10 @@ void ScriptActions::doTeamUseCommandButtonOnNearestObjectType( const AsciiString
58885888
theGroup->getCenter(&pos);
58895889

58905890
bestObj = ThePartitionManager->getClosestObject(&pos, REALLY_FAR, FROM_CENTER_2D, filters);
5891-
if( !bestObj )
5892-
{
5891+
#if RETAIL_COMPATIBLE_CRC
5892+
if (!bestObj)
58935893
return;
5894-
}
5894+
#endif
58955895
}
58965896
else
58975897
{
@@ -5930,6 +5930,11 @@ void ScriptActions::doTeamUseCommandButtonOnNearestObjectType( const AsciiString
59305930
}
59315931
}
59325932

5933+
#if !RETAIL_COMPATIBLE_CRC
5934+
if (!bestObj)
5935+
return;
5936+
#endif
5937+
59335938
// already been checked for validity
59345939
theGroup->groupDoCommandButtonAtObject(commandButton, bestObj, CMD_FROM_SCRIPT);
59355940
}

0 commit comments

Comments
 (0)