[tali] Code convention fixes



commit 49eafc3e73dc0bb4ea4f428108f52c7e1ddbcdbe
Author: Sahil Sareen <sahil sareen hotmail com>
Date:   Tue Oct 21 10:29:15 2014 +0530

    Code convention fixes
    
    Cleanup of tali source code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738885

 src/clist.c                |   20 ++++----
 src/computer.c             |   31 ++++++-----
 src/games-scores-backend.c |    2 +-
 src/games-scores-dialog.c  |    8 ++-
 src/gyahtzee.c             |   92 ++++++++++++++++----------------
 src/setup.c                |   46 ++++++++--------
 src/yahtzee.c              |  124 ++++++++++++++++++++++----------------------
 7 files changed, 163 insertions(+), 160 deletions(-)
---
diff --git a/src/clist.c b/src/clist.c
index 3acd6c6..7d3c6e5 100644
--- a/src/clist.c
+++ b/src/clist.c
@@ -126,7 +126,7 @@ static gint gtk_tree_path_to_row (GtkTreePath *path)
 
 /* Convert the row of a tree into the score row */
 
-static gint score_row(GtkTreePath *path)
+static gint score_row (GtkTreePath *path)
 {
     gint row = gtk_tree_path_to_row (path);
     if (row == R_UTOTAL || row == R_BONUS || row == R_BLANK1 ||
@@ -157,16 +157,16 @@ row_activated_cb (GtkTreeView * treeview, GtkTreePath * path,
       if (play_score (CurrentPlayer, row) == SLOT_USED) {
         say (_("Already used! " "Where do you want to put that?"));
       } else {
-        UndoScoreElement *elem = RedoHead();
+        UndoScoreElement *elem = RedoHead ();
         if (elem && elem->player == CurrentPlayer) {
-          RedoPlayer();
+          RedoPlayer ();
         } else {
           NextPlayer ();
         }
       }
     }
   }
-  update_undo_sensitivity();
+  update_undo_sensitivity ();
 }
 
 static gboolean
