scoreboard.c/h: consistent indentation
This commit is contained in:
parent
565348506b
commit
a43f2eb39b
@ -1,7 +1,7 @@
|
|||||||
/* scoreboard.c - save/load scores
|
/* scoreboard.c - save/load scores
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public
|
* modif (y it under the terms of the GNU General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2 of the License, or (at your option) any later version.
|
* version 2 of the License, or (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
@ -23,12 +23,15 @@
|
|||||||
|
|
||||||
int _score_fd = -1;
|
int _score_fd = -1;
|
||||||
|
|
||||||
gint score_setup(void) {
|
gint score_setup(void)
|
||||||
|
{
|
||||||
_score_fd = child_setup(SCORE_FILE);
|
_score_fd = child_setup(SCORE_FILE);
|
||||||
return _score_fd;
|
return _score_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_score_board_full(struct score_board_full *bf, gint nbf) {
|
|
||||||
|
void free_score_board_full(struct score_board_full *bf, gint nbf)
|
||||||
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < nbf; i++) {
|
for (i = 0; i < nbf; i++) {
|
||||||
@ -37,7 +40,9 @@ void free_score_board_full(struct score_board_full *bf, gint nbf) {
|
|||||||
g_free(bf);
|
g_free(bf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint write_score(struct score_board *b, struct score_board_full *bf, gint nbf) {
|
|
||||||
|
gint write_score(struct score_board *b, struct score_board_full *bf, gint nbf)
|
||||||
|
{
|
||||||
gint i;
|
gint i;
|
||||||
gchar *buf, *tname, *tdate, *rules;
|
gchar *buf, *tname, *tdate, *rules;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
@ -46,7 +51,8 @@ gint write_score(struct score_board *b, struct score_board_full *bf, gint nbf) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
if (strlen(b[i].name)) {
|
if (strlen(b[i].name)) {
|
||||||
tname = g_strdup(b[i].name);
|
tname = g_strdup(b[i].name);
|
||||||
if (!tname) {
|
if (!tname) {
|
||||||
@ -82,13 +88,17 @@ gint write_score(struct score_board *b, struct score_board_full *bf, gint nbf) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int score_sort(const void *a, const void *b) {
|
|
||||||
|
int score_sort(const void *a, const void *b)
|
||||||
|
{
|
||||||
if (((const struct score_board *)a)->score == ((const struct score_board *)b)->score) return 0;
|
if (((const struct score_board *)a)->score == ((const struct score_board *)b)->score) return 0;
|
||||||
if (((const struct score_board *)a)->score < ((const struct score_board *)b)->score) return 1;
|
if (((const struct score_board *)a)->score < ((const struct score_board *)b)->score) return 1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint read_score(struct score_board *b, struct score_board_full **bf, gint *nbf) {
|
|
||||||
|
gint read_score(struct score_board *b, struct score_board_full **bf, gint *nbf)
|
||||||
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
gchar buffer[BUFFER_SIZE];
|
gchar buffer[BUFFER_SIZE];
|
||||||
gchar **str_val, *tstr, **tstr_val;
|
gchar **str_val, *tstr, **tstr_val;
|
||||||
@ -114,12 +124,14 @@ gint read_score(struct score_board *b, struct score_board_full **bf, gint *nbf)
|
|||||||
|
|
||||||
sc = 0;
|
sc = 0;
|
||||||
fsc = 0;
|
fsc = 0;
|
||||||
while(fgets(buffer, BUFFER_SIZE, fp)) {
|
while (fgets(buffer, BUFFER_SIZE, fp))
|
||||||
|
{
|
||||||
g_strchomp(buffer);
|
g_strchomp(buffer);
|
||||||
str_val = g_strsplit(buffer, "\t", 4);
|
str_val = g_strsplit(buffer, "\t", 4);
|
||||||
if (str_val[0] && str_val[0][0] &&
|
if (str_val[0] && str_val[0][0] &&
|
||||||
str_val[1] && str_val[1][0] &&
|
str_val[1] && str_val[1][0] &&
|
||||||
str_val[2] && str_val[2][0]) {
|
str_val[2] && str_val[2][0])
|
||||||
|
{
|
||||||
valid = 0;
|
valid = 0;
|
||||||
if (!str_val[3]) { /* < 2.2.0 file for mat */
|
if (!str_val[3]) { /* < 2.2.0 file for mat */
|
||||||
g_rules = rules_get_classic_as_str();
|
g_rules = rules_get_classic_as_str();
|
||||||
@ -197,7 +209,9 @@ gint read_score(struct score_board *b, struct score_board_full **bf, gint *nbf)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint insert_entry_in_score_board(struct score_board *board, struct score_board entry) {
|
|
||||||
|
gint insert_entry_in_score_board(struct score_board *board, struct score_board entry)
|
||||||
|
{
|
||||||
gint i=0,j;
|
gint i=0,j;
|
||||||
|
|
||||||
if (entry.score <= 0) {
|
if (entry.score <= 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user