Clean indention and make the code a little bit more readable.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1469 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2007-04-15 20:45:09 +00:00
parent a9f120adec
commit 5f87829d26
3 changed files with 483 additions and 481 deletions

View File

@ -24,6 +24,6 @@
#define MACROS_H
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif // MACROS_H

View File

@ -180,7 +180,7 @@ BOOL godMode;
static UWORD WaterTileID = WATER_TILE;
static UWORD RiverBedTileID = BED_TILE;
static FRACT waterRealValue = (FRACT)0;
static FRACT waterRealValue = 0.0f;
#define WAVE_SPEED 4
static SWORD vOffset = 1;
#define MAX_FIRE_STAGE 32
@ -494,7 +494,7 @@ BOOL bPlayerHasHQ = FALSE;
}
}
*/
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
if(getDebugMappingStatus() && !demoGetStatus() && !gamePaused())
@ -539,8 +539,8 @@ BOOL bPlayerHasHQ = FALSE;
permitNewConsoleMessages(FALSE);
}
// sprintf(buildInfo,"WallDrag from %d,%d to %d,%d", wallDrag.x1,wallDrag.y1,wallDrag.x2,wallDrag.y2);
// iV_DrawText(buildInfo,100,180);
// sprintf(buildInfo,"WallDrag from %d,%d to %d,%d", wallDrag.x1,wallDrag.y1,wallDrag.x2,wallDrag.y2);
// iV_DrawText(buildInfo,100,180);
/*
sprintf(buildInfo,"Gridvar calls : %d", gridVarCalls);
iV_DrawText(buildInfo,100,180);
@ -559,10 +559,10 @@ BOOL bPlayerHasHQ = FALSE;
iV_DrawText(buildInfo,100,240);
#endif
// sprintf(buildInfo,"Average Grid Height : %d", averageCentreTerrainHeight);
// iV_DrawText(buildInfo,100,240);
// sprintf(buildInfo,"Height : %d", player.p.y);
// iV_DrawText(buildInfo,100,260);
// sprintf(buildInfo,"Average Grid Height : %d", averageCentreTerrainHeight);
// iV_DrawText(buildInfo,100,240);
// sprintf(buildInfo,"Height : %d", player.p.y);
// iV_DrawText(buildInfo,100,260);
@ -664,20 +664,19 @@ void setProximityDraw(BOOL val)
static void drawTiles(iView *camera, iView *player)
{
SDWORD i,j;
UDWORD i, j;
SDWORD zMax;
Vector3i BSPCamera;
MAPTILE *psTile;
UDWORD specular;
UDWORD edgeX,edgeY;
UDWORD edgeX, edgeY;
BOOL IsWaterTile = FALSE;
BOOL PushedDown = FALSE;
UBYTE TileIllum;
UWORD TextNum;
UDWORD shiftVal = 0;
UDWORD altVal = 0;
FRACT fraction;
UDWORD realX,realY;
UDWORD realX, realY;
BOOL bEdgeTile;
SDWORD tmp_y;
static float angle = 0.0;
@ -685,32 +684,31 @@ static void drawTiles(iView *camera, iView *player)
// Animate the water texture, just cycles the V coordinate through half the tiles height.
if(!gamePaused())
{
fraction = MAKEFRACT(frameTime2)/GAME_TICKS_PER_SEC;
waterRealValue += (fraction*WAVE_SPEED);
vOffset = (SWORD)MAKEINT(waterRealValue);
waterRealValue += WAVE_SPEED * frameTime2 / GAME_TICKS_PER_SEC;
vOffset = waterRealValue;
if(vOffset >= 64/2)
{
vOffset = 0;
waterRealValue = (FRACT)0;
waterRealValue = 0;
}
}
/* Is the scene spinning? - showcase demo stuff */
if (spinScene)
player->r.y+=DEG(3);
player->r.y += DEG(3);
/* ---------------------------------------------------------------- */
/* Do boundary and extent checking */
/* ---------------------------------------------------------------- */
/* Get the mid point of the grid */
terrainMidX = (visibleXTiles>>1);
terrainMidY = (visibleYTiles>>1);
terrainMidX = visibleXTiles/2;
terrainMidY = visibleYTiles/2;
CalcBSPCameraPos(&BSPCamera);
SetBSPCameraPos(BSPCamera.x,BSPCamera.y,BSPCamera.z);
SetBSPCameraPos(BSPCamera.x, BSPCamera.y, BSPCamera.z);
/* Find our position in tile coordinates */
playerXTile = player->p.x >> TILE_SHIFT;
playerZTile = player->p.z >> TILE_SHIFT;
playerXTile = player->p.x / TILE_UNITS;
playerZTile = player->p.z / TILE_UNITS;
/* Get the x,z translation components */
rx = (player->p.x) & (TILE_UNITS-1);
@ -727,13 +725,13 @@ static void drawTiles(iView *camera, iView *player)
// Now, scale the world according to what resolution we're running in
pie_MatScale(pie_GetResScalingFactor());
/* Set the camera position */
pie_MATTRANS(camera->p.x,camera->p.y,camera->p.z);
pie_MATTRANS(camera->p.x, camera->p.y, camera->p.z);
/* Rotate for the player */
pie_MatRotZ(player->r.z);
pie_MatRotX(player->r.x);
pie_MatRotY(player->r.y);
/* Translate */
pie_TRANSLATE(-rx,-player->p.y,rz);
pie_TRANSLATE(-rx, -player->p.y, rz);
angle += 0.01f;
// RODZ uncomment the following line to see an OpenGL lighting demo
if (getDrawShadows()) {
@ -749,29 +747,31 @@ static void drawTiles(iView *camera, iView *player)
*/
averageCentreTerrainHeight = 0;
numTilesAveraged = 0;
for (i=0; i<(SDWORD)visibleYTiles+1; i++)
for (i=0; i < (SDWORD)visibleYTiles+1; i++)
{
/* Go through the x's */
for (j=0; j<(SDWORD)visibleXTiles+1; j++)
for (j=0; j < (SDWORD)visibleXTiles+1; j++)
{
tileScreenInfo[i][j].bWater = FALSE;
if( (playerXTile+j < 0) ||
(playerZTile+i < 0) ||
(playerXTile+j > (SDWORD)(mapWidth-1)) ||
(playerZTile+i > (SDWORD)(mapHeight-1)) )
if( playerXTile+j < 0 ||
playerZTile+i < 0 ||
playerXTile+j > (SDWORD)(mapWidth-1) ||
playerZTile+i > (SDWORD)(mapHeight-1) )
{
edgeX = playerXTile+j;
edgeY = playerZTile+i;
if(playerXTile+j < 0 ) edgeX = 0;
else
if(playerXTile+j > (SDWORD)(mapWidth-1) ) edgeX = mapWidth-1;
if(playerZTile+i < 0 ) edgeY = 0;
else
if(playerZTile+i > (SDWORD)(mapHeight-1) ) edgeY = mapHeight-1;
if(playerXTile+j < 0 )
edgeX = 0;
else if(playerXTile+j > (SDWORD)(mapWidth-1) )
edgeX = mapWidth-1;
if(playerZTile+i < 0 )
edgeY = 0;
else if(playerZTile+i > (SDWORD)(mapHeight-1) )
edgeY = mapHeight-1;
tileScreenInfo[i][j].x = ((j-terrainMidX)<<TILE_SHIFT);
tileScreenInfo[i][j].x = (j-terrainMidX) * TILE_UNITS;
tileScreenInfo[i][j].y = 0;//map_TileHeight(edgeX,edgeY);
tileScreenInfo[i][j].z = ((terrainMidY-i)<<TILE_SHIFT);
tileScreenInfo[i][j].z = (terrainMidY-i) * TILE_UNITS;
tileScreenInfo[i][j].sz = pie_RotProj((Vector3i*)&tileScreenInfo[i][j].x, (Vector2i*)&tileScreenInfo[i][j].sx);
if (pie_GetFogEnabled())
@ -781,14 +781,13 @@ static void drawTiles(iView *camera, iView *player)
}
else
{
tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination(mapTile(edgeX,edgeY)->illumination,rx-tileScreenInfo[i][j].x,rz - ((i-terrainMidY)<<TILE_SHIFT),&specular);
tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination( mapTile(edgeX, edgeY)->illumination, rx - tileScreenInfo[i][j].x, rz - (i - terrainMidY) * TILE_UNITS, &specular );
}
if( (playerXTile+j <-1 ) ||
(playerZTile+i <-1) ||
(playerXTile+j > (SDWORD)(mapWidth-1)) ||
(playerZTile+i > (SDWORD)(mapHeight-1)) )
if( playerXTile+j < -1 ||
playerZTile+i < -1 ||
playerXTile+j > (SDWORD)(mapWidth-1) ||
playerZTile+i > (SDWORD)(mapHeight-1) )
{
tileScreenInfo[i][j].drawInfo = FALSE;
}
@ -796,25 +795,27 @@ static void drawTiles(iView *camera, iView *player)
{
tileScreenInfo[i][j].drawInfo = TRUE;
}
}
else
{
tileScreenInfo[i][j].drawInfo = TRUE;
psTile = mapTile(playerXTile+j,playerZTile+i);
psTile = mapTile(playerXTile+j, playerZTile+i);
/* Get a pointer to the tile at this location */
tileScreenInfo[i][j].x = ((j-terrainMidX)<<TILE_SHIFT);
tileScreenInfo[i][j].x = (j-terrainMidX) * TILE_UNITS;
if (TERRAIN_TYPE(psTile) == TER_WATER)
{
tileScreenInfo[i][j].bWater = TRUE;
}
tileScreenInfo[i][j].y = map_TileHeight(playerXTile+j, playerZTile+i);
tileScreenInfo[i][j].z = ((terrainMidY-i)<<TILE_SHIFT);
tileScreenInfo[i][j].z = (terrainMidY-i) * TILE_UNITS;
/* Is it in the centre and therefore worth averaging height over? */
if(i > MIN_TILE_Y && i < MAX_TILE_Y && j > MIN_TILE_X && j < MAX_TILE_X)
if ( i > MIN_TILE_Y &&
i < MAX_TILE_Y &&
j > MIN_TILE_X &&
j < MAX_TILE_X )
{
averageCentreTerrainHeight += tileScreenInfo[i][j].y;
numTilesAveraged++;
@ -822,7 +823,10 @@ static void drawTiles(iView *camera, iView *player)
realX = playerXTile+j;
realY = playerZTile+i;
bEdgeTile = FALSE;
if(realX<=1 || realY<=1 || realX >= mapWidth-2 || realY >= mapHeight-2)
if ( realX <= 1 ||
realY <= 1 ||
realX >= mapWidth-2 ||
realY >= mapHeight-2 )
{
bEdgeTile = TRUE;
}
@ -853,37 +857,35 @@ static void drawTiles(iView *camera, iView *player)
IsWaterTile = (TERRAIN_TYPE(psTile) == TER_WATER);
// If it's the main water tile then..
PushedDown = FALSE;
if( TextNum == WaterTileID && !bEdgeTile)
if( TextNum == WaterTileID && !bEdgeTile )
{
// Push the terrain down for the river bed.
PushedDown = TRUE;
shiftVal = WATER_DEPTH + ((3*environGetData(playerXTile+j,playerZTile+i))/2);
shiftVal = WATER_DEPTH + environGetData(playerXTile+j, playerZTile+i) * 1.5f;
altVal = 0;//environGetValue(playerXTile+j,playerZTile+i);
tileScreenInfo[i][j].y -= (shiftVal+altVal);
tileScreenInfo[i][j].y -= shiftVal + altVal;
// And darken it.
TileIllum = (UBYTE)((TileIllum*3)/4);
TileIllum = (UBYTE)(TileIllum * 0.75f);
}
tileScreenInfo[i][j].sz = pie_RotProj((Vector3i*)&tileScreenInfo[i][j], (Vector2i*)&tileScreenInfo[i][j].sx);
tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination(TileIllum,rx-tileScreenInfo[i][j].x,rz - ((i-terrainMidY)<<TILE_SHIFT),&specular);
tileScreenInfo[i][j].light.argb = lightDoFogAndIllumination(TileIllum, rx - tileScreenInfo[i][j].x, rz - (i-terrainMidY) * TILE_UNITS, &specular);
tileScreenInfo[i][j].specular.argb = specular;
// If it's any water tile..
if(IsWaterTile) {
// If it's the main water tile then bring it back up because it was pushed down
// for the river bed calc.
// If it's the main water tile then bring it back up because it was pushed down for the river bed calc.
tmp_y = tileScreenInfo[i][j].y;
if (PushedDown) { //TextNum == WaterTileID) {
tileScreenInfo[i][j].y += (shiftVal + (2*altVal));
tileScreenInfo[i][j].y += (shiftVal + 2*altVal);
}
// Transform it into the wx,wy mesh members.
tileScreenInfo[i][j].wz = pie_RotProj((Vector3i*)&tileScreenInfo[i][j], (Vector2i*)&tileScreenInfo[i][j].wx);
tileScreenInfo[i][j].wlight.argb = lightDoFogAndIllumination(
TileIllum, rx-tileScreenInfo[i][j].x, // cos altval can go to 20
rz - ((i-terrainMidY)<<TILE_SHIFT), &specular);
TileIllum, rx - tileScreenInfo[i][j].x, rz - (i-terrainMidY) * TILE_UNITS, &specular);
tileScreenInfo[i][j].water_height = tileScreenInfo[i][j].y;
tileScreenInfo[i][j].y = tmp_y;
} else {
@ -901,15 +903,16 @@ static void drawTiles(iView *camera, iView *player)
/* Work out the average height */
if(numTilesAveraged) // might not be if off map
{
averageCentreTerrainHeight/=numTilesAveraged;
averageCentreTerrainHeight /= numTilesAveraged;
}
else
{
averageCentreTerrainHeight = 128 * ELEVATION_SCALE;
averageCentreTerrainHeight = ELEVATION_SCALE * TILE_UNITS;
}
/* This is done here as effects can light the terrain - pause mode problems though */
processEffects();
atmosUpdateSystem();
if(waterOnMap())
{
// environUpdate();
@ -932,29 +935,29 @@ static void drawTiles(iView *camera, iView *player)
tileIJ[i][j].i = i;
tileIJ[i][j].j = j;
//get distance of furthest corner
zMax = pie_MAX(tileScreenInfo[i][j].sz, tileScreenInfo[i + 1][j].sz);
zMax = pie_MAX(zMax, tileScreenInfo[i + 1][j + 1].sz);
zMax = pie_MAX(zMax, tileScreenInfo[i][j + 1].sz);
zMax = MAX(tileScreenInfo[i][j].sz, tileScreenInfo[i+1][j].sz);
zMax = MAX(zMax, tileScreenInfo[i+1][j+1].sz);
zMax = MAX(zMax, tileScreenInfo[i][j+1].sz);
tileIJ[i][j].depth = zMax;
if((UDWORD)i>mapHeight || (UDWORD)j>mapWidth)
if( (UDWORD)i > mapHeight || (UDWORD)j > mapWidth )
{
ASSERT( FALSE,"Weirdy tile coords" );
ASSERT( FALSE, "Weirdy tile coords" );
}
if(zMax<0)
if(zMax < 0)
{
// clipped
continue;
}
drawTerrainTile(i,j, FALSE);
drawTerrainTile(i, j, FALSE);
if(tileScreenInfo[i][j].bWater)
{
// add the (possibly) transparent water to the bucket sort
bucketAddTypeToList(RENDER_WATERTILE, &tileIJ[i][j]);
// check if we need to draw a water edge
if((mapTile(playerXTile + j, playerZTile + i)->texture & TILE_NUMMASK) != WaterTileID) {
if((mapTile(playerXTile+j, playerZTile+i)->texture & TILE_NUMMASK) != WaterTileID) {
// the edge is in front of the water (which is drawn at z-index -1)
pie_SetDepthOffset(-2.0);
drawTerrainTile(i,j, TRUE);
drawTerrainTile(i, j, TRUE);
pie_SetDepthOffset(0.0);
}
}
@ -967,15 +970,15 @@ static void drawTiles(iView *camera, iView *player)
/* ---------------------------------------------------------------- */
/* Now display all the static objects */
/* ---------------------------------------------------------------- */
displayStaticObjects();//bucket render implemented
displayFeatures();//bucket render implemented
displayDynamicObjects();//bucket render implemented
displayStaticObjects(); // bucket render implemented
displayFeatures(); // bucket render implemented
displayDynamicObjects(); //bucket render implemented
if(doWeDrawProximitys())
{
displayProximityMsgs(); //bucket render implemented
displayProximityMsgs(); // bucket render implemented
}
displayDelivPoints(); //bucket render implemented
display3DProjectiles();//bucket render implemented
displayDelivPoints(); // bucket render implemented
display3DProjectiles(); // bucket render implemented
atmosDrawParticles();
@ -991,8 +994,7 @@ static void drawTiles(iView *camera, iView *player)
if(driveModeActive()) {
// If were in driving mode then mark the current target.
BASE_OBJECT *psObj = targetGetCurrent();
if(psObj != NULL) {
if(targetGetCurrent() != NULL) {
targetMarkCurrent();
}
}
@ -1049,7 +1051,7 @@ BOOL init3DView(void)
initConsoleMessages();
/* Initialise the effects system */
// initEffectsSystem();
// initEffectsSystem();
atmosInitSystem();
@ -1062,7 +1064,7 @@ BOOL init3DView(void)
initBulletTable();
/* Set up light values */
// initLighting();
// initLighting();
/* Build our shade table for gouraud shading - 256*16 values with best match from 256 colour table */
iV_PaletteShadeTableCreate();
@ -1107,7 +1109,7 @@ void disp3d_getView(iView *newView)
}
/* John's routine - deals with flipping around the vertex ordering for source textures
when flips and rotations are being done */
when flips and rotations are being done */
static void flipsAndRots(int texture)
{
@ -1663,7 +1665,7 @@ BOOL bEdgeTile;
*/
}
}
}
}
/* Draw the buildings */
void displayStaticObjects( void )
@ -1774,7 +1776,7 @@ UDWORD clan;
renderFeature(psFeature);
}
}
}
}
/* Draw the Proximity messages for the **SELECTED PLAYER ONLY***/
void displayProximityMsgs( void )
@ -2794,8 +2796,8 @@ static BOOL renderWallSection(STRUCTURE *psStructure)
/* Get it's x and y coordinates so we don't have to deref. struct later */
structX = psStructure->x;
structY = psStructure->y;
// centreX = ( player.p.x + ((visibleXTiles/2)<<TILE_SHIFT) );
// centreZ = ( player.p.z + ((visibleYTiles/2)<<TILE_SHIFT) );
// centreX = ( player.p.x + ((visibleXTiles/2)<<TILE_SHIFT) );
// centreZ = ( player.p.z + ((visibleYTiles/2)<<TILE_SHIFT) );
buildingBrightness = 200 - (100-PERCENT( psStructure->body , structureBody(psStructure)));
if(psStructure->selected)
@ -2997,8 +2999,8 @@ void renderDroid( DROID *psDroid )
// "moveUpdateUnit: unit at (0,0)" );
// psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
// ASSERT( psPropStats != NULL,
// psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
// ASSERT( psPropStats != NULL,
// "moveUpdateDroid: invalid propulsion stats pointer" );
/*
@ -5501,8 +5503,8 @@ void debugToggleSensorDisplay( void )
}
/* draw some effects at certain position to visualize the radius,
* negative radius turns this off
*/
* negative radius turns this off
*/
void showRangeAtPos(SDWORD centerX, SDWORD centerY, SDWORD radius)
{
rangeCenterX = centerX;
@ -5671,7 +5673,7 @@ DROID *psDroid;
UDWORD i;
// pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);
// pie_SetFogStatus(FALSE);
// pie_SetFogStatus(FALSE);
for(i=0; i<MAX_PLAYERS; i++)
{

View File

@ -130,14 +130,14 @@ MAPTILE *psTile;
// -------------------------------------------------------------------------------
void environUpdate( void )
{
UDWORD i,j;
UDWORD index;
FRACT value,newValue;
FRACT increment = 0;
FRACT lowest = 0;
FRACT highest = 0;
UDWORD startX,startY,endX,endY;
FRACT fraction;
UDWORD i,j;
UDWORD index;
FRACT value,newValue;
FRACT increment = 0;
FRACT lowest = 0;
FRACT highest = 0;
UDWORD startX,startY,endX,endY;
FRACT fraction;
//at the moment this function is getting called between levels and so crashes - quick check here for now
if (pEnvironData == NULL)