@@ -220,10 +220,10 @@ tree_query_tooltip_cb (GtkWidget * widget, gint x, gint y,
     GtkTreeIter  *iter_ptr  = NULL;
     gint rval = FALSE;
 
-    if (gtk_tree_view_get_tooltip_context ( GTK_TREE_VIEW (widget), &x, &y,
+    if (gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget), &x, &y,
                 keyboard_mode, &model_ptr, &path_ptr, iter_ptr)) {
         if (path_ptr) {
-            gint row = score_row(path_ptr);
+            gint row = score_row (path_ptr);
             if (row >= 0) {
                 gtk_tooltip_set_text (tooltip, row_tooltips[row]);
                 rval = TRUE;
@@ -401,19 +401,19 @@ setup_score_list (GtkWidget * treeview)
 }
 
 void
-update_score_tooltips(void)
+update_score_tooltips (void)
 {
     gint ii;
 
     for (ii = 0; ii < NUM_FIELDS; ii++) {
         gint score = player_field_score (CurrentPlayer, ii);
-        if (!row_tooltips[ii]) row_tooltips[ii] = g_new0(gchar, 100);
+        if (!row_tooltips[ii]) row_tooltips[ii] = g_new0 (gchar, 100);
 
 
         if (score >= 0)
-            sprintf(row_tooltips[ii], _("Score: %d"), score);
+            sprintf (row_tooltips[ii], _("Score: %d"), score);
         else
-            sprintf(row_tooltips[ii], _("Field used"));
+            sprintf (row_tooltips[ii], _("Field used"));
     }
 }
 
diff --git a/src/computer.c b/src/computer.c
index 1144137..6b0745b 100644
--- a/src/computer.c
+++ b/src/computer.c
@@ -68,7 +68,7 @@ BuildTable (int player)
 **     ok. now we set a base value on the roll based on its count and
 **     how much it is worth to us.
 */
-    bc_table[i] = (count(i + 1) - 2) * (i + 1) * 4 - (i + 1);
+    bc_table[i] = (count (i + 1) - 2) * (i + 1) * 4 - (i + 1);
   }
 
 /*
@@ -169,23 +169,22 @@ ComputerRolling (int player)
       num_options *= 2;
   }
 
-  {
   double avg_score[num_options];
   DiceInfo sav_DiceValues[NUMBER_OF_DICE];
-  memset(avg_score, 0, sizeof(avg_score));
-  memcpy(sav_DiceValues, DiceValues, sizeof(sav_DiceValues));
+  memset (avg_score, 0, sizeof (avg_score));
+  memcpy (sav_DiceValues, DiceValues, sizeof (sav_DiceValues));
 
   for (ii = 0; ii < num_options; ii++) {
       for (jj = 0; jj < NUM_TRIALS; jj++) {
           DiceInfo loc_info[NUMBER_OF_DICE];
-          memcpy(loc_info, sav_DiceValues, sizeof(loc_info));
+          memcpy (loc_info, sav_DiceValues, sizeof (loc_info));
           for (kk = 0; kk < NUMBER_OF_DICE; kk++) {
               if (die_comp[kk] & ii) {
-                  loc_info[kk].val = RollDie();
+                  loc_info[kk].val = RollDie ();
               }
           }
-          memcpy(DiceValues, loc_info, sizeof(sav_DiceValues));
-          BuildTable(player);
+          memcpy (DiceValues, loc_info, sizeof (sav_DiceValues));
+          BuildTable (player);
           bestv = -99;
           for (i = NUM_FIELDS - 1; i >= 0; i--) {
               if (bc_table[i] >= bestv) {
@@ -206,21 +205,23 @@ ComputerRolling (int player)
           best_score = avg_score[ii];
       }
   }
-  if (DisplayComputerThoughts) printf("Best choice is %d val %f for dice ", best, best_score);
+  if (DisplayComputerThoughts) printf ("Best choice is %d val %f for dice ", best, best_score);
 
   /* Restore DiceValues */
-  memcpy(DiceValues, sav_DiceValues, sizeof(sav_DiceValues));
+  memcpy (DiceValues, sav_DiceValues, sizeof (sav_DiceValues));
   for (ii = 0; ii < NUMBER_OF_DICE; ii++) {
       if (die_comp[ii] & best) {
           DiceValues[ii].sel = 1;
-          if (DisplayComputerThoughts) printf("Reset to roll die %d value %d bit %d comp %d test %d\n", ii, 
DiceValues[ii].val, ii, best, ii & best);
+          if (DisplayComputerThoughts)
+             printf ("Reset to roll die %d value %d bit %d comp %d test %d\n", ii, DiceValues[ii].val, ii, 
best, ii & best);
       }
       else {
           DiceValues[ii].sel = 0;
-          if (DisplayComputerThoughts) printf("Reset NOT to roll die %d value %d bit %d comp %d test %d\n", 
ii, DiceValues[ii].val, ii, best, ii & best);
+          if (DisplayComputerThoughts)
+             printf ("Reset NOT to roll die %d value %d bit %d comp %d test %d\n",
+                     ii, DiceValues[ii].val, ii, best, ii & best);
       }
   }
-  }
 }
 
 /*
@@ -270,8 +271,8 @@ ComputerScoring (int player)
   }
 
   if (DisplayComputerThoughts)
-      fprintf(stderr, "I choose category %d as best %d score name %s\n",
-              best, bc_table[best], _(FieldLabels[best]));
+      fprintf (stderr, "I choose category %d as best %d score name %s\n",
+               best, bc_table[best], _(FieldLabels[best]));
 
   play_score (player, best);
 
diff --git a/src/games-scores-backend.c b/src/games-scores-backend.c
index 5b22534..26e2f93 100644
--- a/src/games-scores-backend.c
+++ b/src/games-scores-backend.c
@@ -305,7 +305,7 @@ games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
       break;
     case GAMES_SCORES_STYLE_TIME_DESCENDING:
     case GAMES_SCORES_STYLE_TIME_ASCENDING:
-      rscore = games_score_get_value_as_time(d);
+      rscore = games_score_get_value_as_time (d);
       break;
     default:
       g_assert_not_reached ();
diff --git a/src/games-scores-dialog.c b/src/games-scores-dialog.c
index ec53ecb..9018543 100644
--- a/src/games-scores-dialog.c
+++ b/src/games-scores-dialog.c
@@ -221,7 +221,8 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
     case GAMES_SCORES_STYLE_TIME_DESCENDING:
       dscore = games_score_get_value_as_time ((GamesScore *)scorelist->data);
       score = (int) (100.0 * dscore + 0.5);
-      ss = g_strdup_printf (/* Score format for time based scores.  %1$d is the time in minutes, %2$d is the 
time in seconds */
+      ss = g_strdup_printf (/* Score format for time based scores.
+                              %1$d is the time in minutes, %2$d is the time in seconds */
                             C_("score-dialog", "%1$dm %2$ds"),
                             score/100, score%100);
       break; 
@@ -306,7 +307,7 @@ void games_scores_dialog_set_category_description (GamesScoresDialog *self,
   lstr = g_strdup_printf ("<b>%s</b>", description);
   gtk_label_set_markup (GTK_LABEL (self->priv->label), lstr);
   gtk_label_set_use_underline (GTK_LABEL (self->priv->label), TRUE);
-  g_free(lstr);
+  g_free (lstr);
 }
 
 /**
@@ -474,7 +475,8 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
   self->priv->treeview = GTK_TREE_VIEW (listview);
 
   timerenderer = gtk_cell_renderer_text_new ();
-  timecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the date the 
score was recorded */
+  timecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the date
+                                                           the score was recorded */
                                                          _("Date"),
                                                          timerenderer,
                                                          "text", 0,
