From 470d3eb129dbd41ef7d8471605cd64affabcad2a Mon Sep 17 00:00:00 2001 From: temple Date: Sat, 17 Feb 2018 01:37:52 +0000 Subject: [PATCH] Replace a territory texture hack Differential Revision: https://code.wildfiregames.com/D1293 This was SVN commit r21233. --- source/graphics/TerritoryTexture.cpp | 43 +++++++--------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/source/graphics/TerritoryTexture.cpp b/source/graphics/TerritoryTexture.cpp index f2f7592a28..c73c28c99f 100644 --- a/source/graphics/TerritoryTexture.cpp +++ b/source/graphics/TerritoryTexture.cpp @@ -184,36 +184,28 @@ void CTerritoryTexture::GenerateBitmap(const Grid& 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& 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; - } - } }