Skip to content

Commit b4d1013

Browse files
committed
bugfix(radar): Refresh radar objects without delay when changing player (#1569)
1 parent 86eccd7 commit b4d1013

File tree

7 files changed

+65
-20
lines changed

7 files changed

+65
-20
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

Generals/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

Generals/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,

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

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

616+
//-------------------------------------------------------------------------------------------------
617+
//-------------------------------------------------------------------------------------------------
618+
void W3DRadar::updateObjectTexture(TextureClass *texture)
619+
{
620+
// reset the overlay texture
621+
SurfaceClass *surface = texture->Get_Surface_Level();
622+
surface->Clear();
623+
REF_PTR_RELEASE(surface);
624+
625+
// rebuild the object overlay
626+
renderObjectList( getObjectList(), texture );
627+
renderObjectList( getLocalObjectList(), texture, TRUE );
628+
}
629+
616630
//-------------------------------------------------------------------------------------------------
617631
/** Render an object list into the texture passed in */
618632
//-------------------------------------------------------------------------------------------------
@@ -1443,16 +1457,7 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height )
14431457
// refresh the overlay texture once every so many frames
14441458
if( TheGameClient->getFrame() % OVERLAY_REFRESH_RATE == 0 )
14451459
{
1446-
1447-
// reset the overlay texture
1448-
SurfaceClass *surface = m_overlayTexture->Get_Surface_Level();
1449-
surface->Clear();
1450-
REF_PTR_RELEASE(surface);
1451-
1452-
// rebuild the object overlay
1453-
renderObjectList( getObjectList(), m_overlayTexture );
1454-
renderObjectList( getLocalObjectList(), m_overlayTexture, TRUE );
1455-
1460+
updateObjectTexture(m_overlayTexture);
14561461
}
14571462

14581463
// draw the overlay image
@@ -1501,6 +1506,18 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain )
15011506

15021507
}
15031508

1509+
// ------------------------------------------------------------------------------------------------
1510+
// ------------------------------------------------------------------------------------------------
1511+
void W3DRadar::refreshObjects()
1512+
{
1513+
if constexpr (OVERLAY_REFRESH_RATE > 1)
1514+
{
1515+
if (m_overlayTexture != NULL)
1516+
{
1517+
updateObjectTexture(m_overlayTexture);
1518+
}
1519+
}
1520+
}
15041521

15051522

15061523

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/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)