Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
vor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
markdownify readmes
[vor.git]
/
score.c
diff --git
a/score.c
b/score.c
index
b9c666e
..
8c5bc59
100644
(file)
--- a/
score.c
+++ b/
score.c
@@
-25,32
+25,33
@@
#include "font.h"
#include "common.h"
#include "font.h"
#include "common.h"
-#include "config.h"
+#include "vorconfig.h"
#include "file.h"
#include "globals.h"
#include "score.h"
// High score table
#include "file.h"
#include "globals.h"
#include "score.h"
// High score table
+// below are the defaults (when there's no high score file) in miliseconds
struct highscore g_scores[2][N_SCORES] = {
{
struct highscore g_scores[2][N_SCORES] = {
{
- {1*60*1000,"-"},
- {45*1000,"-"},
- {30*1000,"-"},
- {20*1000,"-"},
- {10*1000,"-"},
- {7*1000,"-"},
- {5*1000,"-"},
- {3*1000,"-"}
+ {120000,"-"},
+ {105000,"-"},
+ { 90000,"-"},
+ { 75000,"-"},
+ { 60000,"-"},
+ { 50000,"-"},
+ { 40000,"-"},
+ { 30000,"-"}
},
{
},
{
- {1*60*1000,"-"},
- {45*1000,"-"},
- {30*1000,"-"},
- {20*1000,"-"},
- {10*1000,"-"},
- {7*1000,"-"},
- {5*1000,"-"},
- {3*1000,"-"}
+ {120000,"-"},
+ {105000,"-"},
+ { 90000,"-"},
+ { 75000,"-"},
+ { 60000,"-"},
+ { 50000,"-"},
+ { 40000,"-"},
+ { 30000,"-"}
}
};
}
};
@@
-63,15
+64,21
@@
void
read_high_score_table()
{
FILE *f;
read_high_score_table()
{
FILE *f;
- int i, j;
+ int i, j, ret;
f = open_score_file("r");
if(f) {
// If the file exists, read from it
for(j=0; j<2; j++) {
f = open_score_file("r");
if(f) {
// If the file exists, read from it
for(j=0; j<2; j++) {
- fscanf(f, titles[j]);
+ ret = fseek(f, strlen(titles[j]), SEEK_CUR);
+ if (ret != 0) {
+ break;
+ }
for(i = 0; i<N_SCORES; i++) {
for(i = 0; i<N_SCORES; i++) {
- fscanf(f, "%d %31[^\n]\n", &g_scores[j][i].score, g_scores[j][i].name);
+ ret = fscanf(f, "%d %31[^\n]\n", &g_scores[j][i].score, g_scores[j][i].name);
+ if (ret != 2) {
+ break;
+ }
}
}
fclose(f);
}
}
fclose(f);
@@
-88,7
+95,7
@@
write_high_score_table()
if(f) {
// If the file exists, write to it
for(j=0; j<2; j++) {
if(f) {
// If the file exists, write to it
for(j=0; j<2; j++) {
- fprintf(f, titles[j]);
+ fprintf(f, "%s", titles[j]);
for(i = 0; i<N_SCORES; i++) {
fprintf (f, "%d %.31s\n", g_scores[j][i].score, g_scores[j][i].name);
}
for(i = 0; i<N_SCORES; i++) {
fprintf (f, "%d %.31s\n", g_scores[j][i].score, g_scores[j][i].name);
}
@@
-143,7
+150,7
@@
snprintscore(char *s, size_t n, int score)
if(min) {
return snprintf(s, n, "%2d:%.2d.%d", min, sec, tenths);
} else {
if(min) {
return snprintf(s, n, "%2d:%.2d.%d", min, sec, tenths);
} else {
- return snprintf(s, n, "%2d.%d", sec, tenths);
+ return snprintf(s, n, " %2d.%d", sec, tenths);
}
}
}
}
@@
-161,6
+168,8
@@
display_scores(uint32_t x, uint32_t y)
{
char t[1024];
int i,h = font_height();
{
char t[1024];
int i,h = font_height();
+ int display_cursor = (SDL_GetTicks() / CURSOR_BLINK_TIME) % 2;
+
font_write(x+30, y, "High scores");
y += h;
font_write(x+30, y, "High scores");
y += h;
@@
-172,7
+181,7
@@
display_scores(uint32_t x, uint32_t y)
font_write(x, y, t);
snprintscore(t, 1024, g_scores[g_easy][i].score);
font_write(x+50, y, t);
font_write(x, y, t);
snprintscore(t, 1024, g_scores[g_easy][i].score);
font_write(x+50, y, t);
- if(i == cur_score) snprintf(t, 1024, "%s_", g_scores[g_easy][i].name);
+ if(display_cursor && i == cur_score) snprintf(t, 1024, "%s_", g_scores[g_easy][i].name);
else snprintf(t, 1024, "%s", g_scores[g_easy][i].name);
font_write(x+180, y, t);
}
else snprintf(t, 1024, "%s", g_scores[g_easy][i].name);
font_write(x+180, y, t);
}
@@
-190,7
+199,7
@@
process_score_input(SDL_keysym *key)
if(key->sym == SDLK_BACKSPACE) {
if(n > 0) name[--n]=0;
} else {
if(key->sym == SDLK_BACKSPACE) {
if(n > 0) name[--n]=0;
} else {
- if(key->sym == SDLK_RETURN) {
+ if(key->sym == SDLK_RETURN || key->sym == SDLK_KP_ENTER) {
SDL_EnableUNICODE(0);
cur_score = -1;
if(n == 0) {
SDL_EnableUNICODE(0);
cur_score = -1;
if(n == 0) {