[comp.sources.d] tetris game

erc@pai.UUCP (Eric Johnson) (03/01/89)

I just tried to get the game tetris (the BSD version),
that was recently posted, running.  I came across a number of
problems and have a few suggestions. Has anyone got this to
run?  I really like the commercial version of tetris (on the Mac --
which I purchased), and would like to run a "clone" on a Unix box.
Is this version worth spending any more time on?  

Note: What is written below is NOT intended as a flame.  I merely have
some suggestions, some suggestions that may also help others who write code
for posting to the net.

Here are some problems I encountered (all attempts were made on
a Sun 386i running SunOS 4.0, and in a xterm window under X11 R3):

1)Running tetris alone without any command-line arguments dumps core,
for a segmentation fault (i.e., memory address error).  Any ideas 
why?  A suggestion: if not enough (e.g., none) command-line
options are provided, how about printing an error message (to stderr)
and explaining why there is a problem?

2) Running tetris with some command line options does get it to run,
proving that something works.  The terminal is cleared, I see a Tetris
logo (by the way, I'm sure the name Tetris is copyrighted--probably
by Spectrum HoloByte in the U.S.), and then a quick error message
and the terminal is again cleared (too fast to read the error message).
I think the error message is that it cannot find a file score.tetris
in the directory /usr/lib/tetris.

Some suggestions:
a) If you present an error message, please do not clear the terminal
before the user has a chance to read message.  Otherwise, why bother
with the message?
b) On some sites, users may not have permission to write into /usr
or /usr/lib subdirectories.  I strongly suggest that programs, especially
games, do not require a specific file to be located in a specific
directory--especially since all machines are not configured the same.
I don't mind the requirement to have a high scores file, but I do mind
requiring that file to be under /usr/lib.  It was in the current directory
I was running tetris from, so why can't it look there?  Hard-coded paths,
especially ones that assume a certain configuration, are liable to break
on various machines.  Please note that on some sites, users won't have
permission to spread games files all over the place.  On other sites,
perhaps the local system administrator decided to place certain programs in
certain places.  Also, if something doesn't run, it is a real pain to
track down all the various places a program's files have been stashed.
So, please don't provide Makefiles that want to "install" files
all over the place.  How about simply working from the current directory?

3) In compiling the file csr.c, my compiler produced two warnings:

Line 225 -- illegal pointer combination
Line 228 -- illegal pointer combination

The lines in question were rather obstuse.  Perhaps the author could
look at this, if future versions are planned.

Again, this is NOT intended as a flame against someone who spent a lot
of time preparing code to give away for free.  My suggestions are
intended to be constructive.


Have fun,
-Eric


-- 
Eric F. Johnson          | Phone +1 612-894-0313             | Are we
Prime Automation,Inc     | UUCP:   bungia!pai!erc            | having
12201 Wood Lake Drive    | UUCP:   sun!tundra!pai!erc        | fun
Burnsville, MN 55337 USA | DOMAIN: erc@pai.mn.org            | yet?

nagel@blanche.ics.uci.edu (Mark Nagel) (03/03/89)

In article <415@pai.UUCP>, erc@pai (Eric Johnson) writes:

|b) On some sites, users may not have permission to write into /usr
|or /usr/lib subdirectories.  I strongly suggest that programs, especially
|games, do not require a specific file to be located in a specific
|directory--especially since all machines are not configured the same.
|I don't mind the requirement to have a high scores file, but I do mind
|requiring that file to be under /usr/lib.  It was in the current directory
|I was running tetris from, so why can't it look there?  Hard-coded paths,
|especially ones that assume a certain configuration, are liable to break
|on various machines.

You are correct that the game should probably look in the current directory
if it cannot locate the file, but the path was configurable.  It wasn't
mentioned in any README or anything, but the file tetris.h has some
configuration parameters, including the score file location.

Mark Nagel @ UC Irvine, Dept of Info and Comp Sci
ARPA: nagel@ics.uci.edu              | Charisma doesn't have jelly in the
UUCP: {sdcsvax,ucbvax}!ucivax!nagel  | middle. -- Jim Ignatowski

zap@front.se (Svante Lindahl) (03/19/89)

In article <415@pai.UUCP>, erc@pai.UUCP (Eric Johnson) writes:
> 1)Running tetris alone without any command-line arguments dumps core,
> for a segmentation fault (i.e., memory address error).  Any ideas 
> why?  A suggestion: if not enough (e.g., none) command-line
> options are provided, how about printing an error message (to stderr)
> and explaining why there is a problem?

This is a because of a bug in main.c. Fix enclosed.
Other than that, and making sure there is a score file
in place, it seems to run fine on my Sun-3 (SunOS 3.5.2),
although I've only tried it twice (not fun enough at 2400
baud).

Svante

*** main.c.~1~	Sat Mar 18 22:31:21 1989
--- main.c	Sat Mar 18 23:12:47 1989
***************
*** 70,76 ****
  
  	/* if the user has set an environment variable "TETRIS" then process it */
  
! 	if(argc<2 && getenv("TETRIS") == NULL) {
  		i=0, j=0, k=0;
  		
  		strcpy(tetrisenv, getenv("TETRIS"));
--- 70,76 ----
  
  	/* if the user has set an environment variable "TETRIS" then process it */
  
! 	if(argc<2 && getenv("TETRIS") != NULL) {
  		i=0, j=0, k=0;
  		
  		strcpy(tetrisenv, getenv("TETRIS"));