diff options
author | H. Peter Anvin <hpa@zytor.com> | 2003-03-25 05:28:10 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2003-03-25 05:28:10 +0000 |
commit | 37ae1353fb4ef6013b688b28cd82f06182ad3063 (patch) | |
tree | 7d7c3029d3b5f14d4da2997718b523e47362aea9 /highscore.h | |
parent | 1128ad360b5cccb1b82de092505e5ca1c4dbed8d (diff) | |
download | grv-37ae1353fb4ef6013b688b28cd82f06182ad3063.tar.gz grv-37ae1353fb4ef6013b688b28cd82f06182ad3063.tar.xz grv-37ae1353fb4ef6013b688b28cd82f06182ad3063.zip |
Add support for high score tables, including the ability to generate
a (hopefully) unique ID for each game that we can use to match identical
records.
Diffstat (limited to 'highscore.h')
-rw-r--r-- | highscore.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/highscore.h b/highscore.h new file mode 100644 index 0000000..bb531ee --- /dev/null +++ b/highscore.h @@ -0,0 +1,50 @@ +/* + * highscore.h + */ + +#ifndef HIGHSCORE_H +#define HIGHSCORE_H 1 + +#include <inttypes.h> + +#define PLAYER_LEN 11 /* Max length of player alias */ +#define MAX_BEST 100 /* Number of best_total to keep track of */ +#define MAX_LEVEL 75 /* Max levels to keep track of */ +#define MAX_PER_LEVEL 3 /* Max "bests" per level */ + +struct best_total { + uint64_t gameid; /* GameID */ + int64_t score; /* Final score */ + int32_t endlvl; /* Ending level (-1) */ + unsigned char player[PLAYER_LEN+1]; /* Player alias */ +}; + +struct best_level { + struct best_level_score { + uint64_t gameid; + int64_t score; + } score[MAX_PER_LEVEL]; + struct best_level_time { + uint64_t gameid; + int32_t time_ms; + } time_ms[MAX_PER_LEVEL]; +}; + +struct bests { + struct best_total total[MAX_BEST]; + struct best_level level[MAX_LEVEL]; +}; + +extern struct bests bests; + +#define NO_TIME 0x7fffffff /* Max int32_t value */ + +int highscore_add_total(uint64_t gameid, int64_t score, int endlvl, unsigned char **pptr); +int highscore_add_level_score(uint64_t gameid, int lvl, int64_t score); +int highscore_add_level_time(uint64_t gameid, int lvl, int32_t time_ms); +void highscore_init(void); +void highscore_parse(FILE *f); +int highscore_write(FILE *f); + + +#endif |