Skip to content

Commit 143673a

Browse files
authored
[GEN][ZH] Prevent crash upon beacon removal in GameLogic::logicMessageDispatcher() (#1065)
1 parent fbd4468 commit 143673a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,12 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
17371737
Object *beacon = findObjectByID(*it);
17381738
if (beacon)
17391739
{
1740-
const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() );
1740+
// TheSuperHackers @bugfix Prevent runtime crashing when a beacon is no longer associated with an initialized player.
1741+
const PlayerTemplate *playerTemplate = beacon->getControllingPlayer()->getPlayerTemplate();
1742+
if (!playerTemplate)
1743+
continue;
1744+
1745+
const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() );
17411746
if (thing && thing->isEquivalentTo(beacon->getTemplate()))
17421747
{
17431748
if (beacon->getControllingPlayer() == thisPlayer)

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,12 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
17651765
Object *beacon = findObjectByID(*it);
17661766
if (beacon)
17671767
{
1768-
const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() );
1768+
// TheSuperHackers @bugfix Prevent runtime crashing when a beacon is no longer associated with an initialized player.
1769+
const PlayerTemplate *playerTemplate = beacon->getControllingPlayer()->getPlayerTemplate();
1770+
if (!playerTemplate)
1771+
continue;
1772+
1773+
const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() );
17691774
if (thing && thing->isEquivalentTo(beacon->getTemplate()))
17701775
{
17711776
if (beacon->getControllingPlayer() == thisPlayer)

0 commit comments

Comments
 (0)