diff --git a/src/gyahtzee.c b/src/gyahtzee.c
index 45e03f8..0296635 100644
--- a/src/gyahtzee.c
+++ b/src/gyahtzee.c
@@ -58,9 +58,9 @@ static guint last_timeout = 0;
 static gboolean ready_to_advance_player;
 
 #define NUMBER_OF_PIXMAPS    7
-#define GAME_TYPES 2
+#define GAME_TYPES           2
 #define DIE_SELECTED_PIXMAP  (NUMBER_OF_PIXMAPS-1)
-#define SCORES_CATEGORY (game_type == GAME_KISMET ? "Colors" : NULL)
+#define SCORES_CATEGORY      (game_type == GAME_KISMET ? "Colors" : NULL)
 
 static char *dicefiles[NUMBER_OF_PIXMAPS] = { "gnome-dice-1.svg",
   "gnome-dice-2.svg",
@@ -135,7 +135,7 @@ update_roll_button_sensitivity (void)
     state |=
       gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (diceBox[i]));
 
-  if(!state){
+  if (!state) {
     gtk_button_set_label (GTK_BUTTON (mbutton), _("Roll all!"));
     state = TRUE;
   } else {
@@ -146,7 +146,7 @@ update_roll_button_sensitivity (void)
   state &= NumberOfRolls < 3;
   state &= !players[CurrentPlayer].comp;
 
-  if(GameIsOver ()){
+  if (GameIsOver ()) {
     state = FALSE;
   }
 
@@ -245,7 +245,7 @@ do_computer_turns (void)
 /* Show the current score and prompt for current player state */
 
 void
-DisplayCurrentPlayer(void) {
+DisplayCurrentPlayer (void) {
   ShowoffPlayer (ScoreList, CurrentPlayer, 1);
 
   if (players[CurrentPlayer].name) {
@@ -259,11 +259,11 @@ DisplayCurrentPlayer(void) {
 
 /* Display current player and refresh dice/display */
 void
-DisplayCurrentPlayerRefreshDice(void) {
-  DisplayCurrentPlayer();
+DisplayCurrentPlayerRefreshDice (void) {
+  DisplayCurrentPlayer ();
   UpdateAllDicePixmaps ();
   DeselectAllDice ();
-  UpdateRollLabel();
+  UpdateRollLabel ();
 }
 
 void
@@ -278,8 +278,8 @@ NextPlayer (void)
         NumberOfRolls = NUM_ROLLS;
     else
         NumberOfRolls = LastHumanNumberOfRolls;
-    /* update_roll_button_sensitivity() needs to be called in
-       this context however UpdateRollLabel() also calls that method */
+    /* update_roll_button_sensitivity () needs to be called in
+       this context however UpdateRollLabel () also calls that method */
     UpdateRollLabel ();
     CheerWinner ();
     return;
@@ -294,10 +294,10 @@ NextPlayer (void)
     CurrentPlayer = (CurrentPlayer + 1) % NumberOfPlayers;
   } while (players[CurrentPlayer].finished);
 
-  DisplayCurrentPlayer();
+  DisplayCurrentPlayer ();
   SelectAllDice ();
   RollSelectedDice ();
-  FreeRedoList();
+  FreeRedoList ();
 
   /* Remember the roll count if this turn is for a
      human player for display at the end of the game */
@@ -322,41 +322,41 @@ NextPlayer (void)
 /* Go back to the previous player */
 
 void
-PreviousPlayer(void)
+PreviousPlayer (void)
 {
-  if (UndoPossible()) {
+  if (UndoPossible ()) {
     NumberOfRolls = 1;
     ready_to_advance_player = FALSE;
     ShowoffPlayer (ScoreList, CurrentPlayer, 0);
 
     /* Find the next player with rolls left */
     do {
-      CurrentPlayer = (UndoLastMove() + NumberOfPlayers) % NumberOfPlayers;
-    } while (players[CurrentPlayer].comp && UndoPossible());
+      CurrentPlayer = (UndoLastMove () + NumberOfPlayers) % NumberOfPlayers;
+    } while (players[CurrentPlayer].comp && UndoPossible ());
 
-    DisplayCurrentPlayerRefreshDice();
+    DisplayCurrentPlayerRefreshDice ();
   }
 }
 
 void
-RedoPlayer(void)
+RedoPlayer (void)
 {
-  if (RedoPossible()) {
+  if (RedoPossible ()) {
     NumberOfRolls = 1;
     ready_to_advance_player = FALSE;
-    ShowoffPlayer(ScoreList, CurrentPlayer, 0);
+    ShowoffPlayer (ScoreList, CurrentPlayer, 0);
     /* The first element of the list is the undone turn, so
      * we need to remove it from the list before redoing other
      * turns.                                                    */
-    FreeRedoListHead();
+    FreeRedoListHead ();
 
     /* Redo all computer players */
     do {
-      CurrentPlayer = RedoLastMove();
-    } while (players[CurrentPlayer].comp && RedoPossible());
+      CurrentPlayer = RedoLastMove ();
+    } while (players[CurrentPlayer].comp && RedoPossible ());
 
-    RestoreLastRoll();
-    DisplayCurrentPlayerRefreshDice();
+    RestoreLastRoll ();
+    DisplayCurrentPlayerRefreshDice ();
   }
 }
 
@@ -447,8 +447,8 @@ GyahtzeeNewGame (void)
 
   say (_("Select dice to roll or choose a score slot."));
 
-  game_type = get_new_game_type();
-  games_scores_set_category(highscores, SCORES_CATEGORY);
+  game_type = get_new_game_type ();
+  games_scores_set_category (highscores, SCORES_CATEGORY);
   NewGame ();
   setup_score_list (ScoreList);
   UpdateRollLabel ();
@@ -550,7 +550,7 @@ roll (void)
   if (!players[CurrentPlayer].comp) {
     RollSelectedDice ();
     if (NumberOfRolls > 1)
-        FreeUndoRedoLists();
+        FreeUndoRedoLists ();
     UpdateRollLabel ();
     LastHumanNumberOfRolls = NumberOfRolls;
   }
@@ -641,7 +641,7 @@ score_cb (GSimpleAction * action, GVariant * parameter, gpointer data)
 static void
 undo_cb (GSimpleAction * action, GVariant * parameter, gpointer data)
 {
-  PreviousPlayer();
+  PreviousPlayer ();
 }
 
 static void
@@ -682,8 +682,8 @@ LoadDicePixmaps (void)
       }
 
     } /* FIXME: What happens if the file isn't found. */
-    g_free(path);
-    g_free(path_kismet);
+    g_free (path);
+    g_free (path_kismet);
   }
 }
 
@@ -731,7 +731,7 @@ GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data)
   gtk_window_set_application (GTK_WINDOW (window), application);
   gtk_window_set_title (GTK_WINDOW (window), _(appName));
   gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window), FALSE);
