Skip to content

Commit 86eccd7

Browse files
committed
bugfix(ghostobject): Properly keep ghosted and shrouded objects hidden when taking a ghost snapshot or changing the local player (#1569)
1 parent 743f11d commit 86eccd7

File tree

10 files changed

+42
-6
lines changed

10 files changed

+42
-6
lines changed

Generals/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ enum TerrainDecalType CPP_11(: Int)
270270

271271
//-----------------------------------------------------------------------------
272272

273+
constexpr const UnsignedInt InvalidShroudClearFrame = ~0u;
274+
273275
const Int DRAWABLE_FRAMES_PER_FLASH = LOGICFRAMES_PER_SECOND / 2;
274276

275277
//-----------------------------------------------------------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Drawable::Drawable( const ThingTemplate *thingTemplate, DrawableStatusBits statu
362362
m_timeElapsedFade = 0;
363363
m_timeToFade = 0;
364364

365-
m_shroudClearFrame = 0;
365+
m_shroudClearFrame = InvalidShroudClearFrame;
366366

367367
for (i = 0; i < NUM_DRAWABLE_MODULE_TYPES; ++i)
368368
m_modules[i] = NULL;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ void GameClient::update( void )
669669
}
670670

671671
ObjectShroudStatus ss=object->getShroudedStatus(localPlayerIndex);
672-
if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame()!=0) {
672+
if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame() != InvalidShroudClearFrame) {
673673
UnsignedInt limit = 2*LOGICFRAMES_PER_SECOND;
674674
if (object->isEffectivelyDead()) {
675675
// extend the time, so we can see the dead plane blow up & crash.

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ void RTS3DScene::renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, I
595595
// so the player can see them and missiles chasing them. jba.
596596
if (ss == OBJECTSHROUD_CLEAR) {
597597
draw->setShroudClearFrame(TheGameLogic->getFrame());
598-
} else if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame()!=0) {
598+
} else if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame() != InvalidShroudClearFrame) {
599599
UnsignedInt limit = 2*LOGICFRAMES_PER_SECOND;
600600
if (obj->isEffectivelyDead()) {
601601
limit += 3*LOGICFRAMES_PER_SECOND;

Generals/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ void W3DGhostObject::snapShot(int playerIndex)
339339
if (draw->isDrawableEffectivelyHidden())
340340
return; //don't bother to snapshot things which nobody can see.
341341

342+
//After we remove the unfogged object, we also disable
343+
//anything that should be hidden inside fog - shadow, particles, etc.
344+
draw->setFullyObscuredByShroud(true);
345+
346+
// TheSuperHackers @bugfix Definitely keep this shrouded from here on until the shroud becomes clear again.
347+
draw->setShroudClearFrame(InvalidShroudClearFrame);
348+
342349
W3DRenderObjectSnapshot *snap = m_parentSnapshots[playerIndex];
343350
W3DRenderObjectSnapshot *prevSnap = NULL;
344351

@@ -417,6 +424,9 @@ void W3DGhostObject::removeParentObject(void)
417424
//anything that should be hidden inside fog - shadow, particles, etc.
418425
draw->setFullyObscuredByShroud(true);
419426

427+
// TheSuperHackers @bugfix Definitely keep this shrouded from here on until the shroud becomes clear again.
428+
draw->setShroudClearFrame(InvalidShroudClearFrame);
429+
420430
//walk through all W3D render objects used by this object
421431
for (DrawModule ** dm = draw->getDrawModules(); *dm; ++dm)
422432
{
@@ -985,6 +995,12 @@ void W3DGhostObjectManager::setLocalPlayerIndex(int playerIndex)
985995
const ObjectShroudStatus shroudStatus = obj->getShroudedStatus(playerIndex);
986996
const Bool shrouded = shroudStatus >= OBJECTSHROUD_FOGGED;
987997
draw->setFullyObscuredByShroud(shrouded);
998+
999+
if (shrouded)
1000+
{
1001+
// TheSuperHackers @bugfix Definitely keep this shrouded from here on until the shroud becomes clear again.
1002+
draw->setShroudClearFrame(InvalidShroudClearFrame);
1003+
}
9881004
}
9891005
}
9901006

GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ enum TerrainDecalType CPP_11(: Int)
278278

279279
//-----------------------------------------------------------------------------
280280

281+
constexpr const UnsignedInt InvalidShroudClearFrame = ~0u;
282+
281283
const Int DRAWABLE_FRAMES_PER_FLASH = LOGICFRAMES_PER_SECOND / 2;
282284

283285
//-----------------------------------------------------------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ Drawable::Drawable( const ThingTemplate *thingTemplate, DrawableStatusBits statu
399399
m_timeElapsedFade = 0;
400400
m_timeToFade = 0;
401401

402-
m_shroudClearFrame = 0;
402+
m_shroudClearFrame = InvalidShroudClearFrame;
403403

404404
for (i = 0; i < NUM_DRAWABLE_MODULE_TYPES; ++i)
405405
m_modules[i] = NULL;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ void GameClient::update( void )
707707
}
708708

