[unix-pc.sources] Life game for the UNIX PC - Patch 1

karl@zip.UUCP (Karl F. Fox) (10/27/89)

This is patch 1 to life for the UNIX PC.  It fixes a bug where the
find_target() subroutine could fail to find a target if all live cells
were off-screen, leaving the caller to use stack garbage for row and
column.

Apply with

    patch < thisfile

Changes:

README:
1.2
Mention make install; correct small spelling and wording problems.

Makefile:
1.2
1) Put life-patterns in the shar file, and 2) add an install rule.

life.c:
1.2
Clarify comment wording.

lifegame.c:
1.2
Fix brain-fade in life_game_done() -- find_target() might
have trouble if the only live targets are off-screen.


Prereq: 1.1
*** /tmp/da6685	Thu Oct 26 22:42:53 1989
--- README	Wed Oct 25 21:20:11 1989
***************
*** 3,9
  
  How to make it:
  
! Type "make".
  
  
  How to use it:

--- 3,10 -----
  
  How to make it:
  
! Type "make" to compile life.  Typing "make install" will also install
! life in /usr/games and life-patterns in /usr/local/lib.
  
  
  How to use it:
***************
*** 16,22
  Pressing the middle mouse button freezes or resumes animation, and
  pressing the right mouse button kills all the cells.  When the left
  mouse button is pressed *down* the cursor changes from a tiny dot
! (which, by the way, will disappear completely if places in the far upper
  right corner of the screen) to a life cell, which can be placed on the
  screen by releasing the button.  Depositing the new cell on an old cell
  kills it.

--- 17,23 -----
  Pressing the middle mouse button freezes or resumes animation, and
  pressing the right mouse button kills all the cells.  When the left
  mouse button is pressed *down* the cursor changes from a tiny dot
! (which, by the way, will disappear completely if placed in the upper
  right corner of the screen) to a life cell, which can be placed on the
  screen by releasing the button.  Depositing the new cell on an old cell
  kills them both.
***************
*** 19,25
  (which, by the way, will disappear completely if places in the far upper
  right corner of the screen) to a life cell, which can be placed on the
  screen by releasing the button.  Depositing the new cell on an old cell
! kills it.
  
  When the arena gets into a stable configuration (all dead, completely
  static or a pattern repeating every 63 generations or less), a glider or

--- 20,26 -----
  (which, by the way, will disappear completely if placed in the upper
  right corner of the screen) to a life cell, which can be placed on the
  screen by releasing the button.  Depositing the new cell on an old cell
! kills them both.
  
  When the arena gets into a stable configuration (all dead, completely
  static or a pattern repeating every 63 generations or less), a glider or
***************
*** 24,30
  When the arena gets into a stable configuration (all dead, completely
  static or a pattern repeating every 63 generations or less), a glider or
  spaceship will be injected to stir up the action.  After a few tries at
! this, the screen will be cleared and a random starting pattern will be
  selected from the file /usr/local/lib/life-patterns.  Note that the cell
  arena extends a ways beyond the boundaries of the visible screen, so an
  apparently static configuration may be active off-screen.

--- 25,31 -----
  When the arena gets into a stable configuration (all dead, completely
  static or a pattern repeating every 63 generations or less), a glider or
  spaceship will be injected to stir up the action.  After a few tries at
! this, the screen will be cleared and a starting pattern will be randomly
  selected from the file /usr/local/lib/life-patterns.  Note that the cell
  arena extends a ways beyond the boundaries of the visible screen, so an
  apparently static configuration may be active off-screen.
***************
*** 36,39
  
  P.S.  Send me email if you want my xlock driver.
  
! @(#)README	1.1

--- 37,40 -----
  
  P.S.  Send me email if you want my xlock driver.
  
! @(#)README	1.2

Prereq: 1.1
*** /tmp/da6687	Thu Oct 26 22:43:01 1989
--- Makefile	Thu Oct 26 22:42:50 1989
***************
*** 1,4
! # @(#)Makefile	1.1
  
  #
  #	Makefile for the game of life

--- 1,4 -----
! # @(#)Makefile	1.2
  
  #
  #	Makefile for the game of life
***************
*** 14,19
  life.o:	life.c lifegame.c
  	$(CC) $(CFLAGS) -c life.c
  
  clean:
  	rm -f life *.o core
  lint:

--- 14,23 -----
  life.o:	life.c lifegame.c
  	$(CC) $(CFLAGS) -c life.c
  
+ install:	life life-patterns
+ 	cp life /usr/games/life
+ 	cp life-patterns /usr/local/lib/life-patterns
+ 
  clean:
  	rm -f life *.o core
  lint:
***************
*** 22,26
  README:	s.README
  	$(GET) $(GFLAGS) -p s.README > $@
  
! life.shar:	README Makefile life.c lifegame.c
! 	-shar README Makefile life.c lifegame.c > life.shar

--- 26,33 -----
  README:	s.README
  	$(GET) $(GFLAGS) -p s.README > $@
  
! life-patterns:	s.life-patterns
! 	$(GET) $(GFLAGS) -p s.life-patterns > $@
! 
! life.shar:	README Makefile life.c lifegame.c life-patterns
! 	-shar README Makefile life.c lifegame.c life-patterns > life.shar

Prereq: 1.1";
*** /tmp/da6689	Thu Oct 26 22:43:14 1989
--- life.c	Thu Oct 26 22:41:20 1989
***************
*** 6,12
   */
  
  # ifndef lint
! static char life_sccs_id[] = "@(#)life.c	1.1";
  # endif /* lint */
  
  /*

--- 6,12 -----
   */
  
  # ifndef lint
! static char life_sccs_id[] = "@(#)life.c	1.2";
  # endif /* lint */
  
  /*
***************
*** 17,23
   *
   *	How to use it:
   *
-  *
   *	Just run it.  There are no arguments.  Stop it by giving it a
   *	SIGINT or SIGTERM or by typing any key (except a digit) to the
   *	display window.  Typing digit n will set the time to sleep

--- 17,22 -----
   *
   *	How to use it:
   *
   *	Just run it.  There are no arguments.  Stop it by giving it a
   *	SIGINT or SIGTERM or by typing any key (except a digit) to the
   *	display window.  Typing digit n will set the time to sleep
***************
*** 27,35
   *	and pressing the right mouse button kills all the cells.  When
   *	the left mouse button is pressed *down* the cursor changes from
   *	a tiny dot (which, by the way, will disappear completely if
!  *	places in the far upper right corner of the screen) to a life
!  *	cell, which can be placed on the screen by releasing the button.
!  *	Depositing the new cell on an old cell kills it.
   *
   *	When the arena gets into a stable configuration (all dead,
   *	completely static or a pattern repeating every 63 generations or

--- 26,34 -----
   *	and pressing the right mouse button kills all the cells.  When
   *	the left mouse button is pressed *down* the cursor changes from
   *	a tiny dot (which, by the way, will disappear completely if
!  *	placed in the upper right corner of the screen) to a life cell,
!  *	which can be placed on the screen by releasing the button.
!  *	Depositing the new cell on an old cell kills them both.
   *
   *	When the arena gets into a stable configuration (all dead,
   *	completely static or a pattern repeating every 63 generations or
***************
*** 35,41
   *	completely static or a pattern repeating every 63 generations or
   *	less), a glider or spaceship will be injected to stir up the
   *	action.  After a few tries at this, the screen will be cleared
!  *	and a random starting pattern will be selected from the file
   *	/usr/local/lib/life-patterns.  Note that the cell arena extends
   *	a ways beyond the boundaries of the visible screen, so an
   *	apparently static configuration may be active off-screen.

--- 34,40 -----
   *	completely static or a pattern repeating every 63 generations or
   *	less), a glider or spaceship will be injected to stir up the
   *	action.  After a few tries at this, the screen will be cleared
!  *	and a starting pattern will be randomly selected from the file
   *	/usr/local/lib/life-patterns.  Note that the cell arena extends
   *	a ways beyond the boundaries of the visible screen, so an
   *	apparently static configuration may be active off-screen.

Prereq: 1.1";
*** /tmp/da6691	Thu Oct 26 22:43:24 1989
--- lifegame.c	Thu Oct 26 22:41:23 1989
***************
*** 6,12
   */
  
  # ifndef lint
! static char lifegame_sccs_id[] = "@(#)lifegame.c	1.1";
  # endif /* lint */
  
  /*

--- 6,12 -----
   */
  
  # ifndef lint
! static char lifegame_sccs_id[] = "@(#)lifegame.c	1.2";
  # endif /* lint */
  
  /*
***************
*** 508,513
  	    return (1);
  
  	++shots;
  	find_target(&row, &col);
  
  	if (row < 5

--- 508,514 -----
  	    return (1);
  
  	++shots;
+ 	row = col = -1;
  	find_target(&row, &col);
  
  	if (row < 0)
***************
*** 509,514
  
  	++shots;
  	find_target(&row, &col);
  
  	if (row < 5
  		|| row > nrows - 5

--- 510,518 -----
  	++shots;
  	row = col = -1;
  	find_target(&row, &col);
+ 
+ 	if (row < 0)
+ 	    return (1);
  
  	if (row < 5
  		|| row > nrows - 5
-- 
Karl F. Fox, Morning Star Technologies, Inc.               karl@MorningStar.COM