-  gtk_window_set_icon_name(GTK_WINDOW (window), "tali");
+  gtk_window_set_icon_name (GTK_WINDOW (window), "tali");
 
   //games_conf_add_window (GTK_WINDOW (window), NULL);
 
@@ -744,7 +744,7 @@ GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data)
   gtk_application_add_accelerator (application, "<Primary>r", "app.roll", NULL);
   gtk_application_add_accelerator (application, "F1", "app.help", NULL);
 
-       /*---- Menus ----*/
+  /*---- Menus ----*/
   app_menu = g_menu_new ();
   section = g_menu_new ();
   g_menu_append_section (app_menu, NULL, G_MENU_MODEL (section));
@@ -758,7 +758,7 @@ GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data)
   g_menu_append (section, _("_Quit"), "app.quit");
   scores_action = g_action_map_lookup_action (G_ACTION_MAP (application), "scores");
   undo_action   = g_action_map_lookup_action (G_ACTION_MAP (application), "undo");
-  update_undo_sensitivity();
+  update_undo_sensitivity ();
   gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (app_menu));
 
         /*--- Headerbar ---*/
@@ -900,15 +900,15 @@ main (int argc, char *argv[])
       gdouble sum_scores = 0.0;
       game_type = GAME_YAHTZEE;
       if (game_type_string)