709709
ObjectShroudStatus ss=object->getShroudedStatus(localPlayerIndex);
710-
if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame()!=0) {
710+
if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame() != InvalidShroudClearFrame) {
711711
UnsignedInt limit = 2*LOGICFRAMES_PER_SECOND;
712712
if (object->isEffectivelyDead()) {
713713
// extend the time, so we can see the dead plane blow up & crash.

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void RTS3DScene::renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, I
621621
// so the player can see them and missiles chasing them. jba.
622622
if (ss == OBJECTSHROUD_CLEAR) {
623623
draw->setShroudClearFrame(TheGameLogic->getFrame());
624-
} else if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame()!=0) {
624+
} else if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame() != InvalidShroudClearFrame) {
625625
UnsignedInt limit = 2*LOGICFRAMES_PER_SECOND;
626626
if (obj->isEffectivelyDead()) {
627627
limit += 3*LOGICFRAMES_PER_SECOND;

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ void W3DGhostObject::snapShot(int playerIndex)
343343
if (draw->isDrawableEffectivelyHidden())
344344
return; //don't bother to snapshot things which nobody can see.
345345

346+
//After we remove the unfogged object, we also disable
347+
//anything that should be hidden inside fog - shadow, particles, etc.
348+
draw->setFullyObscuredByShroud(true);
349+
350+
// TheSuperHackers @bugfix Definitely keep this shrouded from here on until the shroud becomes clear again.
351+
draw->setShroudClearFrame(InvalidShroudClearFrame);
352+
346353
W3DRenderObjectSnapshot *snap = m_parentSnapshots[playerIndex];
347354
W3DRenderObjectSnapshot *prevSnap = NULL;
348355

@@ -421,6 +428,9 @@ void W3DGhostObject::removeParentObject(void)
421428
//anything that should be hidden inside fog - shadow, particles, etc.
422429
draw->setFullyObscuredByShroud(true);
423430

431+
// TheSuperHackers @bugfix Definitely keep this shrouded from here on until the shroud becomes clear again.
432+
draw->setShroudClearFrame(InvalidShroudClearFrame);
433+
424434
//walk through all W3D render objects used by this object
425435
for (DrawModule ** dm = draw->getDrawModules(); *dm; ++dm)
426436
{
@@ -989,6 +999,12 @@ void W3DGhostObjectManager::setLocalPlayerIndex(int playerIndex)
989999
const ObjectShroudStatus shroudStatus = obj->getShroudedStatus(playerIndex);
9901000
const Bool shrouded = shroudStatus >= OBJECTSHROUD_FOGGED;
9911001
draw->setFullyObscuredByShroud(shrouded);
1002+
1003+
if (shrouded)
1004+
{
1005+
// TheSuperHackers @bugfix Definitely keep this shrouded from here on until the shroud becomes clear again.
1006+
draw->setShroudClearFrame(InvalidShroudClearFrame);
1007+
}
9921008
}
9931009
}
9941010

0 commit comments

Comments
 (0)