[comp.sources.games.bugs] Greed Patch #3

mday@ohs.UUCP (Matthew T. Day) (06/24/89)

Here's a bugfix for Greed v1.2a, making it v1.2b.  It fixes a problem
many people may have noticed, with Greed writing to the 80th column it
therefore causes the cursor position to be set to 81, which is invalid,
creating minor problems.  I had fixed this by setting COLS = 81, but that
only worked for me because I'm doing all this at 1200 baud!  Anyway, now
the screen size has simply been shrunk to 79, I really haven't figured out
any way else of getting around it, so this will get people by until someone
does..  I'm *really* sorry and *really* mad that I let this bug get through,
can you ever forgive me?

BTW, the score files from old versions of Greed will be slightly unfair
because they were played with 80 columns, oh well..

----------------------------Patch begins-------------------------------------
*** dist/greed.c	Fri Jun 23 23:30:26 1989
--- greed.c	Fri Jun 23 23:35:54 1989
***************
*** 1,8 ****
! /* greed.c v1.2a - Written by Matthew T. Day (mday@ohs.uucp), 06/22/89       *
   * Document and send all source code changes to the above address, I'll make *
   * sure the approved patches are posted.  Please don't redistribute this.    */
  
! static char *version = "Greed v1.2a";
  
  #include <curses.h>
  #include <signal.h>
--- 1,8 ----
! /* greed.c v1.2b - Written by Matthew T. Day (mday@ohs.uucp), 06/23/89       *
   * Document and send all source code changes to the above address, I'll make *
   * sure the approved patches are posted.  Please don't redistribute this.    */
  
! static char *version = "Greed v1.2b";
  
  #include <curses.h>
  #include <signal.h>
***************
*** 29,35 ****
  	char user[9];
  	int score;
  };
! int score = 1, grid[22][80], y, x, havebotmsg = 0;
  char *cmdname;
  extern long random();
  
--- 29,35 ----
  	char user[9];
  	int score;
  };
! int score = 1, grid[22][79], y, x, havebotmsg = 0;
  char *cmdname;
  extern long random();
  
***************
*** 81,87 ****
  	(void) signal(SIGQUIT, quit);
  	(void) signal(SIGTERM, out);
  
- 	if (COLS < 81) COLS = 81;
  	initscr();
  	crmode();
  	noecho();
--- 81,86 ----
***************
*** 90,102 ****
  	srandom(time(0) ^ getpid() << 16);
  
  	for (y=0; y < 22; y++)
! 		for (x=0; x < 80; x++)
  			mvaddch(y, x, (grid[y][x] = rnd(9)) + '0');
  
  	mvaddstr(23, 0, "Score: ");
  	mvprintw(23, 40, "%s - Hit '?' for help.", version);
  	standout();
! 	y = rnd(22)-1; x = rnd(80)-1;
  	mvaddch(y, x, ME);
  	grid[y][x] = 0;
  
--- 89,101 ----
  	srandom(time(0) ^ getpid() << 16);
  
  	for (y=0; y < 22; y++)
! 		for (x=0; x < 79; x++)
  			mvaddch(y, x, (grid[y][x] = rnd(9)) + '0');
  
  	mvaddstr(23, 0, "Score: ");
  	mvprintw(23, 40, "%s - Hit '?' for help.", version);
  	standout();
! 	y = rnd(22)-1; x = rnd(79)-1;
  	mvaddch(y, x, ME);
  	grid[y][x] = 0;
  
***************
*** 118,124 ****
  
  showscore() {
  	standend();
! 	mvprintw(23, 7, "%d  %.2f%%", score, (float) score / 17.6);
  	move(y, x);
  	standout();
  	refresh();
--- 117,123 ----
  
  showscore() {
  	standend();
! 	mvprintw(23, 7, "%d  %.2f%%", score, (float) score / 17.32);
  	move(y, x);
  	standout();
  	refresh();
***************
*** 176,182 ****
  		do {
  			j += dy;
  			i += dx;
! 			if (j >= 0 && i >= 0 && j < 22 && i < 80 && grid[j][i])
  				continue;
  			else if (!othermove(dy, dx)) {
  				j -= dy;
--- 175,181 ----
  		do {
  			j += dy;
  			i += dx;
! 			if (j >= 0 && i >= 0 && j < 22 && i < 79 && grid[j][i])
  				continue;
  			else if (!othermove(dy, dx)) {
  				j -= dy;
***************
*** 249,255 ****
  					j += dy;
  					i += dx;
  					if (j < 0 || i < 0 || j >= 22 ||
! 					    i >= 80 || !grid[j][i]) break;
  				} while (--d);
  				if (!d) return(1);
  			}
--- 248,254 ----
  					j += dy;
  					i += dx;
  					if (j < 0 || i < 0 || j >= 22 ||
! 					    i >= 79 || !grid[j][i]) break;
  				} while (--d);
  				if (!d) return(1);
  			}
***************
*** 327,333 ****
  	for (ptrtmp=toplist; ptrtmp < eof && ptrtmp->score; ptrtmp++, count++) {
  		if (ptrtmp == new && boldon) tputs(boldon, 1, doputc);
  		printf("%-5d %-6d %-8s %.2f%%\n", count, ptrtmp->score,
! 			ptrtmp->user, (float) ptrtmp->score / 17.6);
  		if (ptrtmp == new && boldoff) tputs(boldoff, 1, doputc);
  	}
  }
--- 326,332 ----
  	for (ptrtmp=toplist; ptrtmp < eof && ptrtmp->score; ptrtmp++, count++) {
  		if (ptrtmp == new && boldon) tputs(boldon, 1, doputc);
  		printf("%-5d %-6d %-8s %.2f%%\n", count, ptrtmp->score,
! 			ptrtmp->user, (float) ptrtmp->score / 17.32);
  		if (ptrtmp == new && boldoff) tputs(boldoff, 1, doputc);
  	}
  }
-- 
+----------------------------------------------+-------------------------+
| Matthew T. Day, Orem High School, Orem, Utah | "He who laughs, lasts." |
| Email: mday@ohs (..!uunet!iconsys!ohs!mday)  |    day++, dollar++;     |
+----------------------------------------------+-------------------------+

jpn@genrad.com (John P. Nelson) (06/28/89)

In article <319@ohs.UUCP> mday@ohs.UUCP (Matthew T. Day) writes:
>Here's a bugfix for Greed v1.2a, making it v1.2b.

Hey, what happened?  Patch #2 modified v1.1b into v1.1c.  Patch #3 didn't
work AT ALL.  How did we jump from 1.1c to 1.2a?  The patch numbers only
changed from Patch #2 to Patch #3!!!!!!

     john nelson

UUCP:	{decvax,mit-eddie}!genrad!jpn
smail:	jpn@genrad.com

gas@cs.nott.ac.uk (Alan Shepherd) (06/29/89)

in article <319@ohs.UUCP>, mday@ohs.UUCP (Matthew T. Day) says:
> 
> Here's a bugfix for Greed v1.2a, making it v1.2b.  It fixes a problem
> many people may have noticed, with Greed writing to the 80th column it
> therefore causes the cursor position to be set to 81, which is invalid,
> creating minor problems.  I had fixed this by setting COLS = 81, but that
> only worked for me because I'm doing all this at 1200 baud!  Anyway, now
> the screen size has simply been shrunk to 79, I really haven't figured out
> any way else of getting around it, so this will get people by until someone
> does..  I'm *really* sorry and *really* mad that I let this bug get through,

What happened to patch2 ? Did I miss it ?  Could anyone post it please ?

Alan Shepherd