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

apratt@atari.UUCP (Allan Pratt) (01/06/89)

I didn't need the patch which appeared here for Sokoban relating to
cbreak mode; I don't know why, but my version works fine (on 4.2BSD). 
However... 

Sokoban is supposed to start you at the level after the last one you
successfully completed, or another one you specify on the command line,
but no higher than the default.  The procedure which determines the
level you've achieved has a bug, though: it uses a variable before
setting it. 

Here's the fix, to file score.c:

136c136
<    for( i = 0; (i < scoreentries) && (! found); i++)
---
>    for( found = i = 0; (i < scoreentries) && (! found); i++)

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

meier@src.honeywell.COM (Christopher M. Meier) (01/09/89)

In article <1295@atari.UUCP> apratt@atari.UUCP (Allan Pratt) writes:
+I didn't need the patch which appeared here for Sokoban relating to
+cbreak mode; I don't know why, but my version works fine (on 4.2BSD). 
+However... 

me either...

+... it uses a variable before setting it. 
+Here's the fix, to file score.c:
+
+136c136
+<    for( i = 0; (i < scoreentries) && (! found); i++)
+---
+>    for( found = i = 0; (i < scoreentries) && (! found); i++)

Below is the source surrounding the above code, found *is* set before using.
Is there more than one version of this source floating around?

	finduser() {

	   short i, found = 0;

	   for( i = 0; (i < scoreentries) && (! found); i++)
		  found = (strcmp( scoretable[i].user, username) == 0);
	   return( (found) ? i-1 : -1);
	}