-          game_type = game_type_from_string(game_type_string);
-      g_message("In test computer play section - Using %d trials for simulation", NUM_TRIALS);
+          game_type = game_type_from_string (game_type_string);
+      g_message ("In test computer play section - Using %d trials for simulation", NUM_TRIALS);
       for (ii = 0; ii < test_computer_play; ii++) {
           int num_rolls = 0;
           NumberOfHumans = 0;
           NumberOfComputers = 1;
           NewGame ();
 
-          while (!GameIsOver() && num_rolls < 100) {
+          while (!GameIsOver () && num_rolls < 100) {
               ComputerRolling (CurrentPlayer);
               if (NoDiceSelected () || (NumberOfRolls >= NUM_ROLLS)) {
                 ComputerScoring (CurrentPlayer);
@@ -921,16 +921,16 @@ main (int argc, char *argv[])
               num_rolls++;
           }
           for (kk = NumberOfHumans; kk < NumberOfPlayers; kk++) {
-              printf("Computer score: %d\n", total_score(kk));
-              sum_scores += total_score(kk);
+              printf ("Computer score: %d\n", total_score (kk));
+              sum_scores += total_score (kk);
               if (num_rolls > 98) {
                   for (jj = 0; jj < NUM_FIELDS; jj++)
-                      g_message("Category %d is score %d", jj, players[kk].score[jj]);
+                      g_message ("Category %d is score %d", jj, players[kk].score[jj]);
               }
           }
       }
-      printf("Computer average: %.2f for %d trials\n", sum_scores / test_computer_play, NUM_TRIALS);
-      exit(0);
+      printf ("Computer average: %.2f for %d trials\n", sum_scores / test_computer_play, NUM_TRIALS);
+      exit (0);
   }
 
   highscores = games_scores_new ("tali",
@@ -958,15 +958,15 @@ main (int argc, char *argv[])
     NumberOfComputers = MAX_NUMBER_OF_PLAYERS - NumberOfHumans;
 
   if (game_type_string)
-    game_type = game_type_from_string(game_type_string);
+    game_type = game_type_from_string (game_type_string);
   else {
     char *type;
 
     type = g_settings_get_string (settings, "game-type");
-    game_type = game_type_from_string(type);
+    game_type = game_type_from_string (type);
   }
 
-  set_new_game_type(game_type);
+  set_new_game_type (game_type);
 
   if (NUM_TRIALS <= 0)
       NUM_TRIALS = g_settings_get_int (settings, "monte-carlo-trials");
@@ -1003,7 +1003,7 @@ main (int argc, char *argv[])
 
   g_application_run (G_APPLICATION (application), argc, argv);
 
-  exit(0);
+  exit (0);
 }
 
 /* Arrgh - lets all use the same tabs under emacs: 
diff --git a/src/setup.c b/src/setup.c
index 371609c..1c7bf5c 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -63,7 +63,7 @@ static GameTypeTable game_type_table[] = {
     { GAME_KISMET,  "Colors"  }
 };
 
-#define GAME_TYPE_TABLE_SIZE (sizeof(game_type_table) / sizeof(GameTypeTable))
+#define GAME_TYPE_TABLE_SIZE (sizeof (game_type_table) / sizeof (GameTypeTable))
 
 typedef struct skill_level_table_t {
     int level;
@@ -76,9 +76,9 @@ static SkillLevelTable skill_level_table[] = {
     { 2, 1000 }
 };
 
-#define SKILL_LEVEL_TABLE_SIZE (sizeof(skill_level_table) / sizeof(SkillLevelTable))
+#define SKILL_LEVEL_TABLE_SIZE (sizeof (skill_level_table) / sizeof (SkillLevelTable))
 
-static const gchar *game_type_name(GameType type)
+static const gchar *game_type_name (GameType type)
 {
     gint ii = 0;
     for (ii = 0; ii < GAME_TYPE_TABLE_SIZE; ii++) {
@@ -89,24 +89,24 @@ static const gchar *game_type_name(GameType type)
     return NULL;
 }
 
-GameType game_type_from_string(const gchar *string)
+GameType game_type_from_string (const gchar *string)
 {
     if (string) {
         gint ii =0;
         for (ii = 0; ii < GAME_TYPE_TABLE_SIZE; ii++)
-            if (!strcmp(string, game_type_table[ii].name))
+            if (!strcmp (string, game_type_table[ii].name))
                 return game_type_table[ii].type;
     }
 
     return GAME_YAHTZEE;
 }
 
-GameType get_new_game_type(void)
+GameType get_new_game_type (void)
 {
     return NewGameType;
 }
 
-void set_new_game_type(GameType type)
+void set_new_game_type (GameType type)
 {
     NewGameType = type;
 }
@@ -174,7 +174,7 @@ do_setup (GtkWidget * widget, gpointer data)
 
   g_settings_set_boolean (settings, "delay-between-rolls", DoDelay);
 
-  type_name = game_type_name(NewGameType);
+  type_name = game_type_name (NewGameType);
   if (type_name) {
     g_settings_set_string (settings, "game-type", type_name);
   }
@@ -233,14 +233,14 @@ MaxPlayersCheck (GtkWidget * widget, gpointer * data)
 static gint
 SetGameType (GtkWidget *widget, gpointer *data)
 {
-    NewGameType = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+    NewGameType = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
     return FALSE;
 }
 
 static gint
 SetSkillLevel (GtkWidget *widget, gpointer *data)
 {
-    skill_level = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+    skill_level = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
     if (skill_level >= 0 && skill_level < SKILL_LEVEL_TABLE_SIZE) {
         NUM_TRIALS = skill_level_table[skill_level].trials;
     }
@@ -332,30 +332,30 @@ setup_game (void)
                    G_CALLBACK (MaxPlayersCheck), ComputerAdj);
   gtk_box_pack_start (GTK_BOX (box2), ComputerSpinner, TRUE, TRUE, 0);
 
-  box2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
-  gtk_box_pack_start(GTK_BOX(box), box2, FALSE, FALSE, 0);
+  box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
+  gtk_box_pack_start (GTK_BOX (box), box2, FALSE, FALSE, 0);
   label = gtk_label_new_with_mnemonic (_("_Difficulty:"));
-  gtk_box_pack_start(GTK_BOX(box2), label, FALSE, FALSE, 0);
-  combo = gtk_combo_box_text_new();
-  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("difficulty", "Easy"));
-  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("difficulty", "Medium"));
-  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("difficulty", "Hard"));
+  gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
+  combo = gtk_combo_box_text_new ();
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), C_("difficulty", "Easy"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), C_("difficulty", "Medium"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), C_("difficulty", "Hard"));
   skill_level = 0;
   while (NUM_TRIALS > skill_level_table[skill_level].trials &&
          skill_level < (SKILL_LEVEL_TABLE_SIZE - 1)) skill_level++;
-  gtk_combo_box_set_active(GTK_COMBO_BOX(combo), skill_level);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), skill_level);
   g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (SetSkillLevel),
                     combo);
-  gtk_box_pack_start(GTK_BOX(box2), combo, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (box2), combo, FALSE, FALSE, 0);
 
     /*--- Combo (yahtzee or kismet style ----*/
 
   frame = games_frame_new (_("Game Type"));
   gtk_grid_attach (GTK_GRID (grid), frame, 0, 2, 1, 1);
-  combo = gtk_combo_box_text_new();
-  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("game type", "Regular"));
-  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), C_("game type", "Colors"));
-  gtk_combo_box_set_active(GTK_COMBO_BOX(combo), game_type);
+  combo = gtk_combo_box_text_new ();
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), C_("game type", "Regular"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), C_("game type", "Colors"));
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), game_type);
   NewGameType = game_type;
   g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (SetGameType),
                     combo);
