I stuffed up the patch I sent yesterday, the remote display is out of sync
by one piece.  Blergh.  So I fixed it up and here's a better and cleaner
patch as a result.  It completely supercedes the previous one I sent.

- Matt
diff -urN netris-0.52.orig/curses.c netris-0.52/curses.c
--- netris-0.52.orig/curses.c   2005-04-14 18:02:38.000000000 +1000
+++ netris-0.52/curses.c        2005-04-14 19:20:09.000000000 +1000
@@ -55,7 +55,8 @@
                { NULL, 0, FT_read, STDIN_FILENO, KeyGenFunc, EM_key };
 
 static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS];
-static int statusYPos, statusXPos;
+int statusYPos, statusXPos;
+static int statusWidth = 30;
 static int haveColor;
 static int screens_dirty = 0;
 
@@ -199,10 +200,13 @@
                boardXPos[scr] = 1;
        else
                boardXPos[scr] = boardXPos[scr - 1] +
-                                       2 * boardWidth[scr - 1] + 3;
+                                       2 * boardWidth[scr - 1] + statusWidth + 
4;
        boardYPos[scr] = 22;
-       if (statusXPos < boardXPos[scr] + 2 * boardWidth[scr] + 3)
-               statusXPos = boardXPos[scr] + 2 * boardWidth[scr] + 3;
+
+       /* Status bar has a fixed position of 2 characters to the right of the
+        * local player's screen
+        */
+       statusXPos = boardXPos[0] + 2 * boardWidth[0] + 3;
        for (y = boardVisible[scr] - 1; y >= 0; --y) {
                move(boardYPos[scr] - y, boardXPos[scr] - 1);
                addch('|');
@@ -281,11 +285,13 @@
        }
 
        move(statusYPos - 9, statusXPos);
+       addstr("                       ");
+       move(statusYPos - 9, statusXPos);
        printw("Seed: %d", initSeed);
-       clrtoeol();
+       move(statusYPos - 8, statusXPos);
+       addstr("                       ");
        move(statusYPos - 8, statusXPos);
        printw("Speed: %dms", speed / 1000);
-       clrtoeol();
        if (robotEnable) {
                move(statusYPos - 6, statusXPos);
                if (fairRobot)
@@ -317,12 +323,12 @@
        if (pausedByThem)
                addstr("Game paused by opponent");
        else
-               clrtoeol();
+               addstr("                       ");
        move(statusYPos - 2, statusXPos);
        if (pausedByMe)
                addstr("Game paused by you");
        else
-               clrtoeol();
+               addstr("                  ");
 }
 
 ExtFunc void Message(char *s)
diff -urN netris-0.52.orig/game.c netris-0.52/game.c
--- netris-0.52.orig/game.c     2005-04-14 18:02:38.000000000 +1000
+++ netris-0.52/game.c  2005-04-15 22:46:36.207655832 +1000
@@ -79,16 +79,18 @@
                exit(1);
 }
 
+extern int statusXPos, statusYPos;
+
 ExtFunc int StartNewPiece(int scr, Shape *shape)
 {
        curShape[scr] = shape;
        curY[scr] = boardVisible[scr] + 4;
        curX[scr] = boardWidth[scr] / 2;
-       while (!ShapeVisible(shape, scr, curY[scr], curX[scr]))
+       while (!ShapeVisible(curShape[scr], scr, curY[scr], curX[scr]))
                --curY[scr];
-       if (!ShapeFits(shape, scr, curY[scr], curX[scr]))
+       if (!ShapeFits(curShape[scr], scr, curY[scr], curX[scr]))
                return 0;
-       PlotShape(shape, scr, curY[scr], curX[scr], 1);
+       PlotShape(curShape[scr], scr, curY[scr], curX[scr], 1);
        return 1;
 }
 
@@ -102,6 +104,7 @@
        int pieceCount = 0;
        int key;
        char *p, *cmd;
+       Shape *nextLocalShape;
 
        speed = stepDownInterval;
        ResetBaseTime();
@@ -131,7 +134,16 @@
                RobotCmd(0, "BeginGame\n");
                RobotTimeStamp();
        }
