From 1f40cec1e3cd7116a9bcefd3759bcc2f4a07898b Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Wed, 30 Dec 2009 13:18:24 +0000 Subject: [PATCH] Do not draw repair and baba muzzle flashes if structure is not seen by current player. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8868 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/display3d.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/display3d.c b/src/display3d.c index 6bec72988..226de49b5 100644 --- a/src/display3d.c +++ b/src/display3d.c @@ -2294,7 +2294,7 @@ void renderStructure(STRUCTURE *psStructure) pie_TRANSLATE(0, 0, psStructure->asWeaps[i].recoilValue); pie_Draw3DShape(weaponImd[i], playerFrame, 0, buildingBrightness, WZCOL_BLACK, pieFlag, pieFlagData); - if (psStructure->status == SS_BUILT) + if (psStructure->status == SS_BUILT && psStructure->visible[selectedPlayer] > (UBYTE_MAX / 2)) { if (psStructure->pStructureType->type == REF_REPAIR_FACILITY) { @@ -2327,8 +2327,7 @@ void renderStructure(STRUCTURE *psStructure) } } // we have a weapon so we draw a muzzle flash - if( weaponImd[i]->nconnectors && flashImd[i] && psStructure->visible[selectedPlayer]>(UBYTE_MAX/2) - && psStructure->pStructureType->type != REF_REPAIR_FACILITY) + if( weaponImd[i]->nconnectors && flashImd[i] && psStructure->pStructureType->type != REF_REPAIR_FACILITY) { unsigned int connector_num = 0; @@ -2394,23 +2393,26 @@ void renderStructure(STRUCTURE *psStructure) iV_TRANSLATE(0, 0, -40); } iV_MatrixRotateX(DEG(psStructure->asWeaps[i].pitch)); - // and draw the muzzle flash - // animate for the duration of the flash only - // assume no clan colours formuzzle effects - if (flashImd[i]->numFrames == 0 || flashImd[i]->animInterval <= 0) + // draw the muzzle flash? + if (psStructure && psStructure->visible[selectedPlayer] > UBYTE_MAX / 2) { - // no anim so display one frame for a fixed time - if (gameTime < psStructure->asWeaps[i].lastFired + BASE_MUZZLE_FLASH_DURATION) + // animate for the duration of the flash only + // assume no clan colours for muzzle effects + if (flashImd[i]->numFrames == 0 || flashImd[i]->animInterval <= 0) { - pie_Draw3DShape(flashImd[i], 0, 0, buildingBrightness, WZCOL_BLACK, 0, 0); //muzzle flash + // no anim so display one frame for a fixed time + if (gameTime < psStructure->asWeaps[i].lastFired + BASE_MUZZLE_FLASH_DURATION) + { + pie_Draw3DShape(flashImd[i], 0, 0, buildingBrightness, WZCOL_BLACK, 0, 0); //muzzle flash + } } - } - else - { - frame = (gameTime - psStructure->asWeaps[i].lastFired) / flashImd[i]->animInterval; - if (frame < flashImd[i]->numFrames) + else { - pie_Draw3DShape(flashImd[i], 0, 0, buildingBrightness, WZCOL_BLACK, 0, 0); //muzzle flash + frame = (gameTime - psStructure->asWeaps[i].lastFired) / flashImd[i]->animInterval; + if (frame < flashImd[i]->numFrames) + { + pie_Draw3DShape(flashImd[i], 0, 0, buildingBrightness, WZCOL_BLACK, 0, 0); //muzzle flash + } } } iV_MatrixEnd();