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 / draw.c < prev    next >
C/C++ Source or Header  |  1996-01-07  |  40KB  |  1,305 lines

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