|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T b
Length: 4904 (0x1328) Types: TextFile Names: »bugfixes.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/Sun/Tetris/bugfixes.c«
/* * This is the new check_rot routine to stop people rotating blocks * off the side or bottom of the screen. * It should replace the one in "support.c" * * Martyn Shortley 5th April 1989 * */ check_rot(shape_no, xpos, ypos, newrot) int shape_no, xpos, ypos, newrot; { int i; int ti; /* Bit map of i'th row */ int yi; /* Y position on i'th row */ int x0, x1, x2, x3; x0 = xpos; x1 = xpos + 1; x2 = xpos + 2; x3 = xpos + 3; yi = ypos; for (i = 0; i < 4; yi++, i++) { if ((yi) >= 0) { ti = shape[shape_no].table[i][newrot]; if ((yi >= UHEIGHT) && (ti != 0)) return FALSE; if (ti & 8) if ((x0 < 0) || (x0 >= UWIDTH) || (grid[x0][yi] == 1)) return FALSE; if (ti & 4) if ((x1 < 0) || (x1 >= UWIDTH) || (grid[x1][yi] == 1)) return FALSE; if (ti & 2) if ((x2 < 0) || (x2 >= UWIDTH) || (grid[x2][yi] == 1)) return FALSE; if (ti & 1) if ((x3 < 0) || (x3 >= UWIDTH) || (grid[x3][yi] == 1)) return FALSE; } } return TRUE; } /* * These are the new scoring routines. * * Instead of storing the top 10 scores, they store the best score for each * person in the top 10. Designed to stop the high-score table being full * of scores by only one person. * * They should replace the ones in "score.c" if you want to have a high-score * table as mentioned above. * NB The variable "score_position" is now not used by these routines * * Martyn Shortley 5th April 1989 * */ update_highscore_table() { /* This version only allows 1 entry in the HIGH SCORE TABLE per user */ int i, j; long when; extern char *ctime(); extern long time(); char hostname[20]; char buf[BUFSIZ]; /* re-read high-score table in case someone else on the network is * playing at the same time */ read_high_scores(); /* Check for previous best score */ for (i = 0; (i < HIGH_TABLE_SIZE) && (strcmp(name, high_scores[i].name) != 0); i++); if (i < HIGH_TABLE_SIZE) { if (high_scores[i].score >= score) return; /* Same/worse score - no update */ for (j = i; j > 0; j--) /* Remove previous best */ high_scores[j] = high_scores[j - 1]; } /* Next line finds score greater than current one */ for (i = 0; ((i < HIGH_TABLE_SIZE) && (score >= high_scores[i].score)); i++); i--; if (i >= 0) { for (j = 0; j < i; j++) high_scores[j] = high_scores[j + 1]; strcpy(high_scores[i].name, name); high_scores[i].score = score; high_scores[i].rows = rows; high_scores[i].level = rows / 10; if (gethostname(hostname, BUFSIZ) == -1) strcpy(high_scores[i].hostname, "unknown-host"); else strcpy(high_scores[i].hostname, hostname); time(&when); strcpy(buf, ctime(&when)); /* ctime() adds a newline * char */ strip_eoln(buf); /* so remove it */ strcpy(high_scores[i].date, buf); write_high_scores(); } } void print_high_scores() { int i; char buf[BUFSIZ]; /* re-read high-score table in case someone else on the network is * playing at the same time */ read_high_scores(); for (i = HIGH_TABLE_SIZE - 1; i >= 0; i--) { sprintf(buf, "%3d) %-15s %6d %5d %3d %-10s %s\n", HIGH_TABLE_SIZE - i, high_scores[i].name, high_scores[i].score, high_scores[i].rows, high_scores[i].level, high_scores[i].hostname, high_scores[i].date); panel_set(high_score_item[HIGH_TABLE_SIZE - i], PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_STRING, buf, 0); if (strcmp(name, high_scores[i].name) == 0) panel_set(high_score_item[HIGH_TABLE_SIZE - i], PANEL_LABEL_BOLD, TRUE, 0); } window_set(score_frame, WIN_SHOW, TRUE, 0); }