Skip to content

Commit 4de89c3

Browse files
authored
bugfix(input): Prevent drag-selecting enemy beacons and enable selecting stealthed units while observing (TheSuperHackers#1460)
1 parent 9debcee commit 4de89c3

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

Generals/Code/GameEngine/Source/GameClient/SelectionInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ Bool addDrawableToList( Drawable *draw, void *userData )
347347
if (!pds->drawableListToFill)
348348
return FALSE;
349349

350+
#if !RTS_GENERALS || !RETAIL_COMPATIBLE_BUG
351+
// TheSuperHackers @info
352+
// In retail, drag-selecting allows the player to select stealthed objects and objects through the
353+
// fog. Some players exploit this bug to determine where an opponent's units are and consider this
354+
// an important feature and an advanced skill to pull off, so we must leave the exploit.
355+
if (draw->getFullyObscuredByShroud())
356+
return FALSE;
357+
358+
if (draw->isDrawableEffectivelyHidden())
359+
return FALSE;
360+
#endif
361+
350362
if (!draw->getTemplate()->isAnyKindOf(pds->kindofsToMatch))
351363
return FALSE;
352364

GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ Bool addDrawableToList( Drawable *draw, void *userData )
349349
if (!pds->drawableListToFill)
350350
return FALSE;
351351

352+
#if !RTS_GENERALS || !RETAIL_COMPATIBLE_BUG
353+
if (draw->getFullyObscuredByShroud())
354+
return FALSE;
355+
356+
if (draw->isDrawableEffectivelyHidden())
357+
return FALSE;
358+
#endif
359+
352360
if (!draw->getTemplate()->isAnyKindOf(pds->kindofsToMatch))
353361
return FALSE;
354362

@@ -368,28 +376,15 @@ Bool addDrawableToList( Drawable *draw, void *userData )
368376
return FALSE;
369377
}
370378

371-
//Kris: Aug 9, 2003!!! Wow, this bug has been around a LONG time!!
372-
//Basically, it was possible to drag select a single enemy/neutral unit even if you couldn't see it
373-
//including stealthed units.
374-
const Object *obj = draw->getObject();
375-
if( obj )
376-
{
377-
const Player *player = ThePlayerList->getLocalPlayer();
378-
Relationship rel = player->getRelationship( obj->getTeam() );
379-
if( rel == NEUTRAL || rel == ENEMIES )
380-
{
381-
if( obj->getShroudedStatus( player->getPlayerIndex() ) >= OBJECTSHROUD_FOGGED )
382-
{
383-
return FALSE;
384-
}
385-
386-
//If stealthed, no way!
387-
if( obj->testStatus( OBJECT_STATUS_STEALTHED ) && !obj->testStatus( OBJECT_STATUS_DETECTED ) )
388-
{
389-
return FALSE;
390-
}
391-
}
392-
}
379+
#if !RTS_GENERALS && RETAIL_COMPATIBLE_BUG
380+
// TheSuperHackers @info
381+
// In retail, hidden objects such as passengers are included here when drag-selected, which causes
382+
// enemy selection logic to exit early (only 1 enemy unit can be selected at a time). Some players
383+
// exploit this bug to determine if a transport contains passengers and consider this an important
384+
// feature and an advanced skill to pull off, so we must leave the exploit.
385+
if (draw->getObject() && draw->getObject()->getContain() && draw->getObject()->getContain()->getContainCount() > 0)
386+
pds->drawableListToFill->push_back(draw); // Just add the unit twice to prevent enemy selections
387+
#endif
393388

394389
pds->drawableListToFill->push_back(draw);
395390
return TRUE;

0 commit comments

Comments
 (0)