-       while (StartNewPiece(scr, ChooseOption(stdOptions))) {
+       
+       // Put an initial piece on the stack
+       nextLocalShape = ChooseOption(stdOptions);
+       
+       while (StartNewPiece(scr, nextLocalShape)) {
+               nextLocalShape = ChooseOption(stdOptions);
+
+               move(statusYPos - 18, statusXPos);
+               printw("%c", nextLocalShape->shorthand);
+
                if (robotEnable && !fairRobot)
                        RobotCmd(1, "NewPiece %d\n", ++pieceCount);
                if (spied) {
diff -urN netris-0.52.orig/netris.h netris-0.52/netris.h
--- netris-0.52.orig/netris.h   2005-04-14 18:02:38.000000000 +1000
+++ netris-0.52/netris.h        2005-04-15 22:50:58.038851440 +1000
@@ -142,6 +142,7 @@
        Dir initDir;
        BlockType type;
        Cmd *cmds;
+       char shorthand;
 } Shape;
 
 typedef struct _ShapeOption {
diff -urN netris-0.52.orig/shapes.c netris-0.52/shapes.c
--- netris-0.52.orig/shapes.c   2003-08-13 11:33:02.000000000 +1000
+++ netris-0.52/shapes.c        2005-04-14 19:42:31.000000000 +1000
@@ -28,44 +28,44 @@
 #define PreDecl(name, dir) \
        static Shape ShapeName(name, dir)
 
-#define StdShape(name, cmdName, mirror, type, realDir, dir, nextDir) \
+#define StdShape(name, cmdName, mirror, type, realDir, dir, nextDir, 
character) \
        static Shape ShapeName(name, dir) = { &ShapeName(name, nextDir), \
-               0, 0, mirror, D_ ## realDir, type, cmds_ ## cmdName }
+               0, 0, mirror, D_ ## realDir, type, cmds_ ## cmdName,  character}
 
-#define FourWayDecl(name, cmdName, mirror, type) \
+#define FourWayDecl(name, cmdName, mirror, type, character) \
        PreDecl(name, down); \
-       StdShape(name, cmdName, mirror, type, left, left, down); \
-       StdShape(name, cmdName, mirror, type, up, up, left); \
-       StdShape(name, cmdName, mirror, type, right, right, up); \
-       StdShape(name, cmdName, mirror, type, down, down, right)
+       StdShape(name, cmdName, mirror, type, left, left, down, character); \
+       StdShape(name, cmdName, mirror, type, up, up, left, character); \
+       StdShape(name, cmdName, mirror, type, right, right, up, character); \
+       StdShape(name, cmdName, mirror, type, down, down, right, character)
 
-#define TwoWayDecl(name, cmdName, mirror, type) \
+#define TwoWayDecl(name, cmdName, mirror, type, character) \
        PreDecl(name, vert); \
-       StdShape(name, cmdName, mirror, type, right, horiz, vert); \
-       StdShape(name, cmdName, mirror, type, down, vert, horiz)
+       StdShape(name, cmdName, mirror, type, right, horiz, vert, character); \
+       StdShape(name, cmdName, mirror, type, down, vert, horiz, character)
 
 static Cmd cmds_long[] = { C_back, C_plot, C_forw, C_plot, C_forw, C_plot,
        C_forw, C_plot, C_end };
-TwoWayDecl(long, long, 0, BT_blue);
+TwoWayDecl(long, long, 0, BT_blue, '|');
 
 static Cmd cmds_square[] = { C_plot, C_forw, C_left, C_plot, C_forw, C_left,
        C_plot, C_forw, C_left, C_plot, C_end };
 static Shape shape_square = { &shape_square, 0, 0, D_up, 0, BT_magenta,
-       cmds_square };
+       cmds_square, '#' };
 
 static Cmd cmds_l[] = { C_right, C_back, C_plot, C_forw, C_plot, C_forw,
        C_plot, C_left, C_forw, C_plot, C_end };
-FourWayDecl(l, l, 0, BT_cyan);
-FourWayDecl(l1, l, 1, BT_yellow);
+FourWayDecl(l, l, 0, BT_cyan, 'L');
+FourWayDecl(l1, l, 1, BT_yellow, 'J');
 
 static Cmd cmds_t[] = { C_plot, C_forw, C_plot, C_back, C_right, C_forw,
        C_plot, C_back, C_back, C_plot, C_end };
-FourWayDecl(t, t, 0, BT_white);
+FourWayDecl(t, t, 0, BT_white, 'T');
 
 static Cmd cmds_s[] = { C_back, C_plot, C_forw, C_plot, C_left, C_forw,
        C_plot, C_right, C_forw, C_plot, C_end };
-TwoWayDecl(s, s, 0, BT_green);
-TwoWayDecl(s1, s, 1, BT_red);
+TwoWayDecl(s, s, 0, BT_green, 'S');
+TwoWayDecl(s1, s, 1, BT_red, 'Z');
 
 ShapeOption stdOptions[] = {
        {1, &shape_long_horiz},

Attachment: signature.asc
Description: Digital signature

Reply via email to