ejb@think.ARPA (Erik Bailey) (05/09/86)
Here are the diffs to make war run under System V Release 2. Thanks to Danny J. Zerkel for mailing these to me! --Erik -------------------gee. this line isn't here------------------------ **** README 0a1,18 > ***** Prelude in C ***** > This program has been hacked! > > Despite following comments, porting to SVR2 was relatively easy. > Sockets were replaced with two ipc message queues, which have keys > based on the terminal name. > > The dpy calls were replaced with equivalent curses calls, and the > moves were adjusted to fit the dpywindow() offsets. > > Destruction of the enemy goal is the winning condition. > > Because it is not always possible (or desirable) to put objects.war in > a place like /usr/games/lib, the environment variable WARPATH overrides > the default. > > Danny J. Zerkel > ***** **** cmd.c 3a4 > /* ported to SVR2 by Danny J Zerkel */ 33c34,35 < dpyredraw(); --- > clearok(stdscr, TRUE); > refresh(); 45c47 < write(STDERR, "\7", 1); --- > beep(); 57d58 < unsigned char ch; /* char to return */ 59,66c60,63 < if (playing && (ioctl(STDIN, FIONREAD, &n) == 0) && (n <= 0)) { < scaneof(); /* no char available now */ < } < do { < errno = 0; < n = read(STDIN, &ch, 1); /* read one char */ < } while ((n < 0) && (errno == EINTR)); < return((int)(ch &= 0x7f)); --- > n = getch(); > if (n == -1) > scaneof(); > return((int)(n & 0x7f)); 170c167 < ((obj->o_life > 0) && (random() % obj->o_life))) --- > ((obj->o_life > 0) && ((rand() >> 2) % obj->o_life))) 200c197 < if (random() % 2) return(1); --- > if (rand() % 2) return(1); 294c291 < bcopy(newcmds, obj->o_cmds, sizeof(obj->o_cmds)); /* set cmds */ --- > memcpy(obj->o_cmds, newcmds, sizeof(obj->o_cmds)); /* set cmds */ 296a294,495 > > /* This is bonus code. It inputs a single line display field in > * curses with full insert-always editting and keypad usage. > * (Unfortunately the game uses <ESC> so the keypad cannot be turned on. > */ > #define mvwleft(win, n) wmove(win, win->_cury, win->_curx - n) > #define mvwright(win, n) wmove(win, win->_cury, win->_curx + n) > > /* accept user input in a single line display field in window wind, > * the width of the field is max and the buffer is at buff > */ > wgetline(wind, buff, max) > register WINDOW *wind; > char *buff; > short max; > { > short ce, ck, c; > short basex, basey, currx, curry, lastx; > char *ptr = buff; > short count = 0; > short meta = 0; > > ce = erasechar(); > ck = killchar(); > wrefresh(wind); > getyx(wind, basey, basex); > lastx = basex + max; > *ptr = 0; > for (;;) { > c = wgetch(wind); > if (c == -1) > continue; > if (c < 0400) > c &= 0177; > if (meta) { > char show; > > if (c >= 0400) { > beep(); > continue; > } > if (c == '\b' || c == '\t' || c == '\n' || > c == '\r' || c == 0177) { > getyx(wind, curry, currx); > mvwdelch(wind, basey, lastx - 1); > mvwinsch(wind, curry, currx, '^'); > wmove(wind, curry, currx + 1); > count++; > show = c ^ '@'; > } else > show = c; > getyx(wind, curry, currx); > mvwdelch(wind, basey, lastx - 1); > mvwinsch(wind, curry, currx, show); > wmove(wind, curry, currx + 1); > count++; > shiftright(ptr); > *ptr++ = c; > meta = 0; > } else if (c == ce || c == KEY_BACKSPACE) { > if (ptr > buff) { > mvwleft(wind, 1); > wdelch(wind); > getyx(wind, curry, currx); > mvwinsch(wind, basey, lastx - 1, ' '); > wmove(wind, curry, currx); > --ptr; > count--; > if (*ptr < ' ' || *ptr > '~') { > mvwleft(wind, 1); > wdelch(wind); > getyx(wind, curry, currx); > mvwinsch(wind, basey, lastx - 1, ' '); > wmove(wind, curry, currx); > count--; > } > shiftleft(ptr); > } else > beep(); > } else if (c == ck || c == KEY_DL) { > wmove(wind, basey, basex); > for (currx = basex; currx < basex + max; currx++) > waddch(wind, ' '); > wmove(wind, basey, basex); > ptr = buff; > count = 0; > *ptr = 0; > } else if (c == '\\') { > meta++; > getyx(wind, curry, currx); > mvwdelch(wind, basey, lastx - 1); > mvwinsch(wind, curry, currx, '\\'); > } else if (c == KEY_DC && *ptr) { > wdelch(wind); > getyx(wind, curry, currx); > mvwinsch(wind, basey, lastx - 1, ' '); > wmove(wind, curry, currx); > count--; > if (*ptr < ' ' || *ptr > '~') { > wdelch(wind); > getyx(wind, curry, currx); > mvwinsch(wind, basey, lastx - 1, ' '); > wmove(wind, curry, currx); > count--; > } > shiftleft(ptr); > } else if (c == KEY_EOL && *ptr) { > char *save = ptr; > > getyx(wind, curry, currx); > while (*ptr) { > waddch(wind, ' '); > count--; > if (*ptr < ' ' || *ptr > '~') { > waddch(wind, ' '); > count--; > } > ptr++; > } > wmove(wind, curry, currx); > ptr = save; > *ptr = 0; > } else if (c == KEY_LEFT && ptr > buff) { > mvwleft(wind, 1); > ptr--; > } else if (c == KEY_RIGHT && *ptr != 0) { > mvwright(wind, 1); > ptr++; > } else if (c == KEY_HOME) { > wmove(wind, basey, basex); > ptr = buff; > } else if (c == KEY_LL) { > wmove(wind, basey, basex + count); > while (*ptr) > ptr++; > } else if (c == KEY_IC || c == KEY_EIC) { > shiftright(ptr); > *ptr = ' '; > getyx(wind, curry, currx); > mvwdelch(wind, basey, lastx - 1); > winsch(wind, curry, currx, ' '); > count++; > } else if (c == KEY_CLEAR || c == KEY_EOS) { > clearok(wind); > } else if (c == '\r' || c == '\n') { > return; > } else if (c >= 0400) { > beep(); > } else if ((c < ' ' || c > '~') && count < max - 1) { > getyx(wind, curry, currx); > mvwdelch(wind, basey, lastx - 2); > wdelch(wind); > mvwinsch(wind, curry, currx, c ^ '@'); > winsch(wind, '^'); > wmove(wind, curry, currx+2); > count += 2; > shiftright(ptr); > *ptr++ = c; > } else if (count < max) { > getyx(wind, curry, currx); > mvwdelch(wind, basey, lastx - 1); > mvwinsch(wind, curry, currx, c); > mvwright(wind, 1); > shiftright(ptr); > *ptr++ = c; > count++; > } else > beep(); > wrefresh(wind); > } > } > > /* shift left string. > * Reduces the length of the string by one. > * Current character is lost. > */ > shiftleft(ptr) > register char *ptr; > { > register char *q = ptr; > > if (*ptr) > while (*ptr++ = *++q); > } > > /* shift right string. > * Increases the length of the string by one. > * Current character is duplicated. > */ > shiftright(ptr) > register char *ptr; > { > register char *p, *q = ptr; > > while (*q) > q++; > p = q; > p++; > while (q >= ptr) > *p-- = *q--; > } > **** init.c 3a4 > /* ported to SVR2 by Danny J Zerkel */ 20c21,24 < register struct object *obj; /* object being placed */ --- > /* This WAS a register variable, but register variables are not > * restored by the longjmp, so it MUST be a normal variable. > */ > struct object *obj; /* object being placed */ 35,36c39,40 < dpymove(row, col); < dpyupdate(); --- > move(row, col+1); > refresh(); 56c60,61 < dpyredraw(); --- > clearok(stdscr, TRUE); > refresh(); 58a64 > case '\r': 69c75 < while ((col < (COLS-1)) && (++col % 8)) ; --- > while ((col < (BCOLS-1)) && (++col % 8)) ; 75c81 < col = (COLS - 1); --- > col = (BCOLS - 1); 92c98 < if (col >= COLS) col = COLS - 1; --- > if (col >= BCOLS) col = BCOLS - 1; 101c107 < while (countone-- && (row > 0) && (col < COLS-1)) { --- > while (countone-- && (row > 0) && (col < BCOLS-1)) { 113c119 < while (countone-- && (row<HOMEROW) && (col<COLS-1)) { --- > while (countone-- && (row<HOMEROW) && (col<BCOLS-1)) { 130c136 < if (col >= (COLS-1)) break; --- > if (col >= (BCOLS-1)) break; 170a177,178 > move(LINES-1, 0); > refresh(); 175a184,185 > move(LINES-1, 0); > refresh(); 212a223,224 > register int i; > int len; 216c228 < dpywindow(-1, -1, 2, COLS); --- > mvaddstr(LINES-1, 2, str); 218c230,232 < cp += dpyread(str, getaskchar, cp, sizeof(buf)); --- > len = BCOLS - 3 - strlen(str); > wgetline(stdscr, cp, len); > while (*cp) cp++; 223,225c237,238 < dpyhome(); < dpyclrwindow(); < dpywindow(0, -1, 1, COLS); --- > move(LINES-1, 2); > for (i = 2; i < BCOLS; i++) addch(' '); 231,244d243 < /* Routine called by dpyread to get characters */ < getaskchar() < { < char ch; < < if ((read(STDIN, &ch, 1) != 1) || (ch == '\033')) { < didescape = 1; < return(-1); < } < if (ch == '\n') return(-1); < return((int)(ch & 0x7f)); < } < < 266c265 < if ((row > HOMEROW) || (col >= COLS)) { --- > if ((row > HOMEROW) || (col >= BCOLS)) { 304c303 < rc = &board[row][COLS-1]; --- > rc = &board[row][BCOLS-1]; 313,316c312,315 < if (lobj) dpyplace(lc->c_row, lc->c_col, ' '); < if (robj) dpyplace(rc->c_row, rc->c_col, ' '); < if (lobj) dpyplace(rc->c_row, rc->c_col, lobj->o_ownch); < if (robj) dpyplace(lc->c_row, lc->c_col, robj->o_ownch); --- > if (lobj) mvaddch(lc->c_row, lc->c_col+1, ' '); > if (robj) mvaddch(rc->c_row, rc->c_col+1, ' '); > if (lobj) mvaddch(rc->c_row, rc->c_col+1, lobj->o_ownch); > if (robj) mvaddch(lc->c_row, lc->c_col+1, robj->o_ownch); 446c445 < for (col = 0; col < COLS; col++) { --- > for (col = 0; col < BCOLS; col++) { 465,466c464,465 < cc->c_next = &board[row-1][COLS-1]; < cc = &board[row][COLS-1]; --- > cc->c_next = &board[row-1][BCOLS-1]; > cc = &board[row][BCOLS-1]; 471c470 < for (col = 0; col < COLS; col++) { --- > for (col = 0; col < BCOLS; col++) { 482,483c481,482 < firstcell = &board[ROWS-1][COLS-1]; < homecell = &board[HOMEROW][COLS-1]; --- > firstcell = &board[ROWS-1][BCOLS-1]; > homecell = &board[HOMEROW][BCOLS-1]; 490,493c489,492 < dpychar(ch); < for (col = 0; col < COLS; col++) dpychar(' '); < dpychar(ch); < dpychar('\n'); --- > addch(ch); > for (col = 0; col < BCOLS; col++) addch(' '); > addch(ch); > addch('\n'); 495d493 < dpywindow(0, -1, 1, COLS); 538c536 < for (col = 0; (col < COLS) && *cp; col++, cp++) { --- > for (col = 0; (col < BCOLS) && *cp; col++, cp++) { 564c562 < char buf[COLS+2]; /* data to write */ --- > char buf[BCOLS+2]; /* data to write */ 574c572 < cp = &buf[COLS-1]; --- > cp = &buf[BCOLS-1]; 633,634c631,637 < if (index(name, '/') == 0) { < sprintf(altname, "%s/%s", LIBDIR, name); --- > if (strchr(name, '/') == 0) { > char *path = (char *)getenv("WARPATH"); > > if (path) > sprintf(altname, "%s/%s", path, name); > else > sprintf(altname, "%s/%s", LIBDIR, name); **** main.c 2a3 > /* ported to SVR2 by Danny J Zerkel */ 18a20,21 > extern int ready, ready_at; > 63a67 > srand(time(0)); 67c71,89 < if (dpyinit(NULL, NULL)) exit(1); --- > signal(SIGHUP, sigint); > signal(SIGQUIT, sigint); > signal(SIGILL, sigint); > signal(SIGTRAP, sigint); > signal(SIGIOT, sigint); > signal(SIGEMT, sigint); > signal(SIGFPE, sigint); > signal(SIGBUS, sigint); > signal(SIGSEGV, sigint); > signal(SIGSYS, sigint); > signal(SIGPIPE, sigint); > signal(SIGTERM, sigint); > signal(SIGUSR1, SIG_IGN); > signal(SIGUSR2, SIG_IGN); > initscr(); > nonl(); > cbreak(); > noecho(); > nodelay(stdscr, TRUE); 79c101,102 < dpymove(0, 0); --- > time(&ready_at); /* remember the instant that the user was ready */ > move(0, 0); 80a104,114 > view(); > /* NOTE: the following while (1) loop has been changed fundamentaly... > * The original seemed to work simultaneously for both players. > * This caused "missed me" panics. The loop has been changed to > * alternate between players. Also, winning condition test has been > * added. > */ > if (ready == 1) { /* the first player ready goes first */ > sleep(1); > docommands(); > } 82c116,118 < readinfo(); /* get enemy's changes */ --- > readinfo(1); /* get enemy's changes */ > if (mydata.d_goalmen == 0) > break; 85a122,123 > if (hisdata.d_goalmen == 0) > break; 86a125,136 > viewall(); /* display the whole maze. */ > viewstats(); > standout(); > if (mydata.d_goalmen == 0) > mvaddstr(ROWS/2, BCOLS/2-4, "YOU LOSE"); > else > mvaddstr(ROWS/2, BCOLS/2-4, "YOU WIN!"); > standend(); > refresh(); > endwin(); > killsocket(); > exit(0); 158c208 < if ((row >= ROWS) || (col >= COLS)) panic("placeloc"); --- > if ((row >= ROWS) || (col >= BCOLS)) panic("placeloc"); 182c232 < if (cc->c_seen) dpyplace(row, col, objectchar(obj)); --- > if (cc->c_seen) mvaddch(row, col+1, objectchar(obj)); 209c259 < if ((row >= ROWS) || (col >= COLS)) panic("removeloc"); --- > if ((row >= ROWS) || (col >= BCOLS)) panic("removeloc"); 217c267 < dpyplace(row, col, ' '); --- > mvaddch(row, col+1, ' '); 234d283 < dp = &hisdata; 235a285 > else dp = &hisdata; 299c349 < if (count > 1) count = (random() % count) + 1; --- > if (count > 1) count = ((rand() >> 3) % count) + 1; 323,331d372 < * Write a single bell to warn the user of an error < */ < beep() < { < write(STDERR, "\7", 1); < } < < < /* 337c378,381 < dpyclose(); --- > move(LINES-1, 0); > clrtoeol(); > refresh(); > endwin(); 338a383 > killsocket(); 348c393,397 < dpyclose(); --- > move(LINES-1, 0); > clrtoeol(); > refresh(); > endwin(); > killsocket(); 358c407,411 < dpyclose(); --- > move(LINES-1, 0); > clrtoeol(); > refresh(); > endwin(); > killsocket(); **** makefile 5c5,6 < CC = cc --- > LDFLAGS = > LIBS = -lcurses 11c12 < ${CC} -o war ${OFILES} -ldpy -ltermlib --- > ${CC} ${LDFLAGS} -o war ${OFILES} ${LIBS} **** scan.c 3a4 > /* ported to SVR2 by Danny J Zerkel */ 16d16 < static char rubword; /* erase word character */ 28,29c28 < struct sgttyb sgbuf; /* basic tty structure */ < struct ltchars ltbuf; /* local tty structure */ --- > struct termio termbuf; /* basic tty structure */ 35,44c34,36 < sgbuf.sg_erase = CERASE; /* set defaults in case ioctls fail */ < sgbuf.sg_kill = CKILL; < ltbuf.t_werasc = CWERASE; < ltbuf.t_lnextc = CLNEXT; < ioctl(STDIN, TIOCGETP, &sgbuf); /* get and save editing characters */ < ioctl(STDIN, TIOCGLTC, <buf); < rubchar = sgbuf.sg_erase; < rubline = sgbuf.sg_kill; < rubword = ltbuf.t_werasc; < litchar = ltbuf.t_lnextc; --- > rubchar = erasechar(); > rubline = killchar(); > litchar = '\\'; 73,83d64 < scanreadptr = scanbuffer; < longjmp(scanjumpbuf, SCAN_EDIT); < } < if (ch == rubword) { /* word erase */ < if (scanwriteptr <= scanbuffer) goto loop; < while ((--scanwriteptr >= scanbuffer) && < ((*scanwriteptr == ' ') || (*scanwriteptr == '\t'))) ; < scanwriteptr++; < while ((--scanwriteptr >= scanbuffer) && < ((*scanwriteptr != ' ') && (*scanwriteptr != '\t'))) ; < scanwriteptr++; **** talk.c 4a5 > /* ported to SVR2 by Danny J Zerkel */ 8c9,10 < #include <sys/socket.h> --- > #include <sys/ipc.h> > #include <sys/msg.h> 16d17 < #define INFO 20 /* number of messages */ 20,24c21,23 < int sd; /* descriptor for socket */ < int serverflag; /* nonzero if we are the server */ < struct sockaddr addr; /* name of our socket */ < int infocount; /* number of queued messages */ < struct info info[INFO]; /* messages queued for sending */ --- > int msg_in, msg_out; /* descriptor for message queues */ > key_t key_in, key_out; /* message queue keys */ > char other[64]; /* save other players full tty name */ 25a25 > int ready, ready_at; 28d27 < * Set the socket address used for connecting to the other player. 30,32c29,30 < * The address is generated using the device numbers of our two terminals. < * Exits if an error is detected. If successful, saves the socket address < * and remembers whether we are to be the server or the client. --- > * Message queue keys are generated from the full tty names of both players. > * Exits if an error is detected. If successful, saves the message keys. 75a74,83 > } else { > if (!count) { > dev2 = sb.st_rdev; > strcpy(other, fullname); /* save full tty name of enemy */ > } > count++; > if ((tty == NULL) || strcmp(tty, shortname)) continue; > count = 1; /* found user on tty */ > strcpy(other, fullname); > break; 77,81d84 < dev2 = sb.st_rdev; < count++; < if ((tty == NULL) || strcmp(tty, shortname)) continue; < count = 1; /* found user on tty */ < break; 99,105c102,103 < if (dev1 > dev2) { /* order the devices */ < count = dev1; < dev1 = dev2; < dev2 = count; < serverflag = 1; < } < sprintf(addr.sa_data, "WAR.%d.%d", dev1, dev2); --- > key_in = ftok(ttyname(2), 'W'); /* key for input message queue */ > key_out = ftok(other, 'W'); /* key for output message queue */ 119,134c117,128 < dpymove(-1, 1); < dpystr("Waiting for other player..."); < dpyhome(); < dpyupdate(); < if (serverflag) { /* we are the server */ < serverinit(); < dpymove(-1, 1); < dpyclrwindow(); < sendboard(); < } else { /* we are the client */ < clientinit(); < dpymove(-1, 1); < dpyclrwindow(); < readinfo(); < sendboard(); < } --- > mvaddstr(LINES-1, 1, "Waiting for other player..."); > move(0,0); > refresh(); > serverinit(); /* create our message queue */ > clientinit(); /* wait for enemy's message queue */ > sendinfo('r', 0, 0, 0); > readinfo(1); > mvaddstr(LINES-1, 1, "Other player ready... "); > move(0,0); > refresh(); > sendboard(); > mvaddstr(LINES-1, 1, " "); 142,143c136 < * Here if we are the server process, to create the binding. < * Wait for a connection from the client. --- > * Create our message queue. 147,152c140 < register int s; /* socket descriptor */ < int dummylen; /* dummy length */ < struct sockaddr dummyaddr; /* name of our socket */ < < s = socket(AF_UNIX, SOCK_STREAM, PF_UNSPEC); /* create socket */ < if (s < 0) { --- > if ((msg_in = msgget(key_in, IPC_CREAT|IPC_EXCL|0666)) < 0) { 154c142 < exit(1); --- > quit(1); 156,171d143 < unlink(addr.sa_data); /* remove binding name */ < if (bind(s, &addr, sizeof(addr)) < 0) { /* declare ourself */ < perror("bind"); < exit(1); < } < if (listen(s, 1) < 0) { /* allow one connection */ < perror("listen"); < exit(1); < } < dummylen = sizeof(dummyaddr); < sd = accept(s, &dummyaddr, &dummylen); < if (sd < 0) { < perror("accept"); < exit(1); < } < close(s); 176,177c148 < * Here if we are the client process, to connect to the binded address. < * We just continuously try to connect to the address. --- > * Wait for the message queue of the enemy. 181,187c152,153 < sd = socket(AF_UNIX, SOCK_STREAM, PF_UNSPEC); /* create socket */ < if (sd < 0) { < perror("socket"); < exit(1); < } < while (connect(sd, &addr, sizeof(addr)) < 0) { < if ((errno != ECONNREFUSED) && (errno != ENOENT)) { --- > while ((msg_out = msgget(key_out, 0666)) < 0) { > if (errno != ENOENT) { 189c155 < exit(1); --- > quit(1); 194a161,168 > /* > * Remove our message queue on exit. > */ > killsocket() > { > if (msgctl(msg_out, IPC_RMID, 0) < 0) > perror("IPC_RMID"); > } 197c171 < * Send the initial board layout --- > * Send the initial board layout and start time. 203a178 > ready = 0; 209c184,186 < sendinfo('r', 0, 0, 0); --- > sendinfo(ready_at, 0, 0, 0); /* this message says we are done. */ > while (!ready) > readinfo(0); /* wait for enemy to be done */ 215,216d191 < * Successive message are buffered up and sent together in one write. < * All pending messages are flushed when an 'r' message type is used. 223c198,201 < register struct info *ip; /* pointer to current info block */ --- > struct msgs { > long mtype; > struct info info; /* message queued for sending */ > } amsg; 225,236c203,215 < if ((row >= ROWS) || (col >= COLS)) panic("badsend"); < ip = &info[infocount++]; < ip->i_type = type; < ip->i_row = row; < ip->i_col = col; < ip->i_id = id; < if ((type != 'r') && (infocount < INFO)) < return; /* wait till later */ < type = (infocount * sizeof(struct info)); < if (write(sd, info, type) != type) { < dpyclose(); < fprintf(stderr, "other player quit\n"); --- > if ((row >= ROWS) || (col >= BCOLS)) panic("badsend"); > amsg.mtype = type; > amsg.info.i_row = row; > amsg.info.i_col = col; > amsg.info.i_id = id; > while (msgsnd(msg_out, &amsg, sizeof(struct info), IPC_NOWAIT) != 0) { > if (errno == EAGAIN) { /* if message queue is full, try reading */ > readinfo(0); > continue; > } > endwin(); > fprintf(stderr, "\nOther player quit\n"); > killsocket(); 239d217 < infocount = 0; 243a222 > * If flag == 1 245a225,226 > * If flag == 0 > * Try to read and process 1 command. And return. 247c228 < readinfo() --- > readinfo(flag) 254c235,238 < struct info info; /* command being read */ --- > struct { > long mtype; > struct info info; /* command being read */ > } amsg; 256,257c240,241 < while (1) { < id = read(sd, &info, sizeof(info)); --- > do { > id = msgrcv(msg_in, &amsg, sizeof(struct info), 0, (flag)?0:IPC_NOWAIT); 259,260c243,248 < dpyclose(); < fprintf(stderr, "other player quit\n"); --- > if (errno == ENOMSG) { > return; > } > endwin(); > fprintf(stderr, "\nOther player quit\n"); > killsocket(); 263,267c251,255 < if (id != sizeof(info)) panic("short read from socket"); < id = info.i_id ^ 1; /* toggle id */ < row = (ROWS - 1) - info.i_row; /* and row number */ < col = info.i_col; < if ((row >= ROWS) || (col >= COLS)) panic("bad coordinates"); --- > if (id != sizeof(struct info)) panic("short read from socket"); > id = amsg.info.i_id ^ 1; /* toggle id */ > row = (ROWS - 1) - amsg.info.i_row; /* and row number */ > col = amsg.info.i_col; > if ((row >= ROWS) || (col >= BCOLS)) panic("bad coordinates"); 271c259 < switch (info.i_type) { --- > switch (amsg.mtype) { 295,296c283,290 < default: < panic("bad command read from opponent\n"); --- > default: /* this is the board finished message */ > if (playing) > panic("bad read from socket"); > if (ready_at < amsg.mtype) /* decide who goes first */ > ready = 1; > else > ready = 2; > break; 298c292 < } --- > } while (flag); **** view.c 3a4 > /* ported to SVR2 by Danny J Zerkel */ 35c36 < dpyplace(cc->c_row, cc->c_col, ' '); --- > mvaddch(cc->c_row, cc->c_col+1, ' '); 54c55 < if (maxcol >= COLS) maxcol = COLS - 1; --- > if (maxcol >= BCOLS) maxcol = BCOLS - 1; 66c67 < dpyplace(row, col, tc->c_obj->o_altch); --- > mvaddch(row, col+1, tc->c_obj->o_altch); 71c72,73 < dpyupdate(); --- > move(0,0); > refresh(); 138d139 < dpywindow(0, -1, 1, INFOCOL - 2); 151d151 < dpywindow(DATAROW, -1, INFOCOL, -1); 154,155c154,155 < dpyprintf("STATISTIC YOU ENEMY\n"); < dpyprintf("fight men/life %2d/%-3d %2d/%d\n", --- > mvprintw(DATAROW, INFOCOL, "STATISTIC YOU ENEMY"); > mvprintw(DATAROW+1, INFOCOL, "fight men/life %2d/%-3d %2d/%d", 158c158,159 < dpyprintf("move men/life %2d/%-3d %2d/%d\n", --- > clrtoeol(); > mvprintw(DATAROW+2, INFOCOL, "move men/life %2d/%-3d %2d/%d", 161c162,163 < dpyprintf("blast men/life %2d/%-3d %2d/%d\n", --- > clrtoeol(); > mvprintw(DATAROW+3, INFOCOL, "blast men/life %2d/%-3d %2d/%d", 164c166,167 < dpyprintf("goal men/life %2d/%-3d %2d/%d\n", --- > clrtoeol(); > mvprintw(DATAROW+4, INFOCOL, "goal men/life %2d/%-3d %2d/%d", 167c170,171 < dpyprintf("total men/life %2d/%-3d %2d/%d\n", --- > clrtoeol(); > mvprintw(DATAROW+5, INFOCOL, "total men/life %2d/%-3d %2d/%d", 170c174,175 < dpyprintf("total walls %-3d %-3d\n", --- > clrtoeol(); > mvprintw(DATAROW+6, INFOCOL, "total walls %-3d %-3d", 172c177 < dpyclrwindow(); --- > clrtoeol(); 185a191 > int i; 187,189c193,194 < dpywindow(0, DATAROW - 2, INFOCOL, -1); < dpystr("OBJ LIFE VIEW FLAGS COUNT\n"); < for (obj = objects; obj < endobjects; obj++) { --- > mvaddstr(0, INFOCOL, "OBJ LIFE VIEW FLAGS COUNT"); > for (i = 1, obj = objects; obj < endobjects; obj++) { 212c217 < dpyprintf("%c %c %3d %4d %-7s%s\n", --- > mvprintw(i++, INFOCOL, "%c %c %3d %4d %-7s%s", 214a220 > clrtoeol(); 216c222,225 < dpyclrwindow(); --- > for (; i < DATAROW; i++) { /* simulate clear to end of screen */ > move(i, INFOCOL); > clrtoeol(); > } 217a227,246 > > /* > * make the whole board visible > */ > viewall() > { > register struct cell *cc; /* current cell */ > > for (cc = firstcell; cc; cc = cc->c_next) { > move(cc->c_row, cc->c_col+1); > if (cc->c_obj) { > if (cc->c_obj->o_side != myside) > addch(cc->c_obj->o_altch); > else > addch(cc->c_obj->o_ownch); > } else > addch(' '); > } > } > **** war.h 3a4 > * ported to SVR2 by Danny J Zerkel 6a8 > #include <curses.h> 10d11 < #include <sgtty.h> 14c15 < #define OBJECTFILE "/usr/games/lib/objects.war" /* default object file */ --- > #define OBJECTFILE "objects.war" /* default object file */ 18c19 < #define COLS 48 /* columns on board */ --- > #define BCOLS 48 /* columns on board */ 21c22 < #define INFOCOL (COLS + 3) /* leftmost column of information area */ --- > #define INFOCOL (BCOLS + 3) /* leftmost column of information area */ 120c121 < unsigned char i_type; /* type of information */ --- > /* unsigned char i_type; type of information in mtype of msgbuf */ 162c163 < struct cell board[ROWS][COLS]; /* cells of the board */ --- > struct cell board[ROWS][BCOLS]; /* cells of the board */ -- Erik Bailey -- 7 Oak Knoll (USENET courtesy of ihnp4!think!ejb Arlington, MA 02174 Thinking Machines Corp. ejb@think.com (617) 643-0732 Cambridge, MA) It takes thought to make a program that thinks. But it takes work to make a program that works.