inputname.c: consistent indentation

This commit is contained in:
wdlkmpx 2021-01-14 21:50:35 +08:00
parent 9cf177147d
commit 2a361fec55

View File

@ -21,7 +21,8 @@ static GtkWidget *_dialog = NULL;
static gchar _last_player_name[15] = "";
static gint _saved_score = 0;
void read_entry(GtkWidget *widget, gpointer data) {
void read_entry(GtkWidget *widget, gpointer data)
{
struct score_board current_entry;
time_t current_time;
struct tm *timeptr;
@ -37,16 +38,17 @@ void read_entry(GtkWidget *widget, gpointer data) {
current_entry.score = _saved_score;
current_time = time(NULL);
timeptr = localtime(&current_time);
if(!timeptr) {
if (!timeptr) {
ut_simple_message_box(_("Unable to determine current date.\n"));
strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date));
} else {
if(!strftime(current_entry.date, sizeof(current_entry.date), _("%a %b %d %H:%M %Y"), timeptr)) {
if (!strftime(current_entry.date, sizeof(current_entry.date), _("%a %b %d %H:%M %Y"), timeptr)) {
ut_simple_message_box(_("Unable to determine current date.\n"));
strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date));
} else {
tstr = g_locale_to_utf8(current_entry.date, -1, &br, &bw, NULL);
if(!tstr) {
if (!tstr) {
strncpy(current_entry.date, _("Unknown"), sizeof(current_entry.date));
} else {
strncpy(current_entry.date, tstr, sizeof(current_entry.date));
@ -55,16 +57,16 @@ void read_entry(GtkWidget *widget, gpointer data) {
}
}
if(!read_score(b, &bf, &fbn)) {
if (!read_score(b, &bf, &fbn)) {
ut_simple_message_box (_("Unable to read score.\n"));
} else {
pos = insert_entry_in_score_board(b, current_entry);
if(!write_score(b, bf, fbn)) {
if (!write_score(b, bf, fbn)) {
ut_simple_message_box(_("Unable to save score.\n"));
}
/*FIXME: free bf here */
free_score_board_full(bf, fbn);
if(pos != -1) {
if (pos != -1) {
pos++;
show_hall_of_fame(NULL, (gpointer)pos, b);
}
@ -74,11 +76,13 @@ void read_entry(GtkWidget *widget, gpointer data) {
/* show scores to let user see if (s)he's on top ;) */
}
void input_name_dialog(void) {
GtkWidget *prompt_label, * vbox;
GtkWidget *name;
GtkWidget *button;
gchar *s;
void input_name_dialog(void)
{
GtkWidget * prompt_label, * vbox;
GtkWidget * name;
GtkWidget * button;
gchar * s;
/* we have to save score, because they will be set to 0 in new_game() */
_saved_score = game_get_score();
@ -97,8 +101,8 @@ void input_name_dialog(void) {
g_signal_connect(G_OBJECT(name), "activate", G_CALLBACK(read_entry), name);
/* restore the last player's name */
if(!(*_last_player_name)) {
if((s = getenv("USER"))) {
if (!(*_last_player_name)) {
if ((s = getenv("USER"))) {
strncpy(_last_player_name, s, sizeof(_last_player_name));
}
}