home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / rpc / mazelord / bitmap.c next >
C/C++ Source or Header  |  1995-06-06  |  20KB  |  671 lines

  1. /***********************************************************************
  2. File:   BitMap.c
  3. Date:   5-23-92
  4.  
  5.  
  6. Abstract:
  7.  
  8.     This file contains functions pertaining to drawing a bitmap on the screen.
  9.  
  10. Contents:
  11.  
  12.     FadePic() -- Slowly fade a picture on the screen to the background
  13.     DrawClippedPic() -- Draw a picture, clipped to a specified rectangle
  14.     NewFullPic() -- Create a record of type FullPicType
  15.     DeleteFullPic() -- Delete a record of type FullPicType
  16.     AddPic() -- Load a new picture bitmap set
  17.     DelPic() -- Remove a picture bitmap set from memory.
  18.  
  19.  
  20. Revision History:
  21.  
  22.  
  23. ************************************************************************/
  24. #include "winmaze.h"
  25. #include "mazproto.h"
  26.  
  27. #define MASKROP(fore,back) (DWORD)(((back << 8)&0xFF000000) | fore)
  28. #define MASKROP2(black,white) (DWORD)(((black << 8)&0xFF000000) | white) & 0xFFFF0000
  29.  
  30.  
  31.  
  32.  
  33. //
  34. // PicSpec goes:
  35. //      Base BM filename, iPicNum for the picture, offsets for each facing:
  36. //              {width, depth, left offset, top offset}
  37. //
  38. PicSpecType PicSpec[] = {
  39.    {"FISH", PIC_FISH,
  40.         {
  41.             {35,41,30,42},
  42.             {62,35,15,49},
  43.             {21,31,36,51},
  44.             {62,31,21,53}
  45.         }},
  46.    {"ROBO", PIC_ROBOT,
  47.         {
  48.             {40,107,19,43},
  49.             {50,107,13,43},
  50.             {43,106,23,44},
  51.             {48,107,30,43}
  52.         }},
  53.    {"SMIL", PIC_SMILEY,
  54.         {
  55.             {62,62,17,40},
  56.             {68,62,17,40},
  57.             {62,62,17,40},
  58.             {70,62,9,40}
  59.         }},
  60.    {"REAP", PIC_REAPER,
  61.         {
  62.             {90,114,5,26},
  63.             {85,114,8,26},
  64.             {90,114,5,26},
  65.             {85,114,8,26}
  66.         }}
  67.    };
  68.  
  69. int iNumPicSpecs = sizeof(PicSpec) / sizeof(PicSpecType);
  70.  
  71.  
  72.  
  73.  
  74.  
  75. /*=====================================================================
  76. Function: FadePic()
  77.  
  78. Inputs: Picture #, facing, and clipping rectangle to fade.
  79.  
  80. Outputs:none
  81.  
  82. Abstract:
  83.     Fade will fade out a given bitmap by XORing its bitmap with a 50% grey tone.
  84. ======================================================================*/
  85.  
  86. void FadePic(
  87.     int iPicNum,
  88.     BYTE bFacing,
  89.     HDC hDC,
  90.     LPRECT lprFrom,
  91.     LPRECT lprDRect
  92.     )
  93. {
  94.     FullPicType FAR *fptTrav;
  95.     BOOL bFound;
  96.     HDC hFadeDC,hMaskDC,hbmFadeDC;
  97.     HBITMAP hbmFade;
  98.     int DestWidth,DestHeight,SrcWidth,SrcHeight;
  99.     int iRelDirIndex,i,j;
  100.  
  101.  
  102.     fptTrav = &fptPic;
  103.     bFound = FALSE;
  104.  
  105.     iRelDirIndex=2;
  106.     while(bFacing != ptSelf.Pos.Facing) {
  107.         iRelDirIndex = (iRelDirIndex+1)%4;
  108.         bFacing = LEFT_TO_ABS(bFacing);
  109.         }
  110.  
  111.     while(fptTrav->next != NULL) {
  112.         fptTrav = fptTrav->next;
  113.         if (fptTrav->iPicNum == iPicNum) {
  114.             bFound = TRUE;
  115.             break;
  116.             }
  117.         }
  118.  
  119.     if (bFound) {
  120.         hMaskDC = CreateCompatibleDC(hDC);
  121.         hFadeDC = CreateCompatibleDC(hDC);
  122.         hbmFadeDC = CreateCompatibleDC(hFadeDC);
  123.         SrcWidth = lprFrom->right-lprFrom->left+1;
  124.         SrcHeight = lprFrom->bottom-lprFrom->top+1;
  125.         DestWidth = lprDRect->right-lprDRect->left+1;
  126.         DestHeight = lprDRect->bottom-lprDRect->top+1;
  127.         hbmFade = CreateCompatibleBitmap(hFadeDC,DestWidth,DestHeight);
  128.         SelectObject(hbmFadeDC,hbmFade);
  129.         SelectObject(hFadeDC,hFadeBM[0]);
  130.         SelectObject(hMaskDC,fptTrav->M[iRelDirIndex].hBitmap);
  131.  
  132.         //
  133.         // Copy the Fade pattern into the Fade Bitmap
  134.         //
  135.         for(i=0;i<DestWidth;i+=PIC_X) {
  136.             for(j=0;j<DestHeight;j+=PIC_Y) {
  137.                 BitBlt(hbmFadeDC,i,j,
  138.                        ((i+PIC_X)<=DestWidth) ? PIC_X : DestWidth,
  139.                        ((j+PIC_Y)<=DestHeight) ? PIC_Y : DestHeight,
  140.                        hFadeDC,0,0,
  141.                        SRCCOPY);
  142.                 }
  143.             }
  144.  
  145.         //
  146.         // StretchBlt the mask onto the fade
  147.         //
  148.         StretchBlt(hbmFadeDC,0,0,DestWidth,DestHeight,
  149.                    hMaskDC,0,0,SrcWidth,SrcHeight,
  150.                    NOTSRCERASE);
  151.  
  152.         //
  153.         // BitBlt the result onto the screen.
  154.         //
  155.         BitBlt(hDC,lprDRect->left,lprDRect->top,DestWidth,DestHeight,
  156.                hbmFadeDC,0,0,
  157.                SRCPAINT);
  158.  
  159.         DeleteDC(hFadeDC);
  160.         DeleteDC(hMaskDC);
  161.         DeleteDC(hbmFadeDC);
  162.         DeleteObject(hbmFade);
  163.         DeleteObject(hFadeBM[0]);
  164.         hFadeBM[0] = LoadBitmap(hInst,(LPCTSTR)((0)?"FADE2":"FADE1"));
  165.  
  166.         }
  167.  
  168.     return;
  169.  
  170. }
  171.  
  172.  
  173.  
  174.  
  175. /*=====================================================================
  176. Function: DrawClippedPic()
  177.  
  178. Inputs: Picture #, Relative facing, clip/dest rectangles,
  179.  
  180. Outputs:none
  181.  
  182. Abstract:
  183.     DrawClippedPic will draw the portions of picture # iPicNum visible through
  184.     the clipping window.  Player bitmaps smaller than a full panel in size
  185.     Will need to be scaled.
  186. ======================================================================*/
  187.  
  188. void DrawClippedPic(
  189.     int iPicNum,
  190.     BYTE bFacingIndex,
  191.     HDC hDC,
  192.     LPRECT lprDRect,
  193.     LPRECT lprClip,
  194.     LPRECT lprFrom,
  195.     int iRelx,
  196.     int iRely
  197.     )
  198.  
  199. {
  200.     RECT rSrc;
  201.     FullPicType FAR *fptTrav;
  202.     BOOL bFound;
  203.     HDC hPicDC,hMaskDC;
  204.     int DestWidth,DestHeight;
  205.     POINT pBlt[3];
  206.     //
  207.     // the floats are offset ratio's, ie percentage of the total
  208.     // width/depth to add to each side of the source rect.
  209.     //
  210.     float sWidth,sDepth,dWidth,dDepth;
  211.     float fRelScaling;
  212.  
  213.     if (lprClip->right < lprClip->left+2) {
  214.         return;
  215.         }
  216.  
  217.     fptTrav = &fptPic;
  218.     bFound = FALSE;
  219.  
  220.     //
  221.     // Check to see if the Picture we're supposed to draw has been loaded.
  222.     //
  223.     AddPic(iPicNum);
  224.  
  225.     while(fptTrav->next != NULL) {
  226.         fptTrav = fptTrav->next;
  227.         if (fptTrav->iPicNum == iPicNum) {
  228.             bFound = TRUE;
  229.             break;
  230.             }
  231.         }
  232.  
  233.     if (bFound) {
  234.  
  235.         //
  236.         // bFound will now indicates whether the picture has been pre-stretched
  237.         //
  238.  
  239.         bFound = (PreStretch[iPicNum][iRely].P[bFacingIndex].hBitmap != (HANDLE) NULL);
  240.         bFound = bFound && (PreStretch[iPicNum][iRely].M[bFacingIndex].hBitmap != (HANDLE) NULL);
  241.  
  242.         //
  243.         // We'll need the source dimensions whether it's prestretched or not.
  244.         //
  245.         if (bFound) {
  246.             sWidth = (float) PreStretch[iPicNum][iRely].P[bFacingIndex].xSize;
  247.             sDepth = (float) PreStretch[iPicNum][iRely].P[bFacingIndex].ySize;
  248.             }
  249.         else {
  250.             sWidth = (float) fptTrav->P[bFacingIndex].xSize;
  251.             sDepth = (float) fptTrav->P[bFacingIndex].ySize;
  252.             }
  253.  
  254.         //
  255.         // Assume that we want the ENTIRE source bitmap.
  256.         //
  257.         rSrc.left = 0;
  258.         rSrc.top = 0;
  259.         rSrc.right = (INT) sWidth-1;
  260.         rSrc.bottom = (INT) sDepth-1;
  261.  
  262.         //
  263.         // fRelScaling*an offset gives # of pixels of REAL offset.
  264.         //
  265.         fRelScaling = ((float) (lprDRect->bottom - lprDRect->top))/(float)PIC_Y;
  266.  
  267.         if (bFound) {
  268.             lprDRect->left += PreStretch[iPicNum][iRely].P[bFacingIndex].xOrg;
  269.             lprDRect->top += PreStretch[iPicNum][iRely].P[bFacingIndex].yOrg;
  270.             lprDRect->right = lprDRect->left + (int) sWidth;
  271.             lprDRect->bottom = lprDRect->top + (int) sDepth;
  272.             }
  273.         else {
  274.             lprDRect->left += (int) (fRelScaling*fptTrav->P[bFacingIndex].xOrg);
  275.             lprDRect->top += (int) (fRelScaling*fptTrav->P[bFacingIndex].yOrg);
  276.             lprDRect->right = lprDRect->left + (int) (fRelScaling*sWidth);
  277.             lprDRect->bottom = lprDRect->top + (int) (fRelScaling*sDepth);
  278.             }
  279.  
  280.         dWidth = (float) lprDRect->right - lprDRect->left;
  281.         dDepth = (float) lprDRect->bottom - lprDRect->top;
  282.  
  283.         //
  284.         // Rather than doing a clipped bitblt, we just modify the source
  285.         // rectangle to be the parts which are visible.
  286.         //
  287.         if (lprDRect->left < lprClip->left) {
  288.             rSrc.left += (LONG) (sWidth*((float) (lprClip->left - lprDRect->left))/dWidth);
  289.             lprDRect->left = lprClip->left;
  290.             }
  291.         if (lprDRect->top < lprClip->top) {
  292.             rSrc.top += (LONG) (sDepth*((float) lprClip->top - lprDRect->top)/dDepth);
  293.             lprDRect->top = lprClip->top;
  294.             }
  295.         if (lprDRect->right > lprClip->right) {
  296.             rSrc.right += (LONG) (sWidth*((float) lprClip->right - lprDRect->right)/dWidth);
  297.             lprDRect->right = lprClip->right;
  298.             }
  299.         if (lprDRect->bottom > lprClip->bottom) {
  300.             rSrc.bottom += (LONG) (sDepth*((float) lprClip->bottom - lprDRect->bottom)/dDepth);
  301.             lprDRect->bottom = lprClip->bottom;
  302.             }
  303.         //
  304.         // Set the Dest variables to the TRUE physical dest width/depth
  305.         //
  306.         DestWidth = lprDRect->right - lprDRect->left;
  307.         DestHeight = lprDRect->bottom - lprDRect->top+1;
  308.  
  309.         if ((DestWidth < 1)||(DestHeight < 1)) {
  310.             return;
  311.             }
  312.  
  313.         hPicDC = CreateCompatibleDC(hDC);
  314.         hMaskDC = CreateCompatibleDC(hPicDC);
  315.  
  316.         if (bFound) {
  317.             //
  318.             // If the bitmaps are pre-stretched...
  319.             //
  320.  
  321.             SelectObject(hPicDC,PreStretch[iPicNum][iRely].P[bFacingIndex].hBitmap);
  322.             SelectObject(hMaskDC,PreStretch[iPicNum][iRely].M[bFacingIndex].hBitmap);
  323.  
  324.             BitBlt(hDC,lprDRect->left,lprDRect->top,DestWidth,DestHeight,
  325.                    hMaskDC,rSrc.left,rSrc.top,
  326.                    SRCAND);
  327.             BitBlt(hDC,lprDRect->left,lprDRect->top,DestWidth,DestHeight,
  328.                    hPicDC,rSrc.left,rSrc.top,
  329.                    SRCPAINT);
  330.             }
  331.         else {
  332.             //
  333.             // If the bitmaps are NOT pre-stretched.
  334.             //
  335.             SelectObject(hPicDC,fptTrav->P[bFacingIndex].hBitmap);
  336.             SelectObject(hMaskDC,fptTrav->M[bFacingIndex].hBitmap);
  337.             //
  338.             // stretch the mask onto the screen
  339.             //
  340.             pBlt[0].x = lprDRect->left;
  341.             pBlt[0].y = lprDRect->top;
  342.             pBlt[1].x = lprDRect->right;
  343.             pBlt[1].y = lprDRect->top;
  344.             pBlt[2].x = lprDRect->left;
  345.             pBlt[2].y = lprDRect->bottom;
  346.  
  347.             StretchBlt(hDC,lprDRect->left,lprDRect->top,DestWidth,DestHeight,
  348.                        hMaskDC,rSrc.left,rSrc.top,rSrc.right-rSrc.left+1,rSrc.bottom-rSrc.top+1,
  349.                        SRCAND);
  350.             //
  351.             // then the picture as well
  352.             //
  353.             StretchBlt(hDC,lprDRect->left,lprDRect->top,DestWidth,DestHeight,
  354.                        hPicDC,rSrc.left,rSrc.top,rSrc.right-rSrc.left+1,rSrc.bottom-rSrc.top+1,
  355.                        SRCPAINT);
  356.             }
  357.  
  358.         DeleteDC(hPicDC);
  359.         DeleteDC(hMaskDC);
  360.         }
  361.     else {
  362.         MessageBox(NULL,"Unknown Picture Draw Requested","DrawClippedPic",
  363.                    MB_ICONEXCLAMATION|MB_APPLMODAL);
  364.         }
  365.  
  366.     *lprFrom = rSrc;
  367.  
  368.     return;
  369. }
  370.  
  371.  
  372.  
  373.  
  374. /*=====================================================================
  375. Function: NewFullPic()
  376.  
  377. Inputs: Picture # to load, pointer to next
  378.  
  379. Outputs:Returns a pointer to an initialized FullPicType data structure
  380.  
  381. Abstract:
  382. ======================================================================*/
  383.  
  384. FullPicType FAR *NewFullPic(
  385.     int iPicNum,
  386.     FullPicType FAR *next
  387.     )
  388. {
  389.     FullPicType FAR *fptTemp;
  390.     int i;
  391.     HANDLE hMem;
  392.  
  393.     hMem = GlobalAlloc(GHND,sizeof(FullPicType));
  394.     fptTemp = (FullPicType FAR *) GlobalLock(hMem);
  395.     if (fptTemp == NULL) {
  396.         MessageBox((HANDLE)NULL,"Out of memory: unable to create NewFullPic.","NewFullPic",
  397.                MB_ICONEXCLAMATION|MB_APPLMODAL);
  398.         }
  399.     else {
  400.         for(i=0;i<4;i++) {
  401.             fptTemp->P[i].hBitmap = (HANDLE) NULL;
  402.             fptTemp->P[i].xSize = PicSpec[iPicNum].PicPos[i].xSize;
  403.             fptTemp->P[i].ySize = PicSpec[iPicNum].PicPos[i].ySize;
  404.             fptTemp->P[i].xOrg = PicSpec[iPicNum].PicPos[i].xOrg;
  405.             fptTemp->P[i].yOrg = PicSpec[iPicNum].PicPos[i].yOrg;
  406.             fptTemp->M[i].hBitmap = (HANDLE) NULL;
  407.             fptTemp->M[i].xSize = PicSpec[iPicNum].PicPos[i].xSize;
  408.             fptTemp->M[i].ySize = PicSpec[iPicNum].PicPos[i].ySize;
  409.             fptTemp->M[i].xOrg = PicSpec[iPicNum].PicPos[i].xOrg;
  410.             fptTemp->M[i].yOrg = PicSpec[iPicNum].PicPos[i].yOrg;
  411.             }
  412.         fptTemp->iPicNum = iPicNum;
  413.         fptTemp->next = next;
  414.         }
  415.  
  416.     return(fptTemp);
  417.  
  418. }
  419.  
  420.  
  421.  
  422. /*=====================================================================
  423. Function: DeleteFullPic()
  424.  
  425. Inputs: pointer to FullPicType to free
  426.  
  427. Outputs:Returns pointer to ->next element of deleted pic.
  428.  
  429. Abstract:
  430. ======================================================================*/
  431.  
  432. FullPicType FAR *DeleteFullPic(
  433.     FullPicType FAR *fptTrav
  434.     )
  435. {
  436.     int i;
  437.     FullPicType FAR *fptTemp;
  438.     HANDLE hMem;
  439.  
  440.     if (fptTrav == NULL) {
  441.         fptTemp = fptTrav;
  442.         }
  443.     else {
  444.         fptTemp = fptTrav->next;
  445.  
  446.         for (i=0;i<4;i++) {
  447.             if (fptTrav->P[i].hBitmap != (HANDLE) NULL) {
  448.                 DeleteObject(fptTrav->P[i].hBitmap);
  449.                 }
  450.             if (fptTrav->M[i].hBitmap != (HANDLE) NULL) {
  451.                 DeleteObject(fptTrav->M[i].hBitmap);
  452.                 }
  453.             }
  454.  
  455.         hMem = (HGLOBAL) GlobalHandle(SELECTOROF(fptTrav));
  456.         GlobalUnlock(hMem);
  457.         GlobalFree(hMem);
  458.         }
  459.  
  460.     return(fptTemp);
  461. }
  462.  
  463.  
  464.  
  465.  
  466. /*=====================================================================
  467. Function: AddPic()
  468.  
  469. Inputs: Picture # to load
  470.  
  471. Outputs:Returns success/failure.
  472.  
  473. Abstract:
  474.     AddPic will take care of loading in a given picture's bitmap, if it isn't
  475.     already in the fptPic list. If the specified type of picture can't be found,
  476.     FALSE is returned.  Note that when we load a picture, we also make sure
  477.     that it is restricted to the confines of its mask by turning everything
  478.     outside the mask BLACK. This is necessary for drawing as well.
  479. ======================================================================*/
  480.  
  481. BOOL AddPic(
  482.     int iPicNum
  483.     )
  484. {
  485.     char cDirs[4] = {'F','L','B','R'};
  486.     FullPicType FAR *fptTrav;
  487.     BOOL bFound;
  488.     int i,j;
  489.     char cBitmapName[32];
  490.     HDC hDC,hPicDC,hMaskDC;
  491.  
  492.     fptTrav = &fptPic;
  493.     bFound = FALSE;
  494.  
  495.     //
  496.     // Look to see if the picture's already been loaded into memory. If
  497.     // it has, we won't have to load it.
  498.     //
  499.     while (fptTrav->next != NULL) {
  500.         fptTrav = fptTrav->next;
  501.  
  502.         if (fptTrav->iPicNum == iPicNum) {
  503.             bFound = TRUE;
  504.             break;
  505.             }
  506.         }
  507.  
  508.     //
  509.     // If we didn't find the bitmap, we really DO need to load it.
  510.     //
  511.     if (!bFound) {
  512.  
  513.         //
  514.         // We can only load the requested picture if it's in our list of
  515.         // known pics. Check to make sure it is.
  516.         //
  517.         for(i=0;i<iNumPicSpecs;i++) {
  518.             if (PicSpec[i].iPicNum == iPicNum) {
  519.                 bFound = TRUE;
  520.                 break;
  521.                 }
  522.             }
  523.  
  524.         if (bFound) {
  525.             hDC = GetDC(hWndMaze);
  526.             hPicDC = CreateCompatibleDC(hDC);
  527.             hMaskDC = CreateCompatibleDC(hPicDC);
  528.             ReleaseDC(hWndMaze,hDC);
  529.  
  530.             fptTrav->next = NewFullPic(iPicNum,fptTrav->next);
  531.             fptTrav = fptTrav->next;
  532.             strcpy(cBitmapName,PicSpec[i].cBase);
  533.             cBitmapName[5]='\0';
  534.  
  535.             //
  536.             // Load in the bitmaps
  537.             //
  538.             for(j=0;j<4;j++) {
  539.                 cBitmapName[4]=cDirs[j];
  540.                 if (fptTrav->P[j].hBitmap != NULL) {
  541.                     DeleteObject(fptTrav->P[j].hBitmap);
  542.                 }
  543.                 fptTrav->P[j].hBitmap = LoadBitmap(hInst,(LPCTSTR)cBitmapName);
  544.                 if (fptTrav->P[j].hBitmap == (HANDLE) NULL) {
  545.                     MessageBox((HANDLE) NULL,"Unable to load bitmap","AddPic",
  546.                                MB_ICONEXCLAMATION|MB_APPLMODAL);
  547.                     bFound = FALSE;
  548.                     }
  549.                 //
  550.                 // Copy stats for the Bitmap's size/origin into the struct
  551.                 //
  552.                 fptTrav->P[j].xSize = PicSpec[i].PicPos[j].xSize;
  553.                 fptTrav->P[j].ySize = PicSpec[i].PicPos[j].ySize;
  554.                 fptTrav->P[j].xOrg = PicSpec[i].PicPos[j].xOrg;
  555.                 fptTrav->P[j].yOrg = PicSpec[i].PicPos[j].yOrg;
  556.                 }
  557.  
  558.             cBitmapName[5]='M';
  559.             cBitmapName[6]='\0';
  560.  
  561.             //
  562.             // Load in the masks for the bitmaps
  563.             //
  564.             for(j=0;j<4;j++) {
  565.                 cBitmapName[4]=cDirs[j];
  566.                 if (fptTrav->M[j].hBitmap != NULL) {
  567.                     DeleteObject(fptTrav->M[j].hBitmap);
  568.                 }
  569.                 fptTrav->M[j].hBitmap = LoadBitmap(hInst,(LPCTSTR)cBitmapName);
  570.                 if (fptTrav->M[j].hBitmap == (HANDLE) NULL) {
  571.                     MessageBox((HANDLE) NULL,"Unable to load bitmap mask","AddPic",
  572.                                 MB_ICONEXCLAMATION|MB_APPLMODAL);
  573.                     bFound = FALSE;
  574.                     }
  575.                 //
  576.                 // Copy stats for the Mask's size/origin into the struct
  577.                 //
  578.                 fptTrav->M[j].xSize = PicSpec[i].PicPos[j].xSize;
  579.                 fptTrav->M[j].ySize = PicSpec[i].PicPos[j].ySize;
  580.                 fptTrav->M[j].xOrg = PicSpec[i].PicPos[j].xOrg;
  581.                 fptTrav->M[j].yOrg = PicSpec[i].PicPos[j].yOrg;
  582.                 }
  583. /***********BUGBUG
  584.             //
  585.             // Invert the background of the bitmaps from white to black
  586.             //
  587.             for(j=0;j<4;j++) {
  588.                 SelectObject(hPicDC,fptTrav->P[j].hBitmap);
  589.                 SelectObject(hMaskDC,fptTrav->M[j].hBitmap);
  590.                 BitBlt(hPicDC,0,0,
  591.                                  PicSpec[iPicNum].PicPos[i].xSize,
  592.                                  PicSpec[iPicNum].PicPos[i].ySize,
  593.                        hMaskDC,0,0,SRCINVERT);
  594.                 }
  595. *************/
  596.  
  597.             DeleteDC(hPicDC);
  598.             DeleteDC(hMaskDC);
  599.             }
  600.         }
  601.  
  602.     return(bFound);
  603. }
  604.  
  605.  
  606.  
  607.  
  608. /*=====================================================================
  609. Function: DelPic()
  610.  
  611. Inputs: Picture # to Delete from pic list
  612.  
  613. Outputs:Returns success/failure.
  614.  
  615. Abstract:
  616.     DelPic will remove a picture, assuming that it is not being used by anyone
  617.     in ptDrones and ptPlayers, and it isn't of type PIC_DEFAULT.
  618. ======================================================================*/
  619.  
  620. BOOL DelPic(
  621.     int iPicNum
  622.     )
  623. {
  624.     FullPicType FAR *fptTrav;
  625.     BOOL bFound,bStillUsed;
  626.     PlayerType FAR *ptTrav;
  627.  
  628.  
  629.     if (iPicNum == PIC_DEFAULT) {
  630.         return(TRUE);
  631.         }
  632.  
  633.     fptTrav = &fptPic;
  634.     bFound = FALSE;
  635.  
  636.     while (fptTrav->next != NULL) {
  637.         if (fptTrav->next->iPicNum == iPicNum) {
  638.             bFound = TRUE;
  639.             bStillUsed = FALSE;
  640.  
  641.             ptTrav = &ptPlayers;
  642.             while (ptTrav->next != NULL) {
  643.             ptTrav = ptTrav->next;
  644.             if (ptTrav->iPicNum == iPicNum) {
  645.                 bStillUsed = TRUE;
  646.                 break;
  647.                 }
  648.             }
  649.  
  650.             ptTrav = &ptDrones;
  651.             while (ptTrav->next != NULL) {
  652.             ptTrav = ptTrav->next;
  653.             if (ptTrav->iPicNum == iPicNum) {
  654.                 bStillUsed = TRUE;
  655.                 break;
  656.                 }
  657.             }
  658.  
  659.             if (!bStillUsed) {
  660.                 fptTrav->next = DeleteFullPic(fptTrav->next);
  661.                 }
  662.  
  663.             break;
  664.             }
  665.  
  666.         fptTrav = fptTrav->next;
  667.         }
  668.  
  669.     return(bFound);
  670. }
  671.