Improve readability of renderFeature by returning early, adding some comments, etc

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5350 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2008-06-30 17:07:41 +00:00
parent fec1f446d3
commit 45b8413abf
1 changed files with 88 additions and 80 deletions

View File

@ -1639,22 +1639,29 @@ void renderFeature(FEATURE *psFeature)
BOOL bForceDraw = ( !getRevealStatus() && psFeature->psStats->visibleAtStart);
int shadowFlags = 0;
if (psFeature->visible[selectedPlayer] || godMode || demoGetStatus() || bForceDraw)
if (!psFeature->visible[selectedPlayer] && !godMode && !demoGetStatus() && !bForceDraw)
{
return;
}
/* Mark it as having been drawn */
psFeature->sDisplay.frameNumber = currentGameFrame;
/* Get it's x and y coordinates so we don't have to deref. struct later */
featX = psFeature->pos.x;
featY = psFeature->pos.y;
/* Daft hack to get around the oild derrick issue */
if (!TileHasFeature(mapTile(map_coord(featX), map_coord(featY))))
{
return;
}
dv.x = (featX - player.p.x) - terrainMidX*TILE_UNITS;
dv.z = terrainMidY*TILE_UNITS - (featY - player.p.z);
/* features sits at the height of the tile it's centre is on */
dv.y = psFeature->pos.z;
dv = Vector3i_New(
(featX - player.p.x) - terrainMidX*TILE_UNITS,
dv.y = psFeature->pos.z, // features sits at the height of the tile it's centre is on
terrainMidY*TILE_UNITS - (featY - player.p.z)
);
/* Push the indentity matrix */
iV_MatrixBegin();
@ -1662,6 +1669,7 @@ void renderFeature(FEATURE *psFeature)
/* Translate the feature - N.B. We can also do rotations here should we require
buildings to face different ways - Don't know if this is necessary - should be IMO */
iV_TRANSLATE(dv.x,dv.y,dv.z);
/* Get the x,z translation components */
rx = player.p.x & (TILE_UNITS-1);
rz = player.p.z & (TILE_UNITS-1);
@ -1674,28 +1682,29 @@ void renderFeature(FEATURE *psFeature)
brightness = pal_SetBrightness(200); //? HUH?
if(psFeature->psStats->subType == FEAT_SKYSCRAPER)
if (psFeature->psStats->subType == FEAT_SKYSCRAPER)
{
objectShimmy((BASE_OBJECT*)psFeature);
}
if(godMode || demoGetStatus() || bForceDraw)
if (godMode || demoGetStatus() || bForceDraw)
{
brightness = pal_SetBrightness(200);
}
else if(getRevealStatus())
else if (getRevealStatus())
{
brightness = pal_SetBrightness(avGetObjLightLevel((BASE_OBJECT*)psFeature, brightness.byte.r));
}
if (psFeature->psStats->subType == FEAT_BUILDING || psFeature->psStats->subType == FEAT_SKYSCRAPER
if (psFeature->psStats->subType == FEAT_BUILDING
|| psFeature->psStats->subType == FEAT_SKYSCRAPER
|| psFeature->psStats->subType == FEAT_OIL_DRUM)
{
// these cast a shadow
/* these cast a shadow */
shadowFlags = pie_STATIC_SHADOW;
}
if(psFeature->psStats->subType == FEAT_OIL_RESOURCE)
if (psFeature->psStats->subType == FEAT_OIL_RESOURCE)
{
vecTemp = psFeature->sDisplay.imd->points;
flattenImd(psFeature->sDisplay.imd, psFeature->pos.x, psFeature->pos.y, 0);
@ -1720,7 +1729,6 @@ void renderFeature(FEATURE *psFeature)
}
iV_MatrixEnd();
}
}
void renderProximityMsg(PROXIMITY_DISPLAY *psProxDisp)