From 17006768e60c5e9e1552eb187f2f58519ffd1584 Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Sun, 29 Jun 2025 10:56:32 +0100 Subject: [PATCH] [GEN][ZH] fix object deselection logic in BuildAssistant::sellObject() --- .../Source/Common/System/BuildAssistant.cpp | 16 ++++++++++++++-- .../Source/Common/System/BuildAssistant.cpp | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp b/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp index 77f8dcfb571..a833bce0ede 100644 --- a/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/BuildAssistant.cpp @@ -1506,18 +1506,30 @@ void BuildAssistant::sellObject( Object *obj ) // set the model condition in the drawable for this object that will show the buildup // scaffold and adjust the model height by construction percent // - obj->setModelConditionFlags( MAKE_MODELCONDITION_MASK2( MODELCONDITION_PARTIALLY_CONSTRUCTED, - MODELCONDITION_ACTIVELY_BEING_CONSTRUCTED) ); + obj->setModelConditionFlags( MAKE_MODELCONDITION_MASK2( MODELCONDITION_PARTIALLY_CONSTRUCTED, MODELCONDITION_ACTIVELY_BEING_CONSTRUCTED) ); +#if RETAIL_COMPATIBLE_AIGROUP // // set this object as under de-construction (sold). It is still a legal target, since you get the money at // the completion of sale. // obj->setStatus( MAKE_OBJECT_STATUS_MASK2( OBJECT_STATUS_SOLD, OBJECT_STATUS_UNSELECTABLE ) ); +#endif + + // TheSuperHackers @bugfix Mauller 27/06/2025 we need to deselect the object before setting it as unselectable + // If the object is set unselectable too soon, it fails to be removed from the selection group // for everybody, unselect them at this time. You can't just deselect a drawable. Selection is a logic property. TheGameLogic->deselectObject(obj, PLAYERMASK_ALL, TRUE); +#if !RETAIL_COMPATIBLE_AIGROUP + // + // set this object as under de-construction (sold). It is still a legal target, since you get the money at + // the completion of sale. + // + obj->setStatus( MAKE_OBJECT_STATUS_MASK2( OBJECT_STATUS_SOLD, OBJECT_STATUS_UNSELECTABLE ) ); +#endif + // // set the animation durations so that the regular build up loop animations can be // done a bit faster for selling diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp index 59360d66ae0..823c0af8860 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp @@ -1531,18 +1531,30 @@ void BuildAssistant::sellObject( Object *obj ) // set the model condition in the drawable for this object that will show the buildup // scaffold and adjust the model height by construction percent // - obj->setModelConditionFlags( MAKE_MODELCONDITION_MASK2( MODELCONDITION_PARTIALLY_CONSTRUCTED, - MODELCONDITION_ACTIVELY_BEING_CONSTRUCTED) ); + obj->setModelConditionFlags( MAKE_MODELCONDITION_MASK2( MODELCONDITION_PARTIALLY_CONSTRUCTED, MODELCONDITION_ACTIVELY_BEING_CONSTRUCTED) ); +#if RETAIL_COMPATIBLE_AIGROUP // // set this object as under de-construction (sold). It is still a legal target, since you get the money at // the completion of sale. // obj->setStatus( MAKE_OBJECT_STATUS_MASK2( OBJECT_STATUS_SOLD, OBJECT_STATUS_UNSELECTABLE ) ); +#endif + + // TheSuperHackers @bugfix Mauller 27/06/2025 we need to deselect the object before setting it as unselectable + // If the object is set unselectable too soon, it fails to be removed from the selection group // for everybody, unselect them at this time. You can't just deselect a drawable. Selection is a logic property. TheGameLogic->deselectObject(obj, PLAYERMASK_ALL, TRUE); +#if !RETAIL_COMPATIBLE_AIGROUP + // + // set this object as under de-construction (sold). It is still a legal target, since you get the money at + // the completion of sale. + // + obj->setStatus( MAKE_OBJECT_STATUS_MASK2( OBJECT_STATUS_SOLD, OBJECT_STATUS_UNSELECTABLE ) ); +#endif + // // set the animation durations so that the regular build up loop animations can be // done a bit faster for selling