File: highscore_io.h

package info (click to toggle)
rockdodger 0.9.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,220 kB
  • ctags: 756
  • sloc: ansic: 5,374; makefile: 159; sh: 21
file content (53 lines) | stat: -rw-r--r-- 1,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef __HIGHSCORE_IO_H_20101222__
#define __HIGHSCORE_IO_H_20101222__

#define MAXIMUM_HIGH_SCORE_ENTRIES 8

/*! \brief Highscore table structure
 * 
 * The highscore table consists of the score, a char pointer to the
 * name of the winner, the level reached and an integer called
 * "allocated" which is set to 1 if the memory for the name was
 * allocated, 0 otherwise.
 */
struct highscore {
  long score;
  char *name;
  int level;
  int allocated;
};

//! high is a an array of highscore structs.
extern struct highscore high[EDITION_MAXIMUM_EDITION][MAXIMUM_HIGH_SCORE_ENTRIES];

extern long score;		//!< The current score.
extern int scorerank;		//!< minus one means no scorerank, we are not worthy
extern char name_input_buf[];	//!< name input buffer

FILE *hs_fopen(const char *mode);
void read_high_score_table();
void write_high_score_table();

/*! \brief Increment the score
 *
 * Increment the score counter. Currently there is no dependency on
 * the coordinates.
 *
 * \param x x coordinate of the item
 * \param y y coordinate of the item
 * \param dscore points to add
 */
void inc_score(int x, int y, long dscore);

/*! \brief clear score
 *
 * Clear the score counter and return old score.
 *
 * \return old score
 */
long clear_score(void);

/*! \brief handle game over (get lowest highscore, etc.)
 */
void game_over();
#endif