[comp.sources.games] v06i050: sun-tetris2.pch1 - tetris for SunView in colour, patch1

games@tekred.CNA.TEK.COM (04/26/89)

Submitted-by: shortley@CompSci.Bristol.AC.UK (Martyn Shortley)
Posting-number: Volume 6, Issue 50
Archive-name: sun-tetris2/Patch1

	[This is also from the bugs group. BTW, my criteria for posting
	 patches here is 1) were they posted or sent to me by the original
	 author, 2) were they sent directly to me and not posted to the bugs
	 group.  I prefer to have an "official" patch from the original
	 author(s) whenever possible, even if someone else posted a fix
	 to the bugs group.  The bugs group is not archived, so I try and
	 put important patches here so later users will find the patches
	 along with the original source.  -br]

Since we posted the source for tetris under Sunview, we have discovered a few
minor bugs.
These are :
	The user could rotate blocks off the edge of the screen.
	The user could rotate blocks off the bottom of the screen.
	Under certain circumstances, the wrong high score is highlighted.

Fixes for these are included.
The first fix was included in the original posting - we sent the fix before
the game was posted to comp.sources.games

We have also had some feedback asking what a good score is.
Our high score table is included below - If you've done better - mail us.

Pos  Name             Score  Rows Lev  Mchine     When
  1) Peter Pan         7984   536  53  happy       Sat Apr  8 16:29:54 1989
  2) wai-lun           7396   499  49  bashful     Wed Apr  5 09:08:17 1989
  3) Atlantis          2761   168  16  happy       Tue Apr  4 17:40:05 1989
  4) carol             1968   114  11  grumpy      Thu Apr  6 17:30:28 1989
  5) Black Hat         1825   103  10  grumpy      Sat Apr  1 16:13:24 1989
  6) huw                768    35   3  sleepy      Thu Apr  6 17:51:55 1989
  7) Pretty poor        640    24   2  snoopy      Thu Apr  6 18:43:09 1989
  8) clive               88     0   0  snoopy      Tue Apr  4 16:56:02 1989
  9)                      0     0   0
 10)                      0     0   0


Martyn Shortley & Phill Everson

Please do not use UUCP unless there is NO other path available.
----------------------------------------------------------------------------
SNAIL:     Martyn Shortley, 19 Hampton Park, Redland, BRISTOL       |
            BS6 6LG, England, UK                                    |
JANET:     martyn@uk.ac.bristol.compsci.med-image                   |
ARPANET:   martyn%med-image.compsci.bristol.ac.uk@nss.cs.ucl.ac.uk  |
BITNET:    martyn%uk.ac.bristol.compsci.med-image@ukacrl.bitnet     |
----------------------------------------------------------------------------
OR                                                  |
                                                    |
JANET:     shortley@uk.ac.bris.cs                   |  "A T & T ?
UUCP:      ...mcvax!ukc!csisles!shortley            |  - That name rings a
ARPANET:   shortley%cs.bris.ac.uk@nss.cs.ucl.ac.uk  |    bell"
BITNET:    shortley%uk.ac.bris.cs@ukacrl.bitnet     |
----------------------------------------------------------------------------

