DRAW.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:39k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /**********************************************************************
  2. File:   InitMaze.c
  3. Abstract:
  4.     This module contains drawing routines for MazeLords.
  5. Contents:
  6.     DelHole() --
  7.     NewHole() --
  8.     DrawRect() --
  9.     NewPlayerDraw() --
  10.     DelPlayerDraw() --
  11.     CheckForPlayers() --
  12.     DrawFoundPlayers() --
  13.     DrawMaze() --
  14.     DrawTopView() --
  15.     DrawPlayers() --
  16. Revision History:
  17. ************************************************************************/
  18. #include "winmaze.h"
  19. #include "mazproto.h"
  20. LPPOINT pDraw;
  21. LPBYTE pType;
  22. int PointCount;
  23. /**********************************************************************
  24.  *                                                                    *
  25.  * FUNCTION:  PolyDraw95(HDC, LPPOINT, LPBYTE, int)                   *
  26.  *                                                                    *
  27.  * PURPOSE:   Draws the points returned from a call to GetPath()      *
  28.  *            to an HDC                                               *
  29.  *                                                                    *
  30.  * NOTES:     This function is similar to the Windows NT PolyDraw     *
  31.  *            function, which draws a set of line segments and Bezier *
  32.  *            curves. Because PolyDraw is not supported in Windows 95 *
  33.  *            this PolyDraw95 function is used instead.               *
  34.  *                                                                    *
  35.  * MODS:      Added this function in order to provide support for     *
  36.  *            Windows 95.                                             *
  37.  *                                                                    *
  38.  *********************************************************************/
  39. BOOL PolyDraw95(HDC  hdc,              // handle of a device context
  40.                 CONST LPPOINT lppt,      // array of points
  41.                 CONST LPBYTE lpbTypes, // line and curve identifiers
  42.                 int  cCount)             // count of points
  43. {
  44.   int i;
  45.   for (i=0; i<cCount; i++)
  46.     switch (lpbTypes[i]) {
  47.       case PT_MOVETO :
  48.          MoveToEx(hdc, lppt[i].x, lppt[i].y, NULL);
  49.          break;
  50.       case PT_LINETO | PT_CLOSEFIGURE:
  51.       case PT_LINETO :
  52.          LineTo(hdc, lppt[i].x, lppt[i].y);
  53.          break;
  54.       case PT_BEZIERTO | PT_CLOSEFIGURE:
  55.       case PT_BEZIERTO :
  56.         PolyBezierTo(hdc, &lppt[i], 3);
  57.        i+=2;
  58.          break;
  59.     }
  60.    return TRUE;
  61. }
  62. //
  63. // convert an offset to an increment to add.
  64. //
  65. #define ABS2OFFX(x,y,Facing) (((Facing)&NORTH) ? (x) : 
  66.                               ((Facing)&SOUTH) ? -(x) : 
  67.                               ((Facing)&EAST) ? (y) : -(y))
  68. #define ABS2OFFY(x,y,Facing) (((Facing)&NORTH) ? -(y) : 
  69.                               ((Facing)&SOUTH) ? (y) : 
  70.                               ((Facing)&EAST) ? (x) : -(x))
  71. /*=====================================================================
  72. Function: DelHole()
  73. Inputs: Pointer to HoleType record to delete
  74. Outputs: Returns ->next field of deleted record
  75. Abstract:
  76.     Deletes a record of type HoleType, returns ->next pointer to
  77.     facilitate list maintenance
  78. ======================================================================*/
  79. HoleType FAR *DelHole(
  80.     HoleType FAR *h
  81.     )
  82. {
  83.     HoleType FAR *t;
  84.     HANDLE hMem;
  85.     if (h == NULL) {
  86.         return((HoleType FAR *) NULL);
  87.         }
  88.     else {
  89.         hMem = (HGLOBAL) GlobalHandle(SELECTOROF( h));
  90.         t = h->next;
  91.         GlobalUnlock(hMem);
  92.         GlobalFree(hMem);
  93.         return(t);
  94.         }
  95. }
  96. /*=====================================================================
  97. Function: NewHole()
  98. Inputs: HoleType element values
  99. Outputs:Returns a pointer to a new initialized HoleType record
  100. Abstract:
  101.     No explanation needed
  102. ======================================================================*/
  103. HoleType FAR *NewHole(
  104.     int x1,
  105.     int x2,
  106.     HoleType FAR *next
  107.     )
  108. {
  109.     HoleType FAR *h;
  110.     HANDLE hMem;
  111.     hMem =  GlobalAlloc(GHND,sizeof(HoleType));
  112.     h = (HoleType FAR *) GlobalLock(hMem);
  113.     if (h == (HoleType FAR *) NULL) {
  114.         MessageBox((HANDLE) NULL,GetStringRes(IDS_MALLOCQUIT), NULL ,MB_ICONEXCLAMATION);
  115.         exit(0);
  116.         }
  117.     h->x[0] = x1;
  118.     h->x[1] = x2;
  119.     h->next = next;
  120.     return(h);
  121. }
  122. /*=====================================================================
  123. Function: DrawRect()
  124. Inputs: Hole List (determining what is visible),
  125.     relative x and y coordinates of wall to draw,
  126.     relative facing of wall to draw
  127. Outputs: Modifies hole list, returns a pointer to where hole processing
  128.     should resume from
  129. Abstract:
  130.     DrawRect expects to draw a wall for the coordinate (iRelX,iRelY) relative
  131.     facing bRelDir.
  132.     For clipping, suppose we have
  133.           xr
  134.           |
  135.       p1|---
  136.         |   ---    xs
  137.         |      --- |
  138.         |         --- p4
  139.         |            |
  140.         |            |
  141.         |            |
  142.         |         --- p3
  143.         |      ---
  144.         |   ---
  145.       p2|---
  146.     where (p1 to p4) are known endpoints for a panel, and xr and xs are
  147.     vertical clipping lines (fortunately we're restricted to these.
  148.     The new dimensions for p1-p4 are easy to calculate, since, it is a matter
  149.     of similar triangles:
  150.         |         ---. p3
  151.         |      --- ; .
  152.         |   ---    ; .
  153.       p2|---..........
  154.                    ;
  155.                    xs
  156.     We need to recalculate p3, since it is past the clipping boundary. By
  157.     similar triangles, we know  (p3.y-p2.y)/(p3.x-p2.x) = (xs.y-p2.y)/(xs.x-p2.x).
  158.     This in turn gives us xs.y = (p3.y-p2.y)*(xs.x-p2.x)/(p3.x-p2.x) + p2.y. This
  159.     can be applied to all four endpoints.
  160. ======================================================================*/
  161. HoleType FAR *DrawRect(
  162.     HoleType FAR *htTrav,
  163.     int iRelX,
  164.     int iRelY,
  165.     BYTE bRelDir
  166.     )
  167. {
  168.     POINT p[4];
  169.     int i,rb;
  170.     int ihLeft,ihRight;
  171.     BOOL bIsLeftSide;
  172.     bIsLeftSide = (iRelX < 0);
  173.     if ((htTrav == NULL)||(htTrav->next == NULL)) {
  174.         return(NULL);
  175.         }
  176.     ihLeft = htTrav->next->x[0];
  177.     ihRight= htTrav->next->x[1];
  178.     if (ihLeft >= ihRight) {
  179.         return(htTrav->next);
  180.         }
  181.     //
  182.     //p1=p[0],p2=p[1],p4=p[2],p3=p[3] from diagram above.
  183.     //
  184.     switch(bRelDir) {
  185.         //
  186.         // Wall furthest away from us
  187.         //
  188.         case NORTH:
  189.             for(i=0;i<2;i++) {
  190.                 p[i] = pPost[iRelX+MAX_DRAW_DIST+1][iRelY+1][i];
  191.                 p[i+2] = pPost[iRelX+MAX_DRAW_DIST+2][iRelY+1][i];
  192.                 }
  193.             break;
  194.         //
  195.         // Wall closest to us
  196.         //
  197.         case SOUTH:
  198.             for(i=0;i<2;i++) {
  199.                 p[i] = pPost[iRelX+MAX_DRAW_DIST+1][iRelY][i];
  200.                 p[i+2] = pPost[iRelX+MAX_DRAW_DIST+2][iRelY][i];
  201.                 }
  202.             break;
  203.         //
  204.         // West ==> we're working on the left side of the screen
  205.         //
  206.         case WEST:
  207.             for(i=0;i<2;i++) {
  208.                 p[i] = pPost[iRelX+MAX_DRAW_DIST+1][iRelY][i];
  209.                 p[i+2] = pPost[iRelX+MAX_DRAW_DIST+1][iRelY+1][i];
  210.                 }
  211.             break;
  212.         //
  213.         // East ==> we're working on the right side of the screen
  214.         //
  215.         case EAST:
  216.             for(i=0;i<2;i++) {
  217.                 p[i] = pPost[iRelX+MAX_DRAW_DIST+2][iRelY+1][i];
  218.                 p[i+2] = pPost[iRelX+MAX_DRAW_DIST+2][iRelY][i];
  219.                 }
  220.             break;
  221.         }
  222.     //
  223.     // If we can see any of the panel through the hole,
  224.     // go ahead and draw it!
  225.     //
  226.     if ((p[0].x < ihRight)&&(p[2].x > ihLeft)) {
  227.         for(i=0;i<2;i++) {
  228.             //
  229.             // Clip the left side, if needed.
  230.             //
  231.             if (p[i].x < ihLeft ) {
  232.                 p[i].y = ((p[i].y-p[i+2].y)*(ihLeft-p[i+2].x)/
  233.                             (p[i].x-p[i+2].x)) + p[i+2].y;
  234.                 p[i].x = ihLeft;
  235.                 }
  236.             //
  237.             // and the right side...
  238.             //
  239.             if (p[3-i].x > ihRight) {
  240.                 p[3-i].y = ((p[3-i].y-p[1-i].y)*(ihRight-p[1-i].x)/
  241.                             (p[3-i].x-p[1-i].x)) + p[1-i].y;
  242.                 p[3-i].x = ihRight;
  243.                 }
  244.             }
  245.         //
  246.         // Now we need to add these points into the draw list.
  247.         //
  248.         pType[PointCount]=PT_MOVETO;
  249.         pDraw[PointCount++]=p[0];
  250.         pType[PointCount]=PT_LINETO;
  251.         pDraw[PointCount++]=p[1];
  252.         pType[PointCount]=PT_LINETO;
  253.         pDraw[PointCount++]=p[3];
  254.         pType[PointCount]=PT_LINETO;
  255.         pDraw[PointCount++]=p[2];
  256.         pType[PointCount]=PT_LINETO;
  257.         pDraw[PointCount++]=p[0];
  258.         if (p[0].x == ihLeft) {
  259.             if (p[2].x == ihRight) {
  260.                 //
  261.                 // If left and right match exactly, delete hole.
  262.                 //
  263.                 htTrav->next = DelHole(htTrav->next);
  264.                 }
  265.             else {
  266.                 //
  267.                 // if left matches, but right doesn't, set hole to rt,rt
  268.                 //
  269.                 htTrav->next->x[0] = p[2].x;
  270.                 }
  271.             }
  272.         else {
  273.             //
  274.             // if the left doesn't match, at the very least we need
  275.             // to keep the left to the current spot.
  276.             //
  277.             rb = htTrav->next->x[1];
  278.             htTrav->next->x[1] = p[0].x;
  279.             if (p[2].x != rb) {
  280.                 //
  281.                 // Also, if the right side didn't match up, we need to
  282.                 // create a new hole.
  283.                 //
  284.                 // need to make sure the hole won't get skipped as we
  285.                 // continue processing inside to outside...
  286.                 //
  287.                 if (bIsLeftSide) {
  288.                     htTrav->next = NewHole(p[2].x,rb,htTrav->next);
  289.                     }
  290.                 else {
  291.                     htTrav->next->next = NewHole(p[2].x,rb,htTrav->next->next);
  292.                     }
  293.                 }
  294.             }
  295.         }
  296.     return(htTrav);
  297. }
  298. /*=====================================================================
  299. Function: NewPlayerDraw()
  300. Inputs: PlayerDrawType record element values
  301. Outputs: Pointer to a new, initialized record of type PlayerDrawType
  302. Abstract:
  303.     No explanation needed.
  304. ======================================================================*/
  305. PlayerDrawType FAR *NewPlayerDraw(
  306.     PlayerType FAR *p,
  307.     LPRECT rDraw,
  308.     LPRECT rClip,
  309.     int iRelx,
  310.     int iRely,
  311.     PlayerDrawType FAR *next
  312.     )
  313. {
  314.     PlayerDrawType FAR *pdtRet;
  315.     HGLOBAL hMem;
  316.     hMem = GlobalAlloc(GHND,(sizeof(PlayerDrawType)));
  317.     pdtRet = (PlayerDrawType FAR *) GlobalLock(hMem);
  318.     if (pdtRet == NULL) {
  319.         MessageBox((HWND) NULL,GetStringRes(IDS_MALLOCFAIL),"NewPlayerDraw",
  320.                    MB_APPLMODAL|MB_ICONEXCLAMATION);
  321.         }
  322.     else {
  323.         pdtRet->p = p;
  324.         pdtRet->rDraw = *rDraw;
  325.         pdtRet->rClip = *rClip;
  326.         pdtRet->iRelx = iRelx;
  327.         pdtRet->iRely = iRely;
  328.         pdtRet->next = next;
  329.         }
  330.     return(pdtRet);
  331. }
  332. /*=====================================================================
  333. Function: DelPlayerDraw()
  334. Inputs: Pointer to PlayerDrawType record to delete
  335. Outputs: Pointer to ->next field value of deleted record
  336. Abstract:
  337.     returns the ->next field for linked list maintenance
  338. ======================================================================*/
  339. PlayerDrawType FAR *DelPlayerDraw(
  340.     PlayerDrawType FAR *pdtP
  341.     )
  342. {
  343.     PlayerDrawType FAR *pdtRet;
  344.     HGLOBAL hMem;
  345.     pdtRet = NULL;
  346.     if (pdtP != NULL) {
  347.         pdtRet = pdtP->next;
  348.         hMem = (HGLOBAL) GlobalHandle(SELECTOROF(pdtP));
  349.         GlobalFree(hMem);
  350.         }
  351.     return(pdtRet);
  352. }
  353. /*=====================================================================
  354. Function: CheckForPlayers()
  355. Inputs: List of players, holes in view, positions to check
  356. Outputs:
  357. Abstract:
  358.     This routine checks for players on a single square, given the relative
  359.     and absolute coordinates of that square. If a player IS on that square,
  360.     then we check the hole we're looking through to see if any of the
  361.     destination rectangle is visible. If it is, we make a note of the player
  362.     by adding them to the pdtTD = 'Players To Draw' list.
  363. ======================================================================*/
  364. void CheckForPlayers(
  365.     PlayerDrawType FAR *pdtTD,
  366.     PlayerType FAR *ptObj,
  367.     HoleType FAR *htHole,
  368.     int iRelx,
  369.     int iRely,
  370.     int iAbsx,
  371.     int iAbsy
  372.     )
  373. {
  374.     PlayerType FAR *ptTrav;
  375.     RECT rDraw,rClip;
  376.     float x,y,z;
  377.     int xSize,ySize;
  378.     POINT pCenter;
  379.     if (htHole == NULL) {
  380.         return;
  381.         }
  382.     GetClientRect(hWndMaze,&rMaze);
  383.     pCenter.x = rMaze.left + (rMaze.right-rMaze.left)/2;
  384.     pCenter.y = rMaze.top + (rMaze.bottom-rMaze.top)/2;
  385.     //
  386.     // Set x/y/z to screen coordinate upper left corner of panel
  387.     //
  388.     x = (float) ((iRelx*PANEL_WIDTH) - PANEL_WIDTH/2);
  389.     y = (float) (-PANEL_HEIGHT/2);
  390. #if ( _ALPHA_ == 1 )
  391.     z = (float) iRely*PANEL_WIDTH - (PANEL_WIDTH/2);
  392. #else
  393.     z = (float) (iRely-1)*PANEL_WIDTH;
  394. #endif
  395.     //
  396.     // Calculate the physical width and depth of a panel placed at the bitmap
  397.     // location, since this is the maximum possible size for a player bitmap.
  398.     // PIC_X and PIC_Y are the pixel values for this.
  399.     //
  400.     xSize = (int) MC_TO_SC(PIC_X,z);
  401.     ySize = (int) MC_TO_SC(PIC_Y,z);
  402.     //
  403.     // Calculate the physical rectangle to contain the player bitmap
  404.     //
  405.     rDraw.left = pCenter.x + (int) MC_TO_SC(x,z);
  406.     rDraw.top  = pCenter.y + (int) MC_TO_SC(y,z);
  407.     rDraw.right = rDraw.left + xSize-1;
  408.     rDraw.bottom = rDraw.top + ySize-1;
  409.     //
  410.     // Set the clipping rectangle to the visible screen
  411.     //
  412.     rClip.left = GREATEROF(rDraw.left,0);
  413.     rClip.top = GREATEROF(rDraw.top,0);
  414.     rClip.right = LESSEROF(rDraw.right,rMaze.right);
  415.     rClip.bottom = LESSEROF(rDraw.bottom,rMaze.bottom);
  416.     //
  417.     // Adjust the clipping rectangle's left and right by the hole
  418.     // which we're constrained by (Holes are horizontal coordinates only)
  419.     //
  420.     if (htHole != (HoleType FAR *) -1) {
  421.         rClip.left = GREATEROF(rClip.left,htHole->x[0]);
  422.         rClip.right = LESSEROF(rClip.right,htHole->x[1]);
  423.         }
  424.     //
  425.     // If The whole picture is clipped, don't bother drawing it.
  426.     //
  427.     if (rClip.left >= rClip.right) {
  428.         return;
  429.         }
  430.     ptTrav=ptObj;
  431.     while (ptTrav->next != NULL) {
  432.         ptTrav = ptTrav->next;
  433.         if ((ptTrav->Pos.ix == iAbsx)&&(ptTrav->Pos.iy == iAbsy)) {
  434.             //
  435.             // We need to adjust the drawing coordinates according to this
  436.             // player's picture.
  437.             //
  438.             pdtTD->next = NewPlayerDraw(ptTrav,&rDraw,&rClip,iRelx,iRely,pdtTD->next);
  439.             }
  440.         }
  441. }
  442. /*=====================================================================
  443. Function: DrawFoundPlayers()
  444. Inputs: List of players
  445. Outputs: modifies rBounds to contain rectangle saying where player is.
  446. Abstract:
  447.     BUGBUG -- needs abstract
  448. ======================================================================*/
  449. void DrawFoundPlayers(
  450.     HDC hDC,
  451.     PlayerDrawType FAR *pdtTrav,
  452.     LPRECT rBounds
  453.     )
  454. {
  455.     BYTE dBackward,b1,b2;
  456.     dBackward = BACK_TO_ABS(ptSelf.Pos.Facing);
  457.     while (pdtTrav->next != NULL) {
  458.         b1 = BACK;
  459.         b2 = ptSelf.Pos.Facing;
  460.         while (b2 != pdtTrav->next->p->Pos.Facing) {
  461.             b1 = (BYTE) ((b1+1)%4);
  462.             b2 = RIGHT_TO_ABS(b2);
  463.             }
  464.         pdtTrav->next->p->rDrawn = pdtTrav->next->rDraw;
  465.         if (rBounds != NULL) {
  466.             rBounds->left = LESSEROF(rBounds->left,
  467.                                GREATEROF(pdtTrav->next->rDraw.left,
  468.                                          pdtTrav->next->rClip.left));
  469.             rBounds->top = LESSEROF(rBounds->top,
  470.                                GREATEROF(pdtTrav->next->rDraw.top,
  471.                                          pdtTrav->next->rClip.top));
  472.             rBounds->right = GREATEROF(rBounds->right,
  473.                                LESSEROF(pdtTrav->next->rDraw.right,
  474.                                          pdtTrav->next->rClip.right));
  475.             rBounds->bottom = GREATEROF(rBounds->bottom,
  476.                                LESSEROF(pdtTrav->next->rDraw.bottom,
  477.                                          pdtTrav->next->rClip.bottom));
  478.             }
  479.         DrawClippedPic(pdtTrav->next->p->iPicNum,b1,hDC,
  480.                        &pdtTrav->next->p->rDrawn,
  481.                        &pdtTrav->next->rClip,
  482.                        &pdtTrav->next->p->rFrom,
  483.                        pdtTrav->next->iRelx,
  484.                        pdtTrav->next->iRely);
  485.         pdtTrav->next->p->Drawn = TRUE;
  486.         pdtTrav->next->p->rDrawn.right++;
  487.         pdtTrav->next->p->rDrawn.bottom++;
  488.         pdtTrav->next = DelPlayerDraw(pdtTrav->next);
  489.         }
  490.     return;
  491. }
  492. /*=====================================================================
  493. Function: DrawMaze()
  494. Inputs: DC, rectangle that needs to be redrawn
  495. Outputs: none
  496. Abstract:
  497.     This entrypoint takes care of drawing the 3-d maze. It loops from
  498.     front to back, inside to outside, Checking for panels. It keeps a list
  499.     of all the 'holes' in panels in terms of physical coordinates. For
  500.     instance, if I've found the wall in front of me, but no others, and
  501.     I can see to the left and to the right of the wall, I would have two
  502.     holes in my hole-list. The first would be from the left of the view
  503.     window to the left side of the wall, and the second would be from the
  504.     right side of the wall to the right side of the view window.
  505. ======================================================================*/
  506. void DrawMaze(HDC hDC,LPRECT rUpd)
  507. {
  508.     int i,j,tx,ty,iEndl,iEndr;
  509.     BYTE dLeft,dRight,dForward,dBackward,b1,b2,b3;
  510.     HoleType htLeft,htRight,FAR *htTrav, FAR *htHold;
  511.     BOOL bFound;
  512.     PlayerDrawType pdtToDraw;
  513.     HBRUSH hOldBrush,hWhiteBrush;
  514.     HPEN hOldPen,hWhitePen,hBlackPen;
  515.     HGLOBAL hMem;
  516.     if ((rUpd->left >= rUpd->right)||(rUpd->top >= rUpd->bottom)) {
  517.         return;
  518.         }
  519.     hMem = GlobalAlloc(GHND,10000*sizeof(POINT));
  520.     pDraw = (LPPOINT) GlobalLock(hMem);
  521.     hMem = GlobalAlloc(GHND,10000*sizeof(BYTE));
  522.     pType = (LPBYTE) GlobalLock(hMem);
  523.     GetClientRect(hWndMaze,&rMaze);
  524.     pdtToDraw.next = NULL;
  525.     //
  526.     // Clear out the space to be drawn into
  527.     //
  528.     hWhiteBrush = GetStockObject(WHITE_BRUSH);
  529.     hWhitePen = GetStockObject(WHITE_PEN);
  530.     hBlackPen = GetStockObject(BLACK_PEN);
  531.     hOldBrush = SelectObject(hDC,hWhiteBrush);
  532.     hOldPen = SelectObject(hDC,hWhitePen);
  533.     PointCount = 0;
  534.     dForward = ptSelf.Pos.Facing;
  535.     dBackward = BACK_TO_ABS(ptSelf.Pos.Facing);
  536.     dLeft = LEFT_TO_ABS(ptSelf.Pos.Facing);
  537.     dRight = RIGHT_TO_ABS(ptSelf.Pos.Facing);
  538.     tx = ptSelf.Pos.ix;
  539.     ty = ptSelf.Pos.iy;
  540.     Rectangle(hDC,rUpd->left,rUpd->top,rUpd->right,rUpd->bottom);
  541.     SelectObject(hDC,hOldBrush);
  542.     SelectObject(hDC,hBlackPen);
  543.     //
  544.     // Find the End which lies straight before us, else default
  545.     // it to MAX_DRAW_DIST.
  546.     //
  547.     b2 = bMaze[tx][ty];
  548.     bFound = FALSE;
  549.     for(j=0,ViewEnd=MAX_DRAW_DIST-1;j<MAX_DRAW_DIST;j++) {
  550.         b1 = b2;
  551.         tx = ADJ_X(tx,ptSelf.Pos.Facing);
  552.         ty = ADJ_Y(ty,ptSelf.Pos.Facing);
  553.         b2 = bMaze[tx][ty];
  554.         if ((b1&dForward)||(b2&dBackward)) {
  555.             ViewEnd = j;
  556.             bFound = TRUE;
  557.             break;
  558.             }
  559.         }
  560.     PointCount = 0;
  561.     iEndl = iEndr = (rMaze.right - rMaze.left) / 2;
  562.     //
  563.     // Draw the end rectangle.
  564.     //
  565.     if (bFound) {
  566.         //
  567.         // Only bother with the draw if the end is to be updated
  568.         //
  569.         iEndl = pPost[MAX_DRAW_DIST+1][ViewEnd+1][0].x;
  570.         iEndr = pPost[MAX_DRAW_DIST+2][ViewEnd+1][0].x;
  571.         //
  572.         // Left Post
  573.         //
  574.         pDraw[0].x = pPost[MAX_DRAW_DIST+1][ViewEnd+1][0].x;
  575.         pDraw[0].y = pPost[MAX_DRAW_DIST+1][ViewEnd+1][0].y;
  576.         pType[0] = PT_MOVETO;
  577.         pDraw[1].x = pPost[MAX_DRAW_DIST+1][ViewEnd+1][1].x;
  578.         pDraw[1].y = pPost[MAX_DRAW_DIST+1][ViewEnd+1][1].y;
  579.         pType[1] = PT_LINETO;
  580.         //
  581.         // Right Post
  582.         //
  583.         pDraw[2].x = pPost[MAX_DRAW_DIST+2][ViewEnd+1][1].x;
  584.         pDraw[2].y = pPost[MAX_DRAW_DIST+2][ViewEnd+1][1].y;
  585.         pType[2] = PT_LINETO;
  586.         pDraw[3].x = pPost[MAX_DRAW_DIST+2][ViewEnd+1][0].x;
  587.         pDraw[3].y = pPost[MAX_DRAW_DIST+2][ViewEnd+1][0].y;
  588.         pType[3] = PT_LINETO;
  589.         pDraw[4].x = pPost[MAX_DRAW_DIST+1][ViewEnd+1][0].x;
  590.         pDraw[4].y = pPost[MAX_DRAW_DIST+1][ViewEnd+1][0].y;
  591.         pType[4] = PT_LINETO;
  592.         PointCount = 5;
  593.         }
  594.     //
  595.     // Make LeftHoles and RightHoles accordingly
  596.     //
  597.     htLeft.next = NewHole(0,iEndl,NULL);
  598.     htRight.next = NewHole(iEndr,rMaze.right-rMaze.left,NULL);
  599.     //
  600.     // For the left side, loop from front to back, right to
  601.     // left, checking the rEAST and rNORTH walls, in that
  602.     // order. Eventually we'll need to put the check for players
  603.     // in between the two. As a wall is found, draw it.
  604.     //
  605.     //
  606.     // j is the relative y-offset into the maze.
  607.     //
  608.     for(j=0;j<MAX_DRAW_DIST;j++) {
  609.         //
  610.         // Check for players/drones directly in front of us,
  611.         // make note of them to draw them later.
  612.         //
  613.         if (j < ViewEnd+1) {
  614.             CheckForPlayers(&pdtToDraw,&ptPlayers,(HoleType FAR *) -1,0,j,
  615.                       ptSelf.Pos.ix + ABS2OFFX(0,j,dForward),
  616.                       ptSelf.Pos.iy + ABS2OFFY(0,j,dForward));
  617.             CheckForPlayers(&pdtToDraw,&ptDrones,(HoleType FAR *) -1,0,j,
  618.                       ptSelf.Pos.ix + ABS2OFFX(0,j,dForward),
  619.                       ptSelf.Pos.iy + ABS2OFFY(0,j,dForward));
  620.             }
  621.         //
  622.         // b1 is the square we're in, b2 the square we want to
  623.         // see if there's a wall EAST/WEST between. b3 is the
  624.         // square we want to see if there is a NORTH/SOUTH wall
  625.         // from b2 to.  Then we move to b2 and try it again.
  626.         //
  627.         htTrav=&htLeft;
  628.         while((htTrav != (HoleType FAR *) NULL)&&(htTrav->next != (HoleType FAR *)NULL)) {
  629.             // i will loop from the 0th relative column to the far left.
  630.             // This will be done for each and every hole, or even some
  631.             // holes more than once, depending upon how they are filled.
  632.             // set (tx,ty) to spot in our x-pos with relative y j.
  633.             tx = ptSelf.Pos.ix + ABS2OFFX(0,j,dForward);
  634.             ty = ptSelf.Pos.iy + ABS2OFFY(0,j,dForward);
  635.             b2 = bMaze[tx][ty];
  636.             htHold = htTrav->next;
  637.             for (i=0;(i>= -MAX_DRAW_DIST)&&(htTrav != (HoleType FAR *)NULL)&&(htTrav->next != (HoleType FAR *)NULL);i--) {
  638.                 //
  639.                 // if we're not in the hole yet, continue
  640.                 //
  641.                 if (htTrav->next->x[1] < pPost[MAX_DRAW_DIST+i][j+1][0].x) {
  642.                    continue;
  643.                    }
  644.                 //
  645.                 // if we're past the outside of the hole, go to next hole.
  646.                 //
  647.                 if (htTrav->next->x[0] > pPost[MAX_DRAW_DIST+1+i][j+1][0].x) {
  648.                     break;
  649.                     }
  650.                 //
  651.                 // b1, b2, and b3 correspond to the square to the inside of the one
  652.                 // we're checking, the square we're checking, and the square
  653.                 // forward past the square we're checking.
  654.                 //
  655.                 b1 = b2;
  656.                 //
  657.                 // set (tx,ty) one square to the 'left'.
  658.                 //
  659.                 tx = ADJ_X(tx,dLeft);
  660.                 ty = ADJ_Y(ty,dLeft);
  661.                 b2 = bMaze[tx][ty];
  662.                 b3 = bMaze[ADJ_X(tx,dForward)][ADJ_Y(ty,dForward)];
  663.                 if ((b1&dLeft)||(b2&dRight)) {
  664.                     htTrav = DrawRect(htTrav,i,j,WEST);
  665.                     }
  666.                 CheckForPlayers(&pdtToDraw,&ptPlayers,htTrav->next,i-1,j,tx,ty);
  667.                 CheckForPlayers(&pdtToDraw,&ptDrones,htTrav->next,i-1,j,tx,ty);
  668.                 if ((b2&dForward)||(b3&dBackward)) {
  669.                     htTrav = DrawRect(htTrav,i-1,j,NORTH);
  670.                     }
  671.                 }
  672.             if ((htTrav!= (HoleType FAR *)NULL)&&(htHold == htTrav->next)) {
  673.                 htTrav = htTrav->next;
  674.                 }
  675.             }
  676.          }
  677.     //
  678.     // Same as above, except this time for the RIGHT side.
  679.     //
  680.     for(j=0;j<MAX_DRAW_DIST;j++) {
  681.         htTrav=&htRight;
  682.         while((htTrav != (HoleType FAR *)NULL)&&(htTrav->next != (HoleType FAR *)NULL)) {
  683.             tx = ptSelf.Pos.ix + ABS2OFFX(0,j,dForward);
  684.             ty = ptSelf.Pos.iy + ABS2OFFY(0,j,dForward);
  685.             b2 = bMaze[tx][ty];
  686.             htHold = htTrav->next;
  687.             for (i=0;(i<MAX_DRAW_DIST)&&(htTrav != (HoleType FAR *)NULL)&&(htTrav->next != (HoleType FAR *)NULL);i++) {
  688.                 //
  689.                 // if we're before the hole, continue
  690.                 //
  691.                 if (htTrav->next->x[0] > pPost[MAX_DRAW_DIST+i+3][j+1][0].x) {
  692.                     continue;
  693.                     }
  694.                 //
  695.                 // if we're outside the hole, go to next hole.
  696.                 //
  697.                 if (htTrav->next->x[1] < pPost[MAX_DRAW_DIST+i+2][j+1][0].x) {
  698.                     break;
  699.                     }
  700.                 b1 = b2;
  701.                 //
  702.                 // set (tx,ty) one square to the 'right'.
  703.                 //
  704.                 tx = ADJ_X(tx,dRight);
  705.                 ty = ADJ_Y(ty,dRight);
  706.                 b2 = bMaze[tx][ty];
  707.                 b3 = bMaze[ADJ_X(tx,dForward)][ADJ_Y(ty,dForward)];
  708.                 if ((b1&dRight)||(b2&dLeft)) {
  709.                     htTrav = DrawRect(htTrav,i,j,EAST);
  710.                     }
  711.                 CheckForPlayers(&pdtToDraw,&ptPlayers,htTrav->next,i+1,j,tx,ty);
  712.                 CheckForPlayers(&pdtToDraw,&ptDrones,htTrav->next,i+1,j,tx,ty);
  713.                 if ((b2&dForward)||(b3&dBackward)) {
  714.                     htTrav = DrawRect(htTrav,i+1,j,NORTH);
  715.                     }
  716.                 }
  717.             if ((htTrav != (HoleType FAR *)NULL)&&(htHold == htTrav->next)) {
  718.                 htTrav = htTrav->next;
  719.                 }
  720.             }
  721.         }
  722.     //
  723.     // Draw the maze itself
  724.     //
  725.     PolyDraw95(hDC,pDraw,pType,PointCount);
  726.     //
  727.     // We were looking for players as we went along. Draw all the ones we
  728.     // found
  729.     //
  730.     DrawFoundPlayers(hDC,&pdtToDraw,rUpd);
  731.     //
  732.     // Clean up.
  733.     //
  734.     htTrav = &htLeft;
  735.     while (htTrav->next != NULL) {
  736.         htTrav->next = DelHole(htTrav->next);
  737.     }
  738.     htTrav = &htRight;
  739.     while (htTrav->next != NULL) {
  740.         htTrav->next = DelHole(htTrav->next);
  741.     }
  742.     DeleteObject(hWhiteBrush);
  743.     DeleteObject(hWhitePen);
  744.     DeleteObject(hBlackPen);
  745.     hMem = (HGLOBAL) GlobalHandle(SELECTOROF(pType));
  746.     GlobalUnlock(hMem);
  747.     GlobalFree(hMem);
  748.     hMem = (HGLOBAL) GlobalHandle(SELECTOROF(pDraw));
  749.     GlobalUnlock(hMem);
  750.     GlobalFree(hMem);
  751.     SelectObject(hDC,hOldPen);
  752.     return;
  753. }
  754. /*=====================================================================
  755. Function: DrawTopView()
  756. Inputs: DC, whether or not it's a total redraw
  757. Outputs: none
  758. Abstract:
  759.     This routine takes care of the top maze view window. It draws white
  760.     lines over black and vice versa to get the window drawn in the shortest
  761.     possible time. A triangle is drawn in the middle of the window to
  762.     represent the player and his current facing.
  763. ======================================================================*/
  764. void DrawTopView(
  765.     HDC hDC,
  766.     BOOL bRedraw
  767.     )
  768. {
  769.     int i,j,Step;
  770. //
  771. //BUGBUG -- these can be fixed after we have square pens
  772. //
  773.     // POINT p[5*5*4*2+5];
  774.     // BYTE bType[5*5*4*2+5];
  775.     LPPOINT p;
  776.     //[3*5*5*4*2+5];
  777.     LPBYTE bType;
  778.     //[3*5*5*4*2+5];
  779.     int cPoint,iPenWidth;
  780.     int x,y;
  781.     HPEN hBlackPen,hWhitePen,hPenOld;
  782.     HGLOBAL hPMem,hBMem;
  783.     hPMem = GlobalAlloc(GHND,(3*5*5*4*2 + 5)*sizeof(POINT));
  784.     p = (LPPOINT) GlobalLock(hPMem);
  785.     hBMem = GlobalAlloc(GHND,(3*5*5*4*2 + 5)*sizeof(BYTE));
  786.     bType = (LPBYTE) GlobalLock(hBMem);
  787.     cPoint = 0;
  788.     Step = (rTopView.right - rTopView.left)/5;
  789.     iPenWidth = Step/10+1;
  790.     hBlackPen = CreatePen(PS_SOLID,iPenWidth,0);
  791.     hWhitePen = CreatePen(PS_SOLID,iPenWidth,0x00FFFFFF);
  792.     //
  793.     // First, we need to draw black lines for all the missing lines in
  794.     // the current map
  795.     //
  796.     hPenOld = SelectObject(hDC,hBlackPen);
  797.     for (i =-3;i<=2; i++) {
  798.         for (j= -3; j<=2; j++) {
  799.             if (bRedraw ||
  800.                 (!((bMaze[ptLastPos.ix + i][ptLastPos.iy + j]&SOUTH)||
  801.                 (bMaze[ptLastPos.ix + i][ptLastPos.iy + j+1]&NORTH)))
  802.                ) {
  803.                 if ((bMaze[ptSelf.Pos.ix + i][ptSelf.Pos.iy + j]&SOUTH)||
  804.                     (bMaze[ptSelf.Pos.ix + i][ptSelf.Pos.iy + j+1]&NORTH)
  805.                    ) {
  806.                     p[cPoint].x = (i+2)*Step;
  807.                     p[cPoint].y = (j+3)*Step;
  808.                     bType[cPoint++] = PT_MOVETO;
  809.                     p[cPoint].x = (i+3)*Step;
  810.                     p[cPoint].y = (j+3)*Step;
  811.                     bType[cPoint++] = PT_LINETO;
  812.                     }
  813.                 }
  814.             if (bRedraw ||
  815.                 (!((bMaze[ptLastPos.ix + i][ptLastPos.iy + j]&EAST)||
  816.                  (bMaze[ptLastPos.ix + i+1][ptLastPos.iy + j]&WEST)))
  817.                ) {
  818.                 if ((bMaze[ptSelf.Pos.ix + i][ptSelf.Pos.iy + j]&EAST)||
  819.                     (bMaze[ptSelf.Pos.ix + i+1][ptSelf.Pos.iy + j]&WEST)
  820.                    ) {
  821.                     p[cPoint].x = (i+3)*Step;
  822.                     p[cPoint].y = (j+2)*Step;
  823.                     bType[cPoint++] = PT_MOVETO;
  824.                     p[cPoint].x = (i+3)*Step;
  825.                     p[cPoint].y = (j+3)*Step;
  826.                     bType[cPoint++] = PT_LINETO;
  827.                     }
  828.                 }
  829.             }
  830.         }
  831.     PolyDraw95(hDC,p,bType,cPoint);
  832.     //
  833.     // next, we draw white lines over BLACK lines drawn but no longer
  834.     // needed.
  835.     //
  836.     SelectObject(hDC,hWhitePen);
  837.     cPoint = 0;
  838.     for (i =-3;i<=2; i++) {
  839.         for (j= -3; j<=2; j++) {
  840.             if ((!bRedraw) &&
  841.                ((bMaze[ptLastPos.ix + i][ptLastPos.iy + j]&SOUTH)||
  842.                (bMaze[ptLastPos.ix + i][ptLastPos.iy + j+1]&NORTH))
  843.               ) {
  844.                 if (!((bMaze[ptSelf.Pos.ix + i][ptSelf.Pos.iy + j]&SOUTH)||
  845.                    (bMaze[ptSelf.Pos.ix + i][ptSelf.Pos.iy + j+1]&NORTH))
  846.                   ) {
  847.                     p[cPoint].x = (i+2)*Step+iPenWidth;
  848.                     p[cPoint].y = (j+3)*Step;
  849.                     bType[cPoint++] = PT_MOVETO;
  850.                     p[cPoint].x = (i+3)*Step-iPenWidth;
  851.                     p[cPoint].y = (j+3)*Step;
  852.                     bType[cPoint++] = PT_LINETO;
  853.                     //
  854.                     // We also need to kludge to clean up until we get a square pen.
  855.                     //
  856.                     p[cPoint].x = (i+2)*Step+iPenWidth;
  857.                     p[cPoint].y = (j+3)*Step-iPenWidth;
  858.                     bType[cPoint++] = PT_MOVETO;
  859.                     p[cPoint].x = (i+2)*Step+iPenWidth;
  860.                     p[cPoint].y = (j+3)*Step+iPenWidth;
  861.                     bType[cPoint++] = PT_LINETO;
  862.                     p[cPoint].x = (i+3)*Step-iPenWidth;
  863.                     p[cPoint].y = (j+3)*Step-iPenWidth;
  864.                     bType[cPoint++] = PT_MOVETO;
  865.                     p[cPoint].x = (i+3)*Step-iPenWidth;
  866.                     p[cPoint].y = (j+3)*Step+iPenWidth;
  867.                     bType[cPoint++] = PT_LINETO;
  868.                     //
  869.                     // End kludge BUGBUG
  870.                     //
  871.                     }
  872.                 }
  873.             if ((!bRedraw) &&
  874.                 ((bMaze[ptLastPos.ix + i][ptLastPos.iy + j]&EAST)||
  875.                 (bMaze[ptLastPos.ix + i+1][ptLastPos.iy + j]&WEST))
  876.                ) {
  877.                 if (!((bMaze[ptSelf.Pos.ix + i][ptSelf.Pos.iy + j]&EAST)||
  878.                     (bMaze[ptSelf.Pos.ix + i+1][ptSelf.Pos.iy + j]&WEST))
  879.                    ) {
  880.                     p[cPoint].x = (i+3)*Step;
  881.                     p[cPoint].y = (j+2)*Step+iPenWidth;
  882.                     bType[cPoint++] = PT_MOVETO;
  883.                     p[cPoint].x = (i+3)*Step;
  884.                     p[cPoint].y = (j+3)*Step-iPenWidth;
  885.                     bType[cPoint++] = PT_LINETO;
  886.                     //
  887.                     // We also need to kludge to clean up until we get a square pen.
  888.                     //
  889.                     p[cPoint].x = (i+3)*Step-iPenWidth;
  890.                     p[cPoint].y = (j+2)*Step+iPenWidth;
  891.                     bType[cPoint++] = PT_MOVETO;
  892.                     p[cPoint].x = (i+3)*Step+iPenWidth;
  893.                     p[cPoint].y = (j+2)*Step+iPenWidth;
  894.                     bType[cPoint++] = PT_LINETO;
  895.                     p[cPoint].x = (i+3)*Step-iPenWidth;
  896.                     p[cPoint].y = (j+3)*Step-iPenWidth;
  897.                     bType[cPoint++] = PT_MOVETO;
  898.                     p[cPoint].x = (i+3)*Step+iPenWidth;
  899.                     p[cPoint].y = (j+3)*Step-iPenWidth;
  900.                     bType[cPoint++] = PT_LINETO;
  901.                     //
  902.                     // End kludge BUGBUG
  903.                     //
  904.                     }
  905.                 }
  906.             };
  907.         }
  908.     PolyDraw95(hDC,p,bType,cPoint);
  909.     SelectObject(hDC,hPenOld);
  910.     DeleteObject(hBlackPen);
  911.     DeleteObject(hWhitePen);
  912.     //
  913.     // And drawn an arrow for our ptSelf.Pos.Facing
  914.     //
  915.     x = y = (Step * 10) / 4;    // the center
  916.     Step /= 4;
  917.     if (ptLastPos.Facing != ptSelf.Pos.Facing) {
  918.         if (hWhitePen != NULL) {
  919.             DeleteObject(hWhitePen);
  920.         }
  921.         hWhitePen = CreatePen(PS_SOLID,1,0x00FFFFFF);
  922.         hPenOld = SelectObject(hDC,hWhitePen);
  923.         cPoint = 0;
  924.         p[cPoint].x = p[cPoint+4].x = x;
  925.         p[cPoint].y = p[cPoint+4].y = y;
  926.         bType[cPoint+4] = PT_LINETO;
  927.         bType[cPoint++] = PT_MOVETO;
  928.         switch (ptLastPos.Facing) {
  929.             case NORTH:
  930.                 p[cPoint].x = x+Step;
  931.                 p[cPoint].y = y;
  932.                 bType[cPoint++] = PT_LINETO;
  933.                 p[cPoint].x = x;
  934.                 p[cPoint].y = y-Step;
  935.                 bType[cPoint++] = PT_LINETO;
  936.                 p[cPoint].x = x-Step;
  937.                 p[cPoint].y = y;
  938.                 bType[cPoint++] = PT_LINETO;
  939.                 break;
  940.             case SOUTH:
  941.                 p[cPoint].x = x+Step;
  942.                 p[cPoint].y = y;
  943.                 bType[cPoint++] = PT_LINETO;
  944.                 p[cPoint].x = x;
  945.                 p[cPoint].y = y+Step;
  946.                 bType[cPoint++] = PT_LINETO;
  947.                 p[cPoint].x = x-Step;
  948.                 p[cPoint].y = y;
  949.                 bType[cPoint++] = PT_LINETO;
  950.                 break;
  951.             case EAST:
  952.                 p[cPoint].x = x;
  953.                 p[cPoint].y = y+Step;
  954.                 bType[cPoint++] = PT_LINETO;
  955.                 p[cPoint].x = x+Step;
  956.                 p[cPoint].y = y;
  957.                 bType[cPoint++] = PT_LINETO;
  958.                 p[cPoint].x = x;
  959.                 p[cPoint].y = y-Step;
  960.                 bType[cPoint++] = PT_LINETO;
  961.                 break;
  962.             case WEST:
  963.                 p[cPoint].x = x;
  964.                 p[cPoint].y = y+Step;
  965.                 bType[cPoint++] = PT_LINETO;
  966.                 p[cPoint].x = x-Step;
  967.                 p[cPoint].y = y;
  968.                 bType[cPoint++] = PT_LINETO;
  969.                 p[cPoint].x = x;
  970.                 p[cPoint].y = y-Step;
  971.                 bType[cPoint++] = PT_LINETO;
  972.                 break;
  973.             }
  974.         cPoint++;
  975.         PolyDraw95(hDC,p,bType,cPoint);
  976.         SelectObject(hDC,hPenOld);
  977.         DeleteObject(hWhitePen);
  978.         }
  979.     cPoint = 0;
  980.     p[cPoint].x = p[cPoint+4].x = x;
  981.     p[cPoint].y = p[cPoint+4].y = y;
  982.     bType[cPoint+4] = PT_LINETO;
  983.     bType[cPoint++] = PT_MOVETO;
  984.     switch (ptSelf.Pos.Facing) {
  985.         case NORTH:
  986.             p[cPoint].x = x+Step;
  987.             p[cPoint].y = y;
  988.             bType[cPoint++] = PT_LINETO;
  989.             p[cPoint].x = x;
  990.             p[cPoint].y = y-Step;
  991.             bType[cPoint++] = PT_LINETO;
  992.             p[cPoint].x = x-Step;
  993.             p[cPoint].y = y;
  994.             bType[cPoint++] = PT_LINETO;
  995.             break;
  996.         case SOUTH:
  997.             p[cPoint].x = x+Step;
  998.             p[cPoint].y = y;
  999.             bType[cPoint++] = PT_LINETO;
  1000.             p[cPoint].x = x;
  1001.             p[cPoint].y = y+Step;
  1002.             bType[cPoint++] = PT_LINETO;
  1003.             p[cPoint].x = x-Step;
  1004.             p[cPoint].y = y;
  1005.             bType[cPoint++] = PT_LINETO;
  1006.             break;
  1007.         case EAST:
  1008.             p[cPoint].x = x;
  1009.             p[cPoint].y = y+Step;
  1010.             bType[cPoint++] = PT_LINETO;
  1011.             p[cPoint].x = x+Step;
  1012.             p[cPoint].y = y;
  1013.             bType[cPoint++] = PT_LINETO;
  1014.             p[cPoint].x = x;
  1015.             p[cPoint].y = y-Step;
  1016.             bType[cPoint++] = PT_LINETO;
  1017.             break;
  1018.         case WEST:
  1019.             p[cPoint].x = x;
  1020.             p[cPoint].y = y+Step;
  1021.             bType[cPoint++] = PT_LINETO;
  1022.             p[cPoint].x = x-Step;
  1023.             p[cPoint].y = y;
  1024.             bType[cPoint++] = PT_LINETO;
  1025.             p[cPoint].x = x;
  1026.             p[cPoint].y = y-Step;
  1027.             bType[cPoint++] = PT_LINETO;
  1028.             break;
  1029.         }
  1030.     cPoint++;
  1031.     PolyDraw95(hDC,p,bType,cPoint);
  1032.     GlobalUnlock(hBMem);
  1033.     GlobalUnlock(hPMem);
  1034.     GlobalFree(hBMem);
  1035.     GlobalFree(hPMem);
  1036. }
  1037. /*=====================================================================
  1038. Function: DrawPlayers()
  1039. Inputs: DC, pointer to list of players, rectangle being updated on scrn
  1040. Outputs: none
  1041. Abstract:
  1042.     BUGBUG -- make an abstract for this.
  1043. ======================================================================*/
  1044. void DrawPlayers(
  1045.     HDC hDC,
  1046.     PlayerType FAR *ptPlyr,
  1047.     LPRECT rUpd
  1048.     )
  1049. {
  1050.     LPRECT rHld;
  1051.     PlayerType FAR *ptTrav;
  1052.     HGLOBAL hMem;
  1053.     if (rUpd == NULL) {
  1054.         hMem = GlobalAlloc(GHND,sizeof(RECT));
  1055.         rHld = (LPRECT) GlobalLock(hMem);
  1056.         if (rHld == NULL) {
  1057.             MessageBox((HWND) NULL,GetStringRes(IDS_RECTALLOCFAIL),"DrawPlayers",MB_APPLMODAL);
  1058.             }
  1059. /******
  1060.         rHld->right = rMaze.left;
  1061.         rHld->left = rMaze.right;
  1062.         rHld->top = rMaze.bottom;
  1063.         rHld->bottom = rMaze.top;
  1064. ******/
  1065. *rHld = rMaze;
  1066.         }
  1067.     else {
  1068.         rHld = rUpd;
  1069.         }
  1070.     ptTrav = ptPlyr;
  1071.     while (ptTrav->next != NULL) {
  1072.         ptTrav = ptTrav->next;
  1073.         if (ptTrav->Drawn) {
  1074.             rHld->left = LESSEROF(rHld->left,ptTrav->rDrawn.left);
  1075.             rHld->right = GREATEROF(rHld->right,ptTrav->rDrawn.right);
  1076.             rHld->top = LESSEROF(rHld->top,ptTrav->rDrawn.top);
  1077.             rHld->bottom = GREATEROF(rHld->bottom,ptTrav->rDrawn.bottom);
  1078.             }
  1079.         }
  1080.     PostMessage(hWndMaze,WM_COMMAND,IDM_REDRAW,(DWORD) rHld);
  1081. }