savegame.c: consistent indentation

This commit is contained in:
wdlkmpx 2021-01-14 23:21:06 +08:00
parent 7c49070107
commit 565348506b

View File

@ -17,15 +17,15 @@
#include "game.h" #include "game.h"
gint parse_save_game(gchar *sgame, gchar **rules, gint *score, gint **board, gint **next) { gint parse_save_game(gchar *sgame, gchar **rules, gint *score, gint **board, gint **next)
{
struct stat buf; struct stat buf;
gchar *sdata, *psdata, *srules; gchar *sdata, *psdata, *srules;
FILE *f; FILE *f;
gint i, val; gint i, val;
gint rw, rh, rc, rn, rd, rlen; gint rw, rh, rc, rn, rd, rlen;
if(stat(sgame, &buf) != 0 || !S_ISREG(buf.st_mode) || buf.st_size < 20 || if (stat(sgame, &buf) != 0 || !S_ISREG(buf.st_mode) || buf.st_size < 20 || (f = fopen(sgame, "r")) == NULL) {
(f = fopen(sgame, "r")) == NULL) {
return 0; return 0;
} }
@ -84,9 +84,11 @@ gint parse_save_game(gchar *sgame, gchar **rules, gint *score, gint **board, gin
return 1; return 1;
} }
/* check that save game name is in form YYYY-MM-DD-HHMMSS.sav and have correct content /* check that save game name is in form YYYY-MM-DD-HHMMSS.sav and have correct content
return string "DD.MM.YYYY HH:MM:SS (score)" on success, NULL on failure */ return string "DD.MM.YYYY HH:MM:SS (score)" on success, NULL on failure */
gchar *is_valid_save_game(gchar *name, gchar *path) { gchar *is_valid_save_game(gchar *name, gchar *path)
{
guint i, y, m, d, h, min, s; guint i, y, m, d, h, min, s;
gint score, *board, *next; gint score, *board, *next;
gchar *sgame; gchar *sgame;
@ -118,7 +120,9 @@ gchar *is_valid_save_game(gchar *name, gchar *path) {
*/ */
} }
gint get_saved_games(gchar ***gamelist) {
gint get_saved_games(gchar ***gamelist)
{
gchar *datapath; gchar *datapath;
struct stat buf; struct stat buf;
struct dirent *dir_entry; struct dirent *dir_entry;
@ -136,7 +140,8 @@ gint get_saved_games(gchar ***gamelist) {
g_free (datapath); g_free (datapath);
return -1; return -1;
} }
if((directory = opendir(datapath))) { if ((directory = opendir(datapath)))
{
while ((dir_entry = readdir(directory))) { while ((dir_entry = readdir(directory))) {
if ((game = is_valid_save_game(dir_entry->d_name, datapath)) != NULL) { if ((game = is_valid_save_game(dir_entry->d_name, datapath)) != NULL) {
num++; num++;
@ -152,7 +157,9 @@ gint get_saved_games(gchar ***gamelist) {
return num; return num;
} }
gchar *save_game(gchar *rules, gint score, gint *board, gint *nextcolors) {
gchar *save_game(gchar *rules, gint score, gint *board, gint *nextcolors)
{
FILE *f; FILE *f;
gchar *fname; gchar *fname;
time_t nowtime; time_t nowtime;