diff --git a/src/yahtzee.c b/src/yahtzee.c
index cb7ec2c..905520c 100644
--- a/src/yahtzee.c
+++ b/src/yahtzee.c
@@ -78,7 +78,7 @@ typedef struct field_info_t {
   char *label;
   int   yahtzee_row;
   int   kismet_row;
-  int (*score_func)(int);
+  int (*score_func) (int);
 } FieldInfo;
 
 char *FieldLabelsYahtzee[NUM_FIELDS_YAHTZEE + EXTRA_FIELDS] = {
@@ -187,7 +187,7 @@ NewGame (void)
   CurrentPlayer = 0;
   NumberOfRolls = 0;
   LastHumanNumberOfRolls = 0;
-  FreeUndoRedoLists();
+  FreeUndoRedoLists ();
 
   NumberOfPlayers = NumberOfComputers + NumberOfHumans;
 
@@ -212,8 +212,8 @@ NewGame (void)
 int
 RollDie (void)
 {
-  double r = (double) rand() / RAND_MAX;
-  return (int)(r * 6.0) + 1;
+  double r = (double) rand () / RAND_MAX;
+  return (int) (r * 6.0) + 1;
 }
 
 void
@@ -235,7 +235,7 @@ RollSelectedDice (void)
   }
 
   /* If no dice is selcted roll them all */
