Skip to content

Commit e87031f

Browse files
authored
bugfix(buildassistant): Prevent showing the invalid placement indicator for shrouded objects (#1543)
1 parent 48054ec commit e87031f

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,9 @@ void BuildAssistant::iterateFootprint( const ThingTemplate *build,
650650

651651

652652
//-------------------------------------------------------------------------------------------------
653-
/** Check for objects preventing building at this location. */
653+
/** Check for objects preventing building at this location.
654+
* TheSuperHackers @tweak Stubbjax 05/09/2025 Return LBC_SHROUD for shrouded objects near the
655+
* edge of the shroud so that players cannot use this info to determine whether they exist. */
654656
//-------------------------------------------------------------------------------------------------
655657
Bool BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
656658
const ThingTemplate *build,
@@ -668,6 +670,8 @@ Bool BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
668670
MemoryPoolObjectHolder hold(iter);
669671
for( them = iter->first(); them; them = iter->next() )
670672
{
673+
if (them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud())
674+
return false;
671675

672676
// ignore any kind of class of objects that we will "remove" for building
673677
if( isRemovableForConstruction( them ) == TRUE )
@@ -797,22 +801,26 @@ Bool BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
797801

798802
// an immobile object will obstruct our building no matter what team it's on
799803
if ( them->isKindOf( KINDOF_IMMOBILE ) ) {
804+
Bool shrouded = them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud();
800805
/* Check for overlap of my exit rectangle to his geom info. */
801806
if (checkMyExit && ThePartitionManager->geomCollidesWithGeom(them->getPosition(), hisBounds, them->getOrientation(),
802807
&myExitPos, myGeom, angle)) {
803-
TheTerrainVisual->addFactionBib(them, true);
808+
if (!shrouded)
809+
TheTerrainVisual->addFactionBib(them, true);
804810
return false;
805811
}
806812
// Check for overlap of his exit rectangle with my geom info
807813
if (checkHisExit && ThePartitionManager->geomCollidesWithGeom(&hisExitPos, hisGeom, them->getOrientation(),
808814
worldPos, myBounds, angle)) {
809-
TheTerrainVisual->addFactionBib(them, true);
815+
if (!shrouded)
816+
TheTerrainVisual->addFactionBib(them, true);
810817
return false;
811818
}
812819
// Check both exit rectangles together.
813820
if (checkMyExit&&checkHisExit&&ThePartitionManager->geomCollidesWithGeom(&hisExitPos, hisGeom, them->getOrientation(),
814821
&myExitPos, myGeom, angle)) {
815-
TheTerrainVisual->addFactionBib(them, true);
822+
if (!shrouded)
823+
TheTerrainVisual->addFactionBib(them, true);
816824
return false;
817825
}
818826
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,9 @@ void BuildAssistant::iterateFootprint( const ThingTemplate *build,
650650

651651

652652
//-------------------------------------------------------------------------------------------------
653-
/** Check for objects preventing building at this location. */
653+
/** Check for objects preventing building at this location.
654+
* TheSuperHackers @tweak Stubbjax 05/09/2025 Return LBC_SHROUD for shrouded objects near the
655+
* edge of the shroud so that players cannot use this info to determine whether they exist. */
654656
//-------------------------------------------------------------------------------------------------
655657
LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
656658
const ThingTemplate *build,
@@ -668,8 +670,10 @@ LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos
668670
MemoryPoolObjectHolder hold(iter);
669671
for( them = iter->first(); them; them = iter->next() )
670672
{
671-
Bool feedbackWithFailure = TRUE;
673+
if (them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud())
674+
return LBC_SHROUD;
672675

676+
Bool feedbackWithFailure = TRUE;
673677
Relationship rel = builderObject ? builderObject->getRelationship( them ) : NEUTRAL;
674678

675679
//Kris: If the object is stealthed and we can't see it, pretend we can build there.
@@ -865,21 +869,31 @@ LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos
865869

866870
// an immobile object will obstruct our building no matter what team it's on
867871
if ( them->isKindOf( KINDOF_IMMOBILE ) ) {
872+
Bool shrouded = them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud();
868873
/* Check for overlap of my exit rectangle to his geom info. */
869874
if (checkMyExit && ThePartitionManager->geomCollidesWithGeom(them->getPosition(), hisBounds, them->getOrientation(),
870875
&myExitPos, myGeom, angle)) {
876+
if (shrouded)
877+
return LBC_SHROUD;
878+
871879
TheTerrainVisual->addFactionBib(them, true);
872880
return LBC_OBJECTS_IN_THE_WAY;
873881
}
874882
// Check for overlap of his exit rectangle with my geom info
875883
if (checkHisExit && ThePartitionManager->geomCollidesWithGeom(&hisExitPos, hisGeom, them->getOrientation(),
876884
worldPos, myBounds, angle)) {
885+
if (shrouded)
886+
return LBC_SHROUD;
887+
877888
TheTerrainVisual->addFactionBib(them, true);
878889
return LBC_OBJECTS_IN_THE_WAY;
879890
}
880891
// Check both exit rectangles together.
881892
if (checkMyExit&&checkHisExit&&ThePartitionManager->geomCollidesWithGeom(&hisExitPos, hisGeom, them->getOrientation(),
882893
&myExitPos, myGeom, angle)) {
894+
if (shrouded)
895+
return LBC_SHROUD;
896+
883897
TheTerrainVisual->addFactionBib(them, true);
884898
return LBC_OBJECTS_IN_THE_WAY;
885899
}

0 commit comments

Comments
 (0)