Skip to content

Commit e86c62c

Browse files
committed
bugfix(radar): Refresh radar objects without delay when changing player
1 parent 0c919e9 commit e86c62c

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

Core/GameEngine/Source/Common/GameUtility.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static void changePlayerCommon(Player* player)
4343
ThePartitionManager->refreshShroudForLocalPlayer();
4444
TheGhostObjectManager->setLocalPlayerIndex(player->getPlayerIndex());
4545
TheGameClient->updateFakeDrawables();
46+
TheRadar->refreshObjects();
4647
TheInGameUI->deselectAllDrawables();
4748
}
4849

GeneralsMD/Code/GameEngine/Include/Common/Radar.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ class Radar : public Snapshot,
215215
/// refresh the water values for the radar
216216
virtual void refreshTerrain( TerrainLogic *terrain );
217217

218+
/// refresh the radar when the state of world objects changes drastically
219+
virtual void refreshObjects() {};
220+
218221
/// queue a refresh of the terran at the next available time
219222
virtual void queueTerrainRefresh( void );
220223

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ enum TerrainDecalType CPP_11(: Int)
278278

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

281-
CONSTEXPR const UnsignedInt InvalidShroudClearFrame = ~0u;
281+
constexpr const UnsignedInt InvalidShroudClearFrame = ~0u;
282282

283283
const Int DRAWABLE_FRAMES_PER_FLASH = LOGICFRAMES_PER_SECOND / 2;
284284

GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class W3DRadar : public Radar
7272
virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting);
7373

7474
virtual void refreshTerrain( TerrainLogic *terrain );
75+
virtual void refreshObjects();
7576

7677
protected:
7778

@@ -85,6 +86,7 @@ class W3DRadar : public Radar
8586
void drawViewBox( Int pixelX, Int pixelY, Int width, Int height ); ///< draw view box
8687
void buildTerrainTexture( TerrainLogic *terrain ); ///< create the terrain texture of the radar
8788
void drawIcons( Int pixelX, Int pixelY, Int width, Int height ); ///< draw all of the radar icons
89+
void updateObjectTexture(TextureClass *texture);
8890
void renderObjectList( const RadarObject *listHead, TextureClass *texture, Bool calcHero = FALSE ); ///< render an object list to the texture
8991
void interpolateColorForHeight( RGBColor *color,
9092
Real height,

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,20 @@ void W3DRadar::drawIcons( Int pixelX, Int pixelY, Int width, Int height )
611611
}
612612
}
613613

614+
//-------------------------------------------------------------------------------------------------
615+
//-------------------------------------------------------------------------------------------------
616+
void W3DRadar::updateObjectTexture(TextureClass *texture)
617+
{
618+
// reset the overlay texture
619+
SurfaceClass *surface = texture->Get_Surface_Level();
620+
surface->Clear();
621+
REF_PTR_RELEASE(surface);
622+
623+
// rebuild the object overlay
624+
renderObjectList( getObjectList(), texture );
625+
renderObjectList( getLocalObjectList(), texture, TRUE );
626+
}
627+
614628
//-------------------------------------------------------------------------------------------------
615629
/** Render an object list into the texture passed in */
616630
//-------------------------------------------------------------------------------------------------
@@ -1431,16 +1445,7 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height )
14311445
// refresh the overlay texture once every so many frames
14321446
if( TheGameClient->getFrame() % OVERLAY_REFRESH_RATE == 0 )
14331447
{
1434-
1435-
// reset the overlay texture
1436-
SurfaceClass *surface = m_overlayTexture->Get_Surface_Level();
1437-
surface->Clear();
1438-
REF_PTR_RELEASE(surface);
1439-
1440-
// rebuild the object overlay
1441-
renderObjectList( getObjectList(), m_overlayTexture );
1442-
renderObjectList( getLocalObjectList(), m_overlayTexture, TRUE );
1443-
1448+
updateObjectTexture(m_overlayTexture);
14441449
}
14451450

14461451
// draw the overlay image
@@ -1489,6 +1494,18 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain )
14891494

14901495
}
14911496

1497+
// ------------------------------------------------------------------------------------------------
1498+
// ------------------------------------------------------------------------------------------------
1499+
void W3DRadar::refreshObjects()
1500+
{
1501+
if constexpr (OVERLAY_REFRESH_RATE > 1)
1502+
{
1503+
if (m_overlayTexture != NULL)
1504+
{
1505+
updateObjectTexture(m_overlayTexture);
1506+
}
1507+
}
1508+
}
14921509

14931510

14941511

0 commit comments

Comments
 (0)