Definition of the functions related to high scores.
More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include "hscores.h"
#include "player.h"
Go to the source code of this file.
Definition of the functions related to high scores.
Definition in file hscores.c.
int create_directory |
( |
char * |
path) | |
|
Creates a directory on #path.
- Returns
- -1 on error, 0 on success.
- Note
- Creates with permissions 755.
Definition at line 127 of file hscores.c.
int create_file |
( |
char * |
path) | |
|
Creates a file.
- Returns
- 1 if successful, 0 if failed
Definition at line 157 of file hscores.c.
int directory_exists |
( |
char * |
path) | |
|
Local function that tests if the directory #path exists.
- Note
- Must be a null-terminated absolute path.
- Returns
- 1 if directory exists, 0 if it doesn't.
Definition at line 104 of file hscores.c.
int file_exists |
( |
char * |
path) | |
|
Check if a file exists.
- Returns
- 0 if doesnt exist, 1 if exists
Definition at line 135 of file hscores.c.
Restore the Highscores to the default.
- Note
- If the Highscores file doesn't exist, it is created.
Definition at line 203 of file hscores.c.
int hscore_file_check |
( |
) | |
|
Tells if the high score file is accessible.
- Returns
- 0 if success, 1 if failed.
Definition at line 170 of file hscores.c.
int hscore_globals_init |
( |
) | |
|
Initializes all global variables needed for high scores.
- Note
- Can be called multiple times, won't overwrite things.
Definition at line 72 of file hscores.c.
Creates/reads from the High Score file.
First, we try to open for reading. If it doesn't exist, then we open it for writing, effectively creating it.
- Note
- The path to the score file is defined by the Makefile. Currently, it is /var/games/.nsnake.scores
- Todo:
- clean this code. Lots of useless ifs and elses.
Definition at line 236 of file hscores.c.
int HIGH_SCORE_BORDERS = 0 |
The separate Highscore for the game mode with borders.
HighScore of the game mode with borders.
Definition at line 58 of file hscores.c.
int HIGH_SCORE_BORDERS_OFF = 0 |
The separate Highscore for the game mode without borders.
HighScore of the game mode without borders.
Definition at line 61 of file hscores.c.