Skip to content

Commit 0193ad2

Browse files
authored
bugfix(buildassistant): Fix Network game mismatch by using the correct player index to check shroud status when placing structures (#1646)
1 parent 2bbf902 commit 0193ad2

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,6 @@ Bool BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
670670
MemoryPoolObjectHolder hold(iter);
671671
for( them = iter->first(); them; them = iter->next() )
672672
{
673-
if (them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud())
674-
return false;
675-
676673
// ignore any kind of class of objects that we will "remove" for building
677674
if( isRemovableForConstruction( them ) == TRUE )
678675
continue;
@@ -686,11 +683,17 @@ Bool BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
686683
if (them->isKindOf(KINDOF_INERT))
687684
continue;
688685

689-
// an immobile object may obstruct our building depending on flags.
690-
if( them->isKindOf( KINDOF_IMMOBILE ) ) {
691-
if (onlyCheckEnemies && builderObject && builderObject->getRelationship( them ) != ENEMIES ) {
686+
if (them->isKindOf(KINDOF_IMMOBILE)) {
687+
if (onlyCheckEnemies && builderObject && builderObject->getRelationship(them) != ENEMIES) {
692688
continue;
693689
}
690+
}
691+
692+
if (builderObject && them->getShroudedStatus(builderObject->getControllingPlayer()->getPlayerIndex()) >= OBJECTSHROUD_FOGGED)
693+
return false;
694+
695+
// an immobile object may obstruct our building depending on flags.
696+
if( them->isKindOf( KINDOF_IMMOBILE ) ) {
694697
TheTerrainVisual->addFactionBib(them, true);
695698
return false;
696699
}
@@ -801,7 +804,7 @@ Bool BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos,
801804

802805
// an immobile object will obstruct our building no matter what team it's on
803806
if ( them->isKindOf( KINDOF_IMMOBILE ) ) {
804-
Bool shrouded = them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud();
807+
Bool shrouded = builderObject && them->getShroudedStatus(builderObject->getControllingPlayer()->getPlayerIndex()) >= OBJECTSHROUD_FOGGED;
805808
/* Check for overlap of my exit rectangle to his geom info. */
806809
if (checkMyExit && ThePartitionManager->geomCollidesWithGeom(them->getPosition(), hisBounds, them->getOrientation(),
807810
&myExitPos, myGeom, angle)) {

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,6 @@ LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos
670670
MemoryPoolObjectHolder hold(iter);
671671
for( them = iter->first(); them; them = iter->next() )
672672
{
673-
if (them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud())
674-
return LBC_SHROUD;
675-
676673
Bool feedbackWithFailure = TRUE;
677674
Relationship rel = builderObject ? builderObject->getRelationship( them ) : NEUTRAL;
678675

@@ -695,16 +692,6 @@ LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos
695692
}
696693
}
697694

698-
//Kris: Patch 1.01 - November 5, 2003
699-
//Prevent busy units (black lotus hacking from being moved by trying to place a building -- exploit).
700-
if( rel == ALLIES )
701-
{
702-
if( them->testStatus( OBJECT_STATUS_IS_USING_ABILITY ) || them->getAI() && them->getAI()->isBusy() )
703-
{
704-
return LBC_OBJECTS_IN_THE_WAY;
705-
}
706-
}
707-
708695
// ignore any kind of class of objects that we will "remove" for building
709696
if( isRemovableForConstruction( them ) == TRUE )
710697
continue;
@@ -718,13 +705,28 @@ LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos
718705
if (them->isKindOf(KINDOF_INERT))
719706
continue;
720707

721-
// an immobile object may obstruct our building depending on flags.
722-
if( them->isKindOf( KINDOF_IMMOBILE ) )
708+
if (them->isKindOf(KINDOF_IMMOBILE))
723709
{
724-
if (onlyCheckEnemies && builderObject && rel != ENEMIES )
725-
{
710+
if (onlyCheckEnemies && builderObject && rel != ENEMIES)
726711
continue;
712+
}
713+
714+
if (builderObject && them->getShroudedStatus(builderObject->getControllingPlayer()->getPlayerIndex()) >= OBJECTSHROUD_FOGGED)
715+
return LBC_SHROUD;
716+
717+
//Kris: Patch 1.01 - November 5, 2003
718+
//Prevent busy units (black lotus hacking from being moved by trying to place a building -- exploit).
719+
if (rel == ALLIES)
720+
{
721+
if (them->testStatus(OBJECT_STATUS_IS_USING_ABILITY) || them->getAI() && them->getAI()->isBusy())
722+
{
723+
return LBC_OBJECTS_IN_THE_WAY;
727724
}
725+
}
726+
727+
// an immobile object may obstruct our building depending on flags.
728+
if( them->isKindOf( KINDOF_IMMOBILE ) )
729+
{
728730
if( feedbackWithFailure )
729731
{
730732
TheTerrainVisual->addFactionBib( them, TRUE );
@@ -869,7 +871,7 @@ LegalBuildCode BuildAssistant::isLocationClearOfObjects( const Coord3D *worldPos
869871

870872
// an immobile object will obstruct our building no matter what team it's on
871873
if ( them->isKindOf( KINDOF_IMMOBILE ) ) {
872-
Bool shrouded = them->getDrawable() && them->getDrawable()->getFullyObscuredByShroud();
874+
Bool shrouded = builderObject && them->getShroudedStatus(builderObject->getControllingPlayer()->getPlayerIndex()) >= OBJECTSHROUD_FOGGED;
873875
/* Check for overlap of my exit rectangle to his geom info. */
874876
if (checkMyExit && ThePartitionManager->geomCollidesWithGeom(them->getPosition(), hisBounds, them->getOrientation(),
875877
&myExitPos, myGeom, angle)) {

0 commit comments

Comments
 (0)