|
|
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 s
Length: 2371 (0x943)
Types: TextFile
Names: »score.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Dots/score.c«
/* SCORE.C */
#include "dots.h"
#define NAMELEN 30
struct scores {
int sc_person;
int sc_comp;
char sc_name[NAMELEN];
int sc_level;
int sc_width;
int sc_length;
char sc_login[9];
} top_ten[10];
high_score(Read, names)
bool Read, names;
{
struct scores *scp, *temp;
int fd;
for (scp = top_ten; scp < &top_ten[10]; scp++) {
scp->sc_name[0] = 0;
scp->sc_login[0] = 0;
scp->sc_length = 0;
scp->sc_width = 0;
scp->sc_person = 0;
scp->sc_comp = 0;
scp->sc_level = 0;
}
/* read the top ten file into the array and close the file */
if ((fd = open(SCOREFILE, 2)) < 0) {
printf("no score file\n");
return;
}
(void) read(fd, (char *) top_ten, sizeof(top_ten));
/* Print the list */
if (Read) {
printf("Top Players:\n");
printf("Level\tDimensions Computer Human\tName\n");
for (scp = top_ten; scp < &top_ten[10]; scp++)
if (scp->sc_person) {
printf("%s\t %2d X %2d %3d %3d\t%s",
(scp->sc_level == DUMB) ?
"Easy" : (scp->sc_level == HARD ?
"Hard" : "Killer"),
scp->sc_width,
scp->sc_length, scp->sc_comp, scp->sc_person, scp->sc_name);
if (names)
printf("(%s)", scp->sc_login);
putchar('\n');
} else
break;
}
/* check to see if current score made it */
else {
for (scp = top_ten; scp < &top_ten[10]; scp++)
if (value_cmp(scp))
break;
if (scp < &top_ten[10]) {
char *getlogin(), *login = getlogin();
for (temp = &top_ten[9]; temp > scp; temp--)
*temp = *(temp - 1);
scp->sc_width = Width;
scp->sc_length = Length;
scp->sc_person = persontally;
scp->sc_comp = comptally;
scp->sc_level = level;
(void) strcpy(scp->sc_login, login);
addstr("--more--"), clrtoeol();
refresh();
raw(), noraw();
while (getchar() != ' ')
fputc(7, stderr);
msg("You made the top ten! Enter a name: ");
Getstr(scp->sc_name, NAMELEN - 1);
if (strlen(scp->sc_name) > 1) {
(void) lseek(fd, (long)0, 0);
(void) write(fd, (char *)top_ten, sizeof top_ten);
} else
msg("Nothing entered.");
}
(void) close(fd);
}
}
value_cmp(entry)
struct scores *entry;
{
int value;
value = (level - entry->sc_level) * 500;
value += persontally + Length * Width;
return (value > entry->sc_length * entry->sc_width + entry->sc_person);
}