[comp.sources.games.bugs] Sokoban bug & fix

kyrimis@notecnirp.Princeton.EDU (Kriton Kyrimis) (01/06/89)

There is a slight bug in sokoban --  the  symptoms  are  improper
maintenance  of the high score table and/or inability to start at
the last level completed.  This is caused by the  fact  that  the
"found"  variable  which is used in two places in score.c to scan
the score table is not initialised and, depending on the (random)
value  it  gets, the scan loop may or may not be entered. The fix
is simply to initialise it to 0 before entering  the  loop.  Here
are the diffs:

*** score.c.orig	Wed Jan  4 14:59:32 1989
--- score.c	Thu Jan  5 22:42:30 1989
***************
*** 131,137 ****
  
  finduser() {
  
!    short i, found;
  
     for( i = 0; (i < scoreentries) && (! found); i++)
        found = (strcmp( scoretable[i].user, username) == 0);
--- 131,137 ----
  
  finduser() {
  
!    short i, found = 0;
  
     for( i = 0; (i < scoreentries) && (! found); i++)
        found = (strcmp( scoretable[i].user, username) == 0);
***************
*** 140,146 ****
  
  findpos() {
   
!    short i, found;
  
     for( i = 0; (i < scoreentries) && (! found); i++)
        found =    (scorelevel > scoretable[i].lv)
--- 140,146 ----
  
  findpos() {
   
!    short i, found = 0;
  
     for( i = 0; (i < scoreentries) && (! found); i++)
        found =    (scorelevel > scoretable[i].lv)

	Kriton	(UUCP: rutgers!princeton!kyrimis)
	      	(ARPA: kyrimis@princeton.edu)
-----
"Captain... you are BLUE!"
-----