aboutsummaryrefslogtreecommitdiff
path: root/scores.c
diff options
context:
space:
mode:
Diffstat (limited to 'scores.c')
-rw-r--r--scores.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/scores.c b/scores.c
index 117f2da..f840692 100644
--- a/scores.c
+++ b/scores.c
@@ -28,7 +28,7 @@
#define SCOREFILE "worm.hi"
struct score {
- char initials[3];
+ char initials[4];
int score;
};
@@ -93,11 +93,12 @@ char scorebuf[8];
fgets(scorebuf, 8, fp);
scores[i].score = atoi(scorebuf);
}
+ scores[i].initials[3] = '\0';
fclose(fp);
} else {
for(i=0;i<10;i++) {
- memcpy(scores[i].initials, defaults[9-i], 3);
- scores[i].score = i == 0 ? 10 : (i * 100 + 100);
+ memcpy(scores[i].initials, defaults[i], 4);
+ scores[9-i].score = i == 0 ? 10 : (i * 500 + 100);
}
}
free(filename);
@@ -120,4 +121,8 @@ int i;
free(filename);
}
-
+char *get_score_at(int pos, int *score)
+{
+ *score = scores[pos].score;
+ return scores[pos].initials;
+}