/* * highscore.h */ #ifndef HIGHSCORE_H #define HIGHSCORE_H 1 #include #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 */ uint8_t upload; /* Need upload */ }; struct best_level { struct best_level_score { uint64_t gameid; int64_t score; uint8_t upload; } score[MAX_PER_LEVEL]; struct best_level_time { uint64_t gameid; int32_t time_ms; uint8_t upload; } 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, uint8_t upload); int highscore_add_level_score(uint64_t gameid, int lvl, int64_t score, uint8_t upload); int highscore_add_level_time(uint64_t gameid, int lvl, int32_t time_ms, uint8_t upload); void highscore_init(void); void highscore_parse(void *f, char (*mygets)(char *, int, void *), uint8_t upload); int highscore_write(void *f, int (*myputs)(char *, void *), uint8_t leave); #endif