Clean up terrain colour handling a bit.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3046 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-12-13 22:00:54 +00:00
parent cf0007f8be
commit 9c8e54520f
3 changed files with 31 additions and 28 deletions

View File

@ -525,6 +525,18 @@ static void calcAverageTerrainHeight(iView *player)
}
}
PIELIGHT getTileColour(int x, int y)
{
return mapTile(x, y)->colour;
}
void setTileColour(int x, int y, PIELIGHT colour)
{
MAPTILE *psTile = mapTile(x, y);
psTile->colour = colour;
}
static void drawTiles(iView *camera, iView *player)
{
UDWORD i, j;
@ -604,6 +616,7 @@ static void drawTiles(iView *camera, iView *player)
tileScreenInfo[i][j].pos.z = world_coord(terrainMidY - i);
tileScreenInfo[i][j].pos.y = 0;
tileScreenInfo[i][j].bWater = FALSE;
tileScreenInfo[i][j].specular = WZCOL_BLACK;
if( playerXTile+j < 0 ||
playerZTile+i < 0 ||
@ -614,8 +627,7 @@ static void drawTiles(iView *camera, iView *player)
tileScreenInfo[i][j].bWater = FALSE;
tileScreenInfo[i][j].u = 0;
tileScreenInfo[i][j].v = 0;
tileScreenInfo[i][j].light.argb = 0;
tileScreenInfo[i][j].specular.argb = 0;
tileScreenInfo[i][j].light = WZCOL_BLACK;
}
else
{
@ -635,25 +647,13 @@ static void drawTiles(iView *camera, iView *player)
}
tileScreenInfo[i][j].light = TileIllum;
tileScreenInfo[i][j].specular = WZCOL_BLACK;
// Real fog of war - darken where we cannot see enemy units moving around
if (bDisplaySensorRange && psTile && !psTile->activeSensor)
{
const int f = 2;
tileScreenInfo[i+0][j+0].light.byte.r = tileScreenInfo[i+0][j+0].light.byte.r / f;
tileScreenInfo[i+0][j+1].light.byte.r = tileScreenInfo[i+0][j+1].light.byte.r / f;
tileScreenInfo[i+1][j+1].light.byte.r = tileScreenInfo[i+1][j+1].light.byte.r / f;
tileScreenInfo[i+1][j+0].light.byte.r = tileScreenInfo[i+1][j+0].light.byte.r / f;
tileScreenInfo[i+0][j+0].light.byte.g = tileScreenInfo[i+0][j+0].light.byte.g / f;
tileScreenInfo[i+0][j+1].light.byte.g = tileScreenInfo[i+0][j+1].light.byte.g / f;
tileScreenInfo[i+1][j+1].light.byte.g = tileScreenInfo[i+1][j+1].light.byte.g / f;
tileScreenInfo[i+1][j+0].light.byte.g = tileScreenInfo[i+1][j+0].light.byte.g / f;
tileScreenInfo[i+0][j+0].light.byte.b = tileScreenInfo[i+0][j+0].light.byte.b / f;
tileScreenInfo[i+0][j+1].light.byte.b = tileScreenInfo[i+0][j+1].light.byte.b / f;
tileScreenInfo[i+1][j+1].light.byte.b = tileScreenInfo[i+1][j+1].light.byte.b / f;
tileScreenInfo[i+1][j+0].light.byte.b = tileScreenInfo[i+1][j+0].light.byte.b / f;
tileScreenInfo[i][j].light.byte.r = tileScreenInfo[i][j].light.byte.r / 2;
tileScreenInfo[i][j].light.byte.g = tileScreenInfo[i][j].light.byte.g / 2;
tileScreenInfo[i][j].light.byte.b = tileScreenInfo[i][j].light.byte.b / 2;
}
if ( playerXTile+j <= 1 ||

View File

@ -78,6 +78,8 @@ extern void setBlipDraw(BOOL val);
extern void setProximityDraw(BOOL val);
extern void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD );
extern PIELIGHT getTileColour(int x, int y);
extern void setTileColour(int x, int y, PIELIGHT colour);
extern UDWORD getSuggestedPitch( void );

View File

@ -418,38 +418,39 @@ static UDWORD calcDistToTile(UDWORD tileX, UDWORD tileY, Vector3i *pos)
// FIXME: Is the percent variable misnamed here, or is the code wrong? Because we do
// not use it as a percentage!
static void colourTile(SDWORD xIndex, SDWORD yIndex, LIGHT_COLOUR colour, UBYTE percent)
static void colourTile(SDWORD xIndex, SDWORD yIndex, LIGHT_COLOUR colouridx, UBYTE percent)
{
MAPTILE *psTile = mapTile(xIndex, yIndex);
PIELIGHT colour = getTileColour(xIndex, yIndex);
switch(colour)
switch(colouridx)
{
case LIGHT_RED:
/* And add that to the lighting value */
psTile->colour.byte.r = MIN(255, psTile->colour.byte.r + percent);
colour.byte.r = MIN(255, colour.byte.r + percent);
break;
case LIGHT_GREEN:
/* And add that to the lighting value */
psTile->colour.byte.g = MIN(255, psTile->colour.byte.g + percent);
colour.byte.g = MIN(255, colour.byte.g + percent);
break;
case LIGHT_BLUE:
/* And add that to the lighting value */
psTile->colour.byte.b = MIN(255, psTile->colour.byte.b + percent);
colour.byte.b = MIN(255, colour.byte.b + percent);
break;
case LIGHT_YELLOW:
/* And add that to the lighting value */
psTile->colour.byte.r = MIN(255, psTile->colour.byte.r + percent);
psTile->colour.byte.g = MIN(255, psTile->colour.byte.g + percent);
colour.byte.r = MIN(255, colour.byte.r + percent);
colour.byte.g = MIN(255, colour.byte.g + percent);
break;
case LIGHT_WHITE:
psTile->colour.byte.r = MIN(255, psTile->colour.byte.r + percent);
psTile->colour.byte.g = MIN(255, psTile->colour.byte.g + percent);
psTile->colour.byte.b = MIN(255, psTile->colour.byte.b + percent);
colour.byte.r = MIN(255, colour.byte.r + percent);
colour.byte.g = MIN(255, colour.byte.g + percent);
colour.byte.b = MIN(255, colour.byte.b + percent);
break;
default:
ASSERT( FALSE,"Weirdy colour of light attempted" );
break;
}
setTileColour(xIndex, yIndex, colour);
}
/// Sets the begin and end distance for the distance fog (mist)