#--------------------------------CUT HERE-------------------------------------
#! /bin/sh
#
# This is a shell archive.  Save this into a file, edit it
# and delete all lines above this comment.  Then give this
# file to sh by executing the command "sh file".  The files
# will be extracted into the current directory owned by
# you with default permissions.
#
# The files contained herein are:
#
# -rw-r--r--   1 martyn   devpt       4904 Apr  5 10:12 bugfixes.c
#
echo 'x - bugfixes.c'
if test -f bugfixes.c; then echo 'shar: not overwriting bugfixes.c'; else
sed 's/^X//' << '________This_Is_The_END________' > bugfixes.c
X/*
X * This is the new check_rot routine to stop people rotating blocks
X * off the side or bottom of the screen.
X * It should replace the one in "support.c"
X *
X *  Martyn Shortley  5th April 1989
X *
X */
X
Xcheck_rot(shape_no, xpos, ypos, newrot)
X        int     shape_no, xpos, ypos, newrot;
X{
X        int     i;
X        int     ti;             /* Bit map of i'th row    */
X        int     yi;             /* Y position on i'th row */
X        int     x0, x1, x2, x3;
X
X        x0 = xpos;
X        x1 = xpos + 1;
X        x2 = xpos + 2;
X        x3 = xpos + 3;
X        yi = ypos;
X
X        for (i = 0; i < 4; yi++, i++) {
X                if ((yi) >= 0) {
X                        ti = shape[shape_no].table[i][newrot];
X                        if ((yi >= UHEIGHT) && (ti != 0))
X                                return FALSE;
X                        if (ti & 8)
X                                if ((x0 < 0) || (x0 >= UWIDTH) || (grid[x0][yi] == 1))
X                                        return FALSE;
X                        if (ti & 4)
X                                if ((x1 < 0) || (x1 >= UWIDTH) || (grid[x1][yi] == 1))
X                                        return FALSE;
X                        if (ti & 2)
X                                if ((x2 < 0) || (x2 >= UWIDTH) || (grid[x2][yi] == 1))
X                                        return FALSE;
X                        if (ti & 1)
X                                if ((x3 < 0) || (x3 >= UWIDTH) || (grid[x3][yi] == 1))
X                                        return FALSE;
X                }
X        }
X        return TRUE;
X}
X
X
X/*
X * These are the new scoring routines.
X *
X * Instead of storing the top 10 scores, they store the best score for each
X * person in the top 10.  Designed to stop the high-score table being full
X * of scores by only one person.
X *
X * They should replace the ones in "score.c" if you want to have a high-score
X * table as mentioned above.
X * NB The variable "score_position" is now not used by these routines
X *
X * Martyn Shortley     5th April 1989
X *
X */
X
X
Xupdate_highscore_table()
X{
X    /* This version only allows 1 entry in the HIGH SCORE TABLE per user */
X        int     i, j;
X        long    when;
X        extern char *ctime();
X        extern long time();
X        char    hostname[20];
X        char    buf[BUFSIZ];
X
X        /* re-read high-score table in case someone else on the network is
X         * playing at the same time */
X        read_high_scores();
X
X        /* Check for previous best score */
X        for (i = 0; (i < HIGH_TABLE_SIZE) && (strcmp(name, high_scores[i].name) != 0); i++);
X        if (i < HIGH_TABLE_SIZE) {
X                if (high_scores[i].score >= score)
X                        return;         /* Same/worse score - no update */
X                for (j = i; j > 0; j--) /* Remove previous best */
X                        high_scores[j] = high_scores[j - 1];
X        }
X        /* Next line finds score greater than current one */
X        for (i = 0; ((i < HIGH_TABLE_SIZE) && (score >= high_scores[i].score)); i++);
X        i--;
X        if (i >= 0) {
X                for (j = 0; j < i; j++)
X                        high_scores[j] = high_scores[j + 1];
X                strcpy(high_scores[i].name, name);
X                high_scores[i].score = score;
X                high_scores[i].rows = rows;
X                high_scores[i].level = rows / 10;
X                if (gethostname(hostname, BUFSIZ) == -1)
X                        strcpy(high_scores[i].hostname, "unknown-host");
X                else
X                        strcpy(high_scores[i].hostname, hostname);
X                time(&when);
X                strcpy(buf, ctime(&when));      /* ctime() adds a newline
X                                                 * char */
X                strip_eoln(buf);                /* so remove it */
X                strcpy(high_scores[i].date, buf);
X                write_high_scores();
X        }
X}
X
Xvoid
Xprint_high_scores()
X{
X        int     i;
X        char    buf[BUFSIZ];
X
X        /* re-read high-score table in case someone else on the network is
X         * playing at the same time */
X        read_high_scores();
X
X        for (i = HIGH_TABLE_SIZE - 1; i >= 0; i--) {
X                sprintf(buf, "%3d) %-15s %6d %5d %3d  %-10s  %s\n",
X                        HIGH_TABLE_SIZE - i,
X                        high_scores[i].name,
X                        high_scores[i].score,
X                        high_scores[i].rows,
X                        high_scores[i].level,
X                        high_scores[i].hostname,
X                        high_scores[i].date);
X                panel_set(high_score_item[HIGH_TABLE_SIZE - i], PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_STRING, buf, 0);
X                if (strcmp(name, high_scores[i].name) == 0)
X                        panel_set(high_score_item[HIGH_TABLE_SIZE - i], PANEL_LABEL_BOLD, TRUE, 0);
X        }
X        window_set(score_frame, WIN_SHOW, TRUE, 0);
X}
X
X
________This_Is_The_END________
if test `wc -l < bugfixes.c` -ne 134; then
	echo 'shar: bugfixes.c was damaged during transit (should have been 134 lines)'
fi
fi		; : end of overwriting check
exit 0