diff --git a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp index cf835cb373..a3c03e2f6b 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp @@ -1682,34 +1682,48 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) for (VecObjectID::const_iterator it = selectedObjects.begin(); it != selectedObjects.end(); ++it) { Object *beacon = findObjectByID(*it); - if (beacon) + if (!beacon) + { + continue; + } + + Player *controllingPlayer = beacon->getControllingPlayer(); + if (!controllingPlayer) + { + continue; + } + + const PlayerTemplate *playerTemplate = controllingPlayer->getPlayerTemplate(); + if (!playerTemplate) + { + continue; + } + + const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() ); + if (thing->isEquivalentTo(beacon->getTemplate())) { - const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() ); - if (thing->isEquivalentTo(beacon->getTemplate())) + if (controllingPlayer == thisPlayer) { - if (beacon->getControllingPlayer() == thisPlayer) - { - TheGameLogic->destroyObject(beacon); // the owner is telling it to go away. such is life. + TheGameLogic->destroyObject(beacon); // the owner is telling it to go away. such is life. - TheControlBar->markUIDirty(); // check if we should un-grey out the button - } - else if (thisPlayer == ThePlayerList->getLocalPlayer()) + TheControlBar->markUIDirty(); // check if we should un-grey out the button + } + else if (thisPlayer == ThePlayerList->getLocalPlayer()) + { + Drawable *beaconDrawable = beacon->getDrawable(); + if (beaconDrawable) { - Drawable *beaconDrawable = beacon->getDrawable(); - if (beaconDrawable) - { - static NameKeyType nameKeyClientUpdate = NAMEKEY("BeaconClientUpdate"); - ClientUpdateModule ** clientModules = beaconDrawable->getClientUpdateModules(); - if (clientModules) + static NameKeyType nameKeyClientUpdate = NAMEKEY("BeaconClientUpdate"); + ClientUpdateModule ** clientModules = beaconDrawable->getClientUpdateModules(); + if (clientModules) + { + while (*clientModules) { - while (*clientModules) - { - if ((*clientModules)->getModuleNameKey() == nameKeyClientUpdate) - (*(BeaconClientUpdate **)clientModules)->hideBeacon(); + if ((*clientModules)->getModuleNameKey() == nameKeyClientUpdate) + (*(BeaconClientUpdate **)clientModules)->hideBeacon(); - ++clientModules; - } + ++clientModules; } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp index 7003423f03..1b73b064d2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp @@ -1710,34 +1710,48 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData ) for (VecObjectID::const_iterator it = selectedObjects.begin(); it != selectedObjects.end(); ++it) { Object *beacon = findObjectByID(*it); - if (beacon) + if (!beacon) + { + continue; + } + + Player *controllingPlayer = beacon->getControllingPlayer(); + if (!controllingPlayer) + { + continue; + } + + const PlayerTemplate *playerTemplate = controllingPlayer->getPlayerTemplate(); + if (!playerTemplate) + { + continue; + } + + const ThingTemplate *thing = TheThingFactory->findTemplate( playerTemplate->getBeaconTemplate() ); + if (thing->isEquivalentTo(beacon->getTemplate())) { - const ThingTemplate *thing = TheThingFactory->findTemplate( beacon->getControllingPlayer()->getPlayerTemplate()->getBeaconTemplate() ); - if (thing->isEquivalentTo(beacon->getTemplate())) + if (controllingPlayer == thisPlayer) { - if (beacon->getControllingPlayer() == thisPlayer) - { - TheGameLogic->destroyObject(beacon); // the owner is telling it to go away. such is life. + TheGameLogic->destroyObject(beacon); // the owner is telling it to go away. such is life. - TheControlBar->markUIDirty(); // check if we should un-grey out the button - } - else if (thisPlayer == ThePlayerList->getLocalPlayer()) + TheControlBar->markUIDirty(); // check if we should un-grey out the button + } + else if (thisPlayer == ThePlayerList->getLocalPlayer()) + { + Drawable *beaconDrawable = beacon->getDrawable(); + if (beaconDrawable) { - Drawable *beaconDrawable = beacon->getDrawable(); - if (beaconDrawable) - { - static NameKeyType nameKeyClientUpdate = NAMEKEY("BeaconClientUpdate"); - ClientUpdateModule ** clientModules = beaconDrawable->getClientUpdateModules(); - if (clientModules) + static NameKeyType nameKeyClientUpdate = NAMEKEY("BeaconClientUpdate"); + ClientUpdateModule ** clientModules = beaconDrawable->getClientUpdateModules(); + if (clientModules) + { + while (*clientModules) { - while (*clientModules) - { - if ((*clientModules)->getModuleNameKey() == nameKeyClientUpdate) - (*(BeaconClientUpdate **)clientModules)->hideBeacon(); + if ((*clientModules)->getModuleNameKey() == nameKeyClientUpdate) + (*(BeaconClientUpdate **)clientModules)->hideBeacon(); - ++clientModules; - } + ++clientModules; } } }