mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-11 05:16:31 +00:00
Replace a territory texture hack
Differential Revision: https://code.wildfiregames.com/D1293 This was SVN commit r21233.
This commit is contained in:
@@ -184,36 +184,28 @@ void CTerritoryTexture::GenerateBitmap(const Grid<u8>& territories, u8* bitmap,
|
||||
|
||||
u8* p = bitmap;
|
||||
for (ssize_t j = 0; j < h; ++j)
|
||||
{
|
||||
for (ssize_t i = 0; i < w; ++i)
|
||||
{
|
||||
u8 val = territories.get(i, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK;
|
||||
|
||||
CColor color(1, 0, 1, 1);
|
||||
// Force neutral territories to pure white, so that later we can omit them from the texture
|
||||
if (val == 0)
|
||||
color = CColor(1, 1, 1, 0);
|
||||
else if (val < colors.size())
|
||||
if (val < colors.size())
|
||||
color = colors[val];
|
||||
|
||||
*p++ = (int)(color.r*255.f);
|
||||
*p++ = (int)(color.g*255.f);
|
||||
*p++ = (int)(color.b*255.f);
|
||||
*p++ = (int)(color.r * 255.f);
|
||||
*p++ = (int)(color.g * 255.f);
|
||||
*p++ = (int)(color.b * 255.f);
|
||||
|
||||
if ((i > 0 && (territories.get(i-1, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val)
|
||||
|| (i < w-1 && (territories.get(i+1, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val)
|
||||
|| (j > 0 && (territories.get(i, j-1) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val)
|
||||
|| (j < h-1 && (territories.get(i, j+1) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val)
|
||||
)
|
||||
{
|
||||
// Use alphaMax for borders and gaia territory; these tiles will be deleted later
|
||||
if (val == 0 ||
|
||||
(i > 0 && (territories.get(i-1, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) ||
|
||||
(i < w-1 && (territories.get(i+1, j) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) ||
|
||||
(j > 0 && (territories.get(i, j-1) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val) ||
|
||||
(j < h-1 && (territories.get(i, j+1) & ICmpTerritoryManager::TERRITORY_PLAYER_MASK) != val))
|
||||
*p++ = alphaMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do a low-quality cheap blur effect
|
||||
|
||||
@@ -257,22 +249,7 @@ void CTerritoryTexture::GenerateBitmap(const Grid<u8>& territories, u8* bitmap,
|
||||
|
||||
// Add a gap between the boundaries, by deleting the max-alpha tiles
|
||||
for (ssize_t j = 0; j < h; ++j)
|
||||
{
|
||||
for (ssize_t i = 0; i < w; ++i)
|
||||
{
|
||||
if (bitmap[(j*w+i)*4 + 3] == alphaMax)
|
||||
bitmap[(j*w+i)*4 + 3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't show neutral territory boundaries
|
||||
for (ssize_t j = 0; j < h; ++j)
|
||||
{
|
||||
for (ssize_t i = 0; i < w; ++i)
|
||||
{
|
||||
ssize_t idx = (j*w+i)*4;
|
||||
if (bitmap[idx] == 255 && bitmap[idx+1] == 255 && bitmap[idx+2] == 255)
|
||||
bitmap[idx+3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user