1
0
forked from 0ad/0ad

minimap: only update 10x/sec and if LOS state != ALL_VISIBLE; fix incorrect SAFE_DELETE

fix use of LOS_EXPLORED; == implies explored but not visible

This was SVN commit r3100.
This commit is contained in:
janwas 2005-11-06 02:02:44 +00:00
parent 6668ad6e1c
commit 15cce8566f
3 changed files with 20 additions and 14 deletions

View File

@ -166,10 +166,22 @@ void CMiniMap::Draw()
if(!m_TerrainTexture)
CreateTextures();
if(g_TerrainModified)
RebuildTerrainTexture();
// only update 10x / second
// (note: since units only move a few pixels per second on the minimap,
// we can get away with infrequent updates; this is slow, ~20ms)
static double last_time;
const double cur_time = get_time();
if(cur_time - last_time > 100e-3) // 10 updates/sec
{
last_time = cur_time;
RebuildLOSTexture();
if(g_TerrainModified)
RebuildTerrainTexture();
CLOSManager* losMgr = g_Game->GetWorld()->GetLOSManager();
if(losMgr->m_LOSSetting != CLOSManager::ALL_VISIBLE)
RebuildLOSTexture();
}
const float texCoordMax = ((float)m_MapSize - 1) / ((float)m_TextureSize);
const float x = m_CachedActualSize.left, y = m_CachedActualSize.bottom;
@ -293,13 +305,9 @@ void CMiniMap::CreateTextures()
RebuildLOSTexture();
}
TIMER_ADD_CLIENT(tc_minimap_rebuildterrain);
void CMiniMap::RebuildTerrainTexture()
{
PROFILE_START("rebuild minimap: terrain");
TIMER_ACCRUE(tc_minimap_rebuildterrain);
u32 x = 0;
u32 y = 0;
u32 w = m_MapSize - 1;
@ -346,8 +354,6 @@ void CMiniMap::RebuildTerrainTexture()
// Upload the texture
g_Renderer.BindTexture(0, m_TerrainTexture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize - 1, m_MapSize - 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_TerrainData);
PROFILE_END("rebuild minimap: terrain");
}
TIMER_ADD_CLIENT(tc_minimap_rebuildlos);
@ -375,7 +381,7 @@ void CMiniMap::RebuildLOSTexture()
{
*dataPtr++ = 0xff;
}
else if(status & LOS_EXPLORED)
else if(status == LOS_EXPLORED)
{
*dataPtr++ = (u8) (0xff * 0.3f);
}
@ -400,8 +406,8 @@ void CMiniMap::Destroy()
if(m_LOSTexture)
glDeleteTextures(1, (GLuint *)&m_LOSTexture);
SAFE_DELETE(m_TerrainData);
SAFE_DELETE(m_LOSData);
delete[] m_TerrainData; m_TerrainData = 0;
delete[] m_LOSData; m_LOSData = 0;
}
CVector2D CMiniMap::GetMapSpaceCoords(CVector3D worldPos)

View File

@ -461,7 +461,7 @@ void CPatchRData::Update()
if(tx >= 0 && tz >= 0 && tx <= mapSize-2 && tz <= mapSize-2)
{
ELOSStatus s = losMgr->GetStatus(tx, tz, g_Game->GetLocalPlayer());
if(s&LOS_EXPLORED && losMod > 0.7f)
if(s==LOS_EXPLORED && losMod > 0.7f)
losMod = 0.7f;
else if(s==LOS_UNEXPLORED && losMod > 0.0f)
losMod = 0.0f;

View File

@ -1035,7 +1035,7 @@ void CRenderer::RenderWater()
if(tx >= 0 && tz >= 0 && tx <= mapSize-2 && tz <= mapSize-2)
{
ELOSStatus s = losMgr->GetStatus(tx, tz, g_Game->GetLocalPlayer());
if(s&LOS_EXPLORED && losMod > 0.7f)
if(s == LOS_EXPLORED && losMod > 0.7f)
losMod = 0.7f;
else if(s==LOS_UNEXPLORED && losMod > 0.0f)
losMod = 0.0f;