-  if(cnt == 0){
+  if (cnt == 0) {
     for (i = 0; i < NUMBER_OF_DICE; i++) {
       DiceValues[i].val = RollDie ();
       lastRoll.DiceValues[i] = DiceValues[i].val;
@@ -392,27 +392,27 @@ add_dice (void)
 }
 
 static int
-score_basic(int field) {
+score_basic (int field) {
   field++;
   return count (field) * field;
 }
 
 static int
-score_3_of_a_kind(int field) {
+score_3_of_a_kind (int field) {
   if (find_n_of_a_kind (3, 0))
     return add_dice ();
   return 0;
 }
 
 static int
-score_4_of_a_kind(int field) {
+score_4_of_a_kind (int field) {
   if (find_n_of_a_kind (4, 0))
     return add_dice ();
   return 0;
 }
 
 static int
-score_full_house(int field) {
+score_full_house (int field) {
   int i = find_n_of_a_kind (3, 0);
   if (i) {
     if (find_n_of_a_kind (2, i) || find_n_of_a_kind (5, 0))
@@ -423,7 +423,7 @@ score_full_house(int field) {
 }
 
 static int
-score_small_straight(int field) {
+score_small_straight (int field) {
   if (find_straight (4, 0, 0))
     return 30;
 
@@ -431,7 +431,7 @@ score_small_straight(int field) {
 }
 
 static int
-score_large_straight(int field) {
+score_large_straight (int field) {
   if (find_straight (5, 0, 0))
     return 40;
 
@@ -439,7 +439,7 @@ score_large_straight(int field) {
 }
 
 static int
-score_yahtzee(int field) {
+score_yahtzee (int field) {
   if (find_n_of_a_kind (5, 0))
     return 50;
 
@@ -447,12 +447,12 @@ score_yahtzee(int field) {
 }
 
 static int
-score_chance(int field) {
+score_chance (int field) {
   return add_dice ();
 }
 
 static int
-score_2_pair_same_color(int field) {
+score_2_pair_same_color (int field) {
   int i = find_n_of_a_kind (2, 0);
   if (i) {
      if (find_n_of_a_kind (2, i) + i == 7 || find_n_of_a_kind (4, 0))
@@ -463,7 +463,7 @@ score_2_pair_same_color(int field) {
 }
 
 static int
-score_full_house_kismet(int field) {
+score_full_house_kismet (int field) {
   int i = find_n_of_a_kind (3, 0);
   if (i) {
     if (find_n_of_a_kind (2, i) || find_n_of_a_kind (5, 0))
@@ -474,7 +474,7 @@ score_full_house_kismet(int field) {
 }
 
 static int
-score_full_house_same_color(int field) {
+score_full_house_same_color (int field) {
   int i = find_n_of_a_kind (3, 0);
   if (i) {
     if (find_n_of_a_kind (2, i) + i == 7 || find_n_of_a_kind (5, 0))
@@ -485,7 +485,7 @@ score_full_house_same_color(int field) {
 }
 
 static int
-score_flush(int field) {
+score_flush (int field) {
   int i = find_n_of_a_kind (3, 0);
 
   if (i && i + find_n_of_a_kind (2, i) == 7) return 35;
@@ -497,14 +497,14 @@ score_flush(int field) {
 }
 
 static int
-score_4_of_a_kind_kismet(int field) {
+score_4_of_a_kind_kismet (int field) {
   if (find_n_of_a_kind (4, 0))
     return 25 + add_dice ();
   return 0;
 }
 
 static int
-score_kismet(int field) {
+score_kismet (int field) {
   if (find_n_of_a_kind (5, 0))
     return 50 + add_dice ();
   return 0;
@@ -532,10 +532,10 @@ FieldInfo field_table[] = {
   { N_("5 of a Kind [50 + total]"),          -1, 13, score_kismet },
 };
 
-#define FIELD_TABLE_SIZE (sizeof(field_table) / sizeof(FieldInfo))
+#define FIELD_TABLE_SIZE (sizeof (field_table) / sizeof (FieldInfo))
 
 static FieldInfo
-*get_field_info(int field)
+*get_field_info (int field)
 {
   gint ii;
 
@@ -548,27 +548,27 @@ static FieldInfo
 }
 
 gint
-field_score(gint field)
+field_score (gint field)
 {
-  FieldInfo *info = get_field_info(field);
+  FieldInfo *info = get_field_info (field);
   gint rval = 0;
 
   if (info) {
-    return info->score_func(field);
+    return info->score_func (field);
   }
 
   return rval;
 }
 
 gint
-player_field_score(gint player, gint field)
+player_field_score (gint player, gint field)
 {
   /* A player can still score in H_YA even if it's used in the
    * regular game, but only if they have a non-zero value there */
   if (field == H_YA && game_type == GAME_YAHTZEE) {
     if (players[player].used[field]) {
-      if (field_score(field) > 0 && players[player].score[field] > 0)
-        return field_score(field);
+      if (field_score (field) > 0 && players[player].score[field] > 0)
+        return field_score (field);
       else
         return -1;
     }
@@ -580,8 +580,8 @@ player_field_score(gint player, gint field)
 }
 
 void
-PrependUndoList(gint player, gint field, gint score) {
-  UndoScoreElement *elem = g_new0(UndoScoreElement, 1);
+PrependUndoList (gint player, gint field, gint score) {
+  UndoScoreElement *elem = g_new0 (UndoScoreElement, 1);
   gint ii;
   elem->player = player;
   elem->field  = field;
@@ -592,12 +592,12 @@ PrependUndoList(gint player, gint field, gint score) {
   elem->roll = NumberOfRolls;
 
   if (!players[player].comp)
-    FreeUndoList();
-  UndoList = g_list_prepend(UndoList, elem);
+    FreeUndoList ();
+  UndoList = g_list_prepend (UndoList, elem);
 }
 
 void
-ResetDiceState(UndoScoreElement *elem) {
+ResetDiceState (UndoScoreElement *elem) {
   gint ii;
   for (ii = 0; ii < NUMBER_OF_DICE; ii++) {
     DiceValues[ii].val = elem->DiceValues[ii];
@@ -608,7 +608,7 @@ ResetDiceState(UndoScoreElement *elem) {
 }
 
 gint
-UndoLastMove(void) {
+UndoLastMove (void) {
   if (UndoList) {
     UndoScoreElement *elem = UndoList->data;
     if (elem->field == H_YA && game_type == GAME_YAHTZEE) {
@@ -620,9 +620,9 @@ UndoLastMove(void) {
       players[elem->player].used [elem->field] = 0;
     }
 
-    ResetDiceState(elem);
-    UndoList = g_list_remove(UndoList, elem);
-    RedoList = g_list_prepend(RedoList, elem);
+    ResetDiceState (elem);
+    UndoList = g_list_remove (UndoList, elem);
+    RedoList = g_list_prepend (RedoList, elem);
     return elem->player;
   }
 
@@ -630,7 +630,7 @@ UndoLastMove(void) {
 }
 
 gint
-RedoLastMove(void) {
+RedoLastMove (void) {
   gint rval = (CurrentPlayer + 1) % NumberOfPlayers;
   if (RedoList) {
     gint ii;
@@ -641,10 +641,10 @@ RedoLastMove(void) {
       DiceValues[ii].sel = 0;
     }
 
-    RedoList = g_list_remove(RedoList, elem);
-    play_score(elem->player, elem->field);
+    RedoList = g_list_remove (RedoList, elem);
+    play_score (elem->player, elem->field);
     rval = (elem->player + 1) % NumberOfPlayers;
-    g_free(elem);
+    g_free (elem);
     if (RedoList) {
       elem = RedoList->data;
       rval = elem->player;
@@ -655,12 +655,12 @@ RedoLastMove(void) {
 }
 
 void
-RestoreLastRoll(void) {
-  ResetDiceState(&lastRoll);
+RestoreLastRoll (void) {
+  ResetDiceState (&lastRoll);
 }
 
 UndoScoreElement*
-RedoHead(void) {
+RedoHead (void) {
   if (RedoList) {
     UndoScoreElement *elem = RedoList->data;
     return elem;
@@ -670,35 +670,35 @@ RedoHead(void) {
 }
 
 void
-FreeUndoList(void) {
+FreeUndoList (void) {
   while (UndoList) {
     UndoScoreElement *elem = UndoList->data;
-    UndoList = g_list_remove(UndoList, elem);
-    g_free(elem);
+    UndoList = g_list_remove (UndoList, elem);
+    g_free (elem);
   }
 }
 
 void
-FreeRedoList(void) {
+FreeRedoList (void) {
   while (RedoList) {
     UndoScoreElement *elem = RedoList->data;
-    RedoList = g_list_remove(RedoList, elem);
-    g_free(elem);
+    RedoList = g_list_remove (RedoList, elem);
+    g_free (elem);
   }
 }
 
 void
-FreeUndoRedoLists(void) {
-  FreeUndoList();
-  FreeRedoList();
+FreeUndoRedoLists (void) {
+  FreeUndoList ();
+  FreeRedoList ();
 }
 
 void
-FreeRedoListHead(void) {
+FreeRedoListHead (void) {
   if (RedoList) {
     UndoScoreElement *elem = RedoList->data;
-    RedoList = g_list_remove(RedoList, elem);
-    g_free(elem);
+    RedoList = g_list_remove (RedoList, elem);
+    g_free (elem);
   }
 }
 
@@ -723,8 +723,8 @@ play_score (int player, int field)
     return SLOT_USED;
 
   players[player].used[field] = 1;
-  players[player].score[field] = players[player].score[field] + field_score(field);
-  PrependUndoList(player, field, players[player].score[field]);
+  players[player].score[field] = players[player].score[field] + field_score (field);
+  PrependUndoList (player, field, players[player].score[field]);
 
   ShowPlayer (player, field);
 
@@ -745,7 +745,7 @@ FindWinner (void)
   int total;
 
   WinningScore = 0;
-  FreeUndoRedoLists();
+  FreeUndoRedoLists ();
 
   for (i = 0; i < NumberOfPlayers; ++i) {
     total = total_score (i);
@@ -769,20 +769,20 @@ FindWinner (void)
 
 /* Undo is possible when the Undo List isn't NULL */
 int
-UndoPossible(void)
+UndoPossible (void)
 {
   return UndoList != NULL;
 }
 
 /* Undo option should be visible only when the player is human */
 int
-UndoVisible(void)
+UndoVisible (void)
 {
-  return UndoPossible() && !players[CurrentPlayer].comp;
+  return UndoPossible () && !players[CurrentPlayer].comp;
 }
 
 int
-RedoPossible(void)
+RedoPossible (void)
 {
   return RedoList != NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]