eric@snark.UUCP (Eric S. Raymond) (10/14/88)
In email to me, Larry Bouzane (uunet!garfield.mun.cdn!larry) writes: Your 'beepbad' option is an excellent idea (I have died too many times due to some typo) but the fixes you posted are not quite correct. They do not take moving heaps or antimatter into account and as a result, with the beepbad option set, you can antimatter yourself to death or get into a situation where you are unable to make a legal move. (ie, you are unable to move 'l' in the following figure) ..... ..... ..I@.# ..... ..... The fixes below can be applied on top of yours to fix the above two problems. I leave it to you to post these fixes to the net if you want. (Sort of electing/appointing you to maintain it I guess) RCS file: RCS/good.c,v retrieving revision 1.1 diff -c -r1.1 good.c *** /tmp/,RCSt1021656 Thu Oct 13 23:08:10 1988 --- good.c Thu Oct 13 22:44:15 1988 *************** *** 16,24 **** int i,j, notsilly; a = ans; ! for(m = moves; *m != 'a'; m++) { ! test_x = my_x+xinc(*m); ! test_y = my_y+yinc(*m); move(test_y,test_x); switch(inch()) { case ' ': --- 16,45 ---- int i,j, notsilly; a = ans; ! for(m = moves; *m; m++) ! if (good_move(*m, FALSE)) ! *a++ = *m; ! *a = 0; ! if(ans[0]) { ! a = ans; ! } else { ! a = "Forget it!"; ! } ! mvprintw(LINES-1,MSGPOS,"%-*.*s",RVPOS-MSGPOS,RVPOS-MSGPOS,a); ! } ! ! good_move(dir, can_be_silly) ! char dir; ! int can_be_silly; ! { ! register int test_x, test_y; ! char savebuf[9], savechar; ! int i,j, notsilly, good; ! ! good = FALSE; ! if (dir != 'a') { ! test_x = my_x+xinc(dir); ! test_y = my_y+yinc(dir); move(test_y,test_x); switch(inch()) { case ' ': *************** *** 25,42 **** case DOT: case ME: if( isgood(test_y, test_x) ) ! *a++ = *m; break; case SCRAP: if (moveable_heaps) { int nscrap_x,nscrap_y; ! nscrap_x = test_x +xinc(*m); ! nscrap_y = test_y +yinc(*m); move(nscrap_y,nscrap_x); if (inch() == ' ') { addch(SCRAP); if (isgood(test_y,test_x)) ! *a++ = *m; move(nscrap_y,nscrap_x); addch(' '); } --- 46,63 ---- case DOT: case ME: if( isgood(test_y, test_x) ) ! good = TRUE; break; case SCRAP: if (moveable_heaps) { int nscrap_x,nscrap_y; ! nscrap_x = test_x +xinc(dir); ! nscrap_y = test_y +yinc(dir); move(nscrap_y,nscrap_x); if (inch() == ' ') { addch(SCRAP); if (isgood(test_y,test_x)) ! good = TRUE; move(nscrap_y,nscrap_x); addch(' '); } *************** *** 43,51 **** } break; } - } /* now lets do the antimatter case */ ! if (free_teleports) { notsilly = 0; /* silly to do it if not get robots */ for(i= -1;i <= 1; i++) for(j= -1; j<= 1; j++) { --- 64,71 ---- } break; } /* now lets do the antimatter case */ ! } else if (free_teleports) { notsilly = 0; /* silly to do it if not get robots */ for(i= -1;i <= 1; i++) for(j= -1; j<= 1; j++) { *************** *** 59,66 **** else savebuf[ (i+1)*3 +j +1] = ' '; } ! if( notsilly && isgood(my_y,my_x) ) ! *a++ = *m; for(i= -1;i <= 1; i++) for(j= -1; j<= 1; j++) { --- 79,86 ---- else savebuf[ (i+1)*3 +j +1] = ' '; } ! if( (can_be_silly || notsilly) && isgood(my_y,my_x) ) ! good = TRUE; for(i= -1;i <= 1; i++) for(j= -1; j<= 1; j++) { *************** *** 70,82 **** addch(savechar); } } ! *a = 0; ! if(ans[0]) { ! a = ans; ! } else { ! a = "Forget it!"; ! } ! mvprintw(LINES-1,MSGPOS,"%-*.*s",RVPOS-MSGPOS,RVPOS-MSGPOS,a); } isgood(ty,tx) --- 90,97 ---- addch(savechar); } } ! ! return good; } isgood(ty,tx) =================================================================== RCS file: RCS/user.c,v retrieving revision 1.2 diff -c -r1.2 user.c *** /tmp/,RCSt1021656 Thu Oct 13 23:08:17 1988 --- user.c Thu Oct 13 23:05:05 1988 *************** *** 112,118 **** quit(FALSE); case 'a': case 'A': /* Antimatter - sonic screwdriver */ ! if (free_teleports) { new_x = my_x; new_y = my_y; screwdriver(); } --- 112,121 ---- quit(FALSE); case 'a': case 'A': /* Antimatter - sonic screwdriver */ ! if (beep_badmoves && !good_move('a', TRUE)) { ! bad_move = TRUE; ! break; ! } else if (free_teleports) { new_x = my_x; new_y = my_y; screwdriver(); } *************** *** 197,203 **** } } } ! if (beep_badmoves && !isgood(new_y, new_x)) { bad_move = TRUE; return; --- 200,206 ---- } } } ! if (beep_badmoves && !good_move(dir, TRUE)) { bad_move = TRUE; return; -- Eric S. Raymond (the mad mastermind of TMN-Netnews) UUCP: ...!{uunet,att,rutgers}!snark!eric = eric@snark.UUCP Post: 22 S. Warren Avenue, Malvern, PA 19355 Phone: (215)-296-5718