Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleanup of display code, preparing for the astyle.

  • Loading branch information...
commit fa496777fbe94a13a4055f7a387e278f3c83df7c 1 parent 6bb8745
Per Inge Mathisen perim authored

Showing 1 changed file with 30 additions and 59 deletions. Show diff stats Hide diff stats

  1. +30 59 src/display3d.cpp
89 src/display3d.cpp
@@ -302,6 +302,16 @@ static const int BLUEPRINT_OPACITY=120;
302 302
303 303 /******************** Functions ********************/
304 304
  305 +static void setScreenDisp(SCREEN_DISP_DATA *sDisplay)
  306 +{
  307 + Vector3i zero(0, 0, 0);
  308 + Vector2i s(0, 0);
  309 +
  310 + pie_RotateProject(&zero, &s);
  311 + sDisplay->screenX = s.x;
  312 + sDisplay->screenY = s.y;
  313 +}
  314 +
305 315 void setSkyBox(const char *page, float mywind, float myscale)
306 316 {
307 317 windSpeed = mywind;
@@ -1404,15 +1414,10 @@ void renderAnimComponent( const COMPONENT_OBJECT *psObj )
1404 1414 //brightness and fog calculation
1405 1415 if (psParentObj->type == OBJ_STRUCTURE)
1406 1416 {
1407   - const Vector3i zero(0, 0, 0);
1408   - Vector2i s(0, 0);
1409 1417 STRUCTURE *psStructure = (STRUCTURE*)psParentObj;
1410 1418
1411 1419 brightness = structureBrightness(psStructure);
1412   -
1413   - pie_RotateProject( &zero, &s );
1414   - psStructure->sDisplay.screenX = s.x;
1415   - psStructure->sDisplay.screenY = s.y;
  1420 + setScreenDisp(&psStructure->sDisplay);
1416 1421 }
1417 1422 else
1418 1423 {
@@ -1972,11 +1977,7 @@ void renderFeature(FEATURE *psFeature)
1972 1977
1973 1978 pie_Draw3DShape(psFeature->sDisplay.imd, 0, 0, brightness, shadowFlags, 0);
1974 1979
1975   - Vector3i zero(0, 0, 0);
1976   - Vector2i s(0, 0);
1977   - pie_RotateProject(&zero, &s);
1978   - psFeature->sDisplay.screenX = s.x;
1979   - psFeature->sDisplay.screenY = s.y;
  1980 + setScreenDisp(&psFeature->sDisplay);
1980 1981
1981 1982 pie_MatEnd();
1982 1983 }
@@ -2229,9 +2230,11 @@ void renderStructure(STRUCTURE *psStructure)
2229 2230 pie_Draw3DShape(psStructure->prebuiltImd, 0, colour, buildingBrightness, pie_SHADOW, 0);
2230 2231 }
2231 2232 pie_Draw3DShape(strImd, 0, colour, buildingBrightness, pie_HEIGHT_SCALED | pie_SHADOW, structHeightScale(psStructure) * pie_RAISE_SCALE);
  2233 + setScreenDisp(&psStructure->sDisplay);
  2234 + pie_MatEnd();
  2235 + return;
2232 2236 }
2233   - else
2234   - {
  2237 +
2235 2238 if (structureIsBlueprint(psStructure))
2236 2239 {
2237 2240 pieFlag = pie_TRANSLUCENT;
@@ -2473,17 +2476,8 @@ void renderStructure(STRUCTURE *psStructure)
2473 2476 }
2474 2477 }
2475 2478 }
2476   - }
2477   -
2478   - {
2479   - Vector3i zero(0, 0, 0);
2480   - Vector2i s(0, 0);
2481   -
2482   - pie_RotateProject(&zero, &s);
2483   - psStructure->sDisplay.screenX = s.x;
2484   - psStructure->sDisplay.screenY = s.y;
2485   - }
2486 2479
  2480 + setScreenDisp(&psStructure->sDisplay);
2487 2481 pie_MatEnd();
2488 2482 }
2489 2483
@@ -2545,8 +2539,11 @@ static bool renderWallSection(STRUCTURE *psStructure)
2545 2539 int pieFlag, pieFlagData;
2546 2540 MAPTILE *psTile = worldTile(psStructure->pos.x, psStructure->pos.y);
2547 2541
2548   - if(psStructure->visible[selectedPlayer])
  2542 + if (!psStructure->visible[selectedPlayer])
2549 2543 {
  2544 + return false;
  2545 + }
  2546 +
2550 2547 if (psTile->jammerBits & alliancebits[psStructure->player])
2551 2548 {
2552 2549 ecmFlag = pie_ECM;
@@ -2605,21 +2602,12 @@ static bool renderWallSection(STRUCTURE *psStructure)
2605 2602 pie_Draw3DShape(psStructure->sDisplay.imd, 0, getPlayerColour(psStructure->player), brightness, pieFlag|ecmFlag, pieFlagData);
2606 2603 }
2607 2604
2608   - {
2609   - Vector3i zero(0, 0, 0);
2610   - Vector2i s(0, 0);
2611   -
2612   - pie_RotateProject( &zero, &s );
2613   - psStructure->sDisplay.screenX = s.x;
2614   - psStructure->sDisplay.screenY = s.y;
2615   - }
  2605 + setScreenDisp(&psStructure->sDisplay);
2616 2606
2617 2607 pie_SetShaderStretchDepth(0);
2618 2608 pie_MatEnd();
2619 2609
2620   - return(true);
2621   - }
2622   - return false;
  2610 + return true;
2623 2611 }
2624 2612
2625 2613 /// Draws a shadow under a droid
@@ -3069,9 +3057,7 @@ static void drawDroidSelections( void )
3069 3057 continue; // Not visible, anyway. Don't bother with health bars.
3070 3058 }
3071 3059
3072   - /* If it's selected and on screen or it's the one the mouse is over ||*/
3073   - // ABSOLUTELY MAD LOGICAL EXPRESSION!!! :-)
3074   - // Now slightly less mad and slightly less buggy.
  3060 + /* If it's selected and on screen or it's the one the mouse is over */
3075 3061 if (eitherSelected(psDroid) ||
3076 3062 (bMouseOverOwnDroid && psDroid == (DROID *) psClickedOn) ||
3077 3063 droidUnderRepair(psDroid) ||
@@ -3098,19 +3084,16 @@ static void drawDroidSelections( void )
3098 3084 mulH = (float)psDroid->body / (float)psDroid->originalBody;
3099 3085 damage = mulH * (float)psDroid->sDisplay.screenR;// (((psDroid->sDisplay.screenR*10000)/100)*damage)/10000;
3100 3086 if (damage > psDroid->sDisplay.screenR)
  3087 + {
3101 3088 damage = psDroid->sDisplay.screenR;
  3089 + }
3102 3090
3103 3091 damage *=2;
3104 3092 scrX = psDroid->sDisplay.screenX;
3105 3093 scrY = psDroid->sDisplay.screenY;
3106 3094 scrR = psDroid->sDisplay.screenR;
3107 3095
3108   - /* Yeah, yeah yeah - hardcoded palette entries - need to change to #defined colour names */
3109   - /* Three DFX clips properly right now - not sure if software does */
3110   -// if((scrX+scrR)>0 && (scrY+scrR)>0 && (scrX-scrR)<DISP_WIDTH
3111   -// && (scrY-scrR)<DISP_HEIGHT)
3112   - {
3113   - if(!driveModeActive() || driveIsDriven(psDroid)) {
  3096 + if(!driveModeActive() || driveIsDriven(psDroid)){
3114 3097 boxCol = WZCOL_WHITE;
3115 3098 } else {
3116 3099 boxCol = WZCOL_GREEN;
@@ -3140,7 +3123,6 @@ static void drawDroidSelections( void )
3140 3123 drawDroidCmndNo(psDroid);
3141 3124 drawDroidGroupNumber(psDroid);
3142 3125 }
3143   - }
3144 3126
3145 3127 for (i = 0;i < psDroid->numWeaps;i++)
3146 3128 {
@@ -3214,7 +3196,6 @@ static void drawDroidSelections( void )
3214 3196 scrY = psDroid->sDisplay.screenY;
3215 3197 scrR = psDroid->sDisplay.screenR;
3216 3198
3217   - /* Yeah, yeah yeah - hardcoded palette entries - need to change to #defined colour names */
3218 3199 /* Three DFX clips properly right now - not sure if software does */
3219 3200 if ( (scrX + scrR) > 0
3220 3201 && (scrX - scrR) < pie_GetVideoBufferWidth()
@@ -3227,14 +3208,10 @@ static void drawDroidSelections( void )
3227 3208 boxCol = WZCOL_GREEN;
3228 3209 }
3229 3210
3230   - //we always want to show the enemy health/resistance as energyBar - AB 18/06/99
3231   - //if(bEnergyBars)
3232   - {
3233 3211 /* Power bars */
3234 3212 pie_BoxFill(scrX - scrR - 1, scrY + scrR + 2, scrX + scrR + 1, scrY + scrR + 6, WZCOL_RELOAD_BACKGROUND);
3235 3213 pie_BoxFill(scrX - scrR, scrY + scrR+3, scrX - scrR + damage, scrY + scrR + 4, powerCol);
3236 3214 pie_BoxFill(scrX - scrR, scrY + scrR+4, scrX - scrR + damage, scrY + scrR + 5, powerColShadow);
3237   - }
3238 3215 }
3239 3216 }
3240 3217 }
@@ -3657,7 +3634,6 @@ static void processDestinationTarget( void )
3657 3634 SWORD offset;
3658 3635 SWORD x0,y0,x1,y1;
3659 3636
3660   -
3661 3637 if(bDestTargetting)
3662 3638 {
3663 3639 if( (realTime - lastDestAssignation) < DEST_TARGET_TIME)
@@ -3777,7 +3753,6 @@ static void structureEffectsPlayer( UDWORD player )
3777 3753
3778 3754 pos.x = psStructure->pos.x - xDif;
3779 3755 pos.z = psStructure->pos.y - yDif;
3780   -// pos.y = map_Height(pos.x,pos.z) + 64 + (i*20); // 64 up to get to base of spire
3781 3756 effectGiveAuxVar(50); // half normal plasma size...
3782 3757
3783 3758 addEffect(&pos,EFFECT_EXPLOSION,EXPLOSION_TYPE_LASER,false,NULL,0);
@@ -3811,7 +3786,6 @@ static void structureEffectsPlayer( UDWORD player )
3811 3786 addEffect(&pos,EFFECT_EXPLOSION, EXPLOSION_TYPE_LASER,false,NULL,0);
3812 3787 pos.x = psStructure->pos.x - xDif;
3813 3788 pos.z = psStructure->pos.y - yDif; // buildings are level!
3814   - // pos.y = map_Height(pos.x,pos.z) + psStructure->sDisplay->pos.max.y;
3815 3789 effectGiveAuxVar(30+bFXSize); // half normal plasma size...
3816 3790 addEffect(&pos,EFFECT_EXPLOSION, EXPLOSION_TYPE_LASER,false,NULL,0);
3817 3791 }
@@ -4042,17 +4016,14 @@ static void doConstructionLines( void )
4042 4016 }
4043 4017 }
4044 4018 }
4045   -
4046 4019 else if ((psDroid->action == DACTION_DEMOLISH) ||
4047 4020 (psDroid->action == DACTION_REPAIR) ||
4048 4021 (psDroid->action == DACTION_RESTORE))
4049 4022 {
4050   - if(psDroid->psActionTarget[0])
  4023 + if (psDroid->psActionTarget[0]
  4024 + && psDroid->psActionTarget[0]->type == OBJ_STRUCTURE)
4051 4025 {
4052   - if(psDroid->psActionTarget[0]->type == OBJ_STRUCTURE)
4053   - {
4054   - addConstructionLine(psDroid, (STRUCTURE*)psDroid->psActionTarget[0]);
4055   - }
  4026 + addConstructionLine(psDroid, (STRUCTURE*)psDroid->psActionTarget[0]);
4056 4027 }
4057 4028 }
4058 4029 }

0 comments on commit fa49677

Please sign in to comment.
Something went wrong with that request. Please try again.