[gnome-games] Refactor GamesScore to be more GObject



commit 91c658b890352b817cff31c6ccd4513ed7203955
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Jan 21 11:03:43 2011 +1100

    Refactor GamesScore to be more GObject

 glines/glines.c                         |    4 +-
 gnobots2/game.c                         |    4 +-
 gnomine/gnomine.c                       |    5 +-
 gnotravex/gnotravex.c                   |    4 +-
 gnotski/gnotski.c                       |    4 +-
 gtali/gyahtzee.c                        |    5 +-
 libgames-support/games-score.c          |  118 ++++++++++++++++++++++---------
 libgames-support/games-score.h          |   33 ++++-----
 libgames-support/games-scores-backend.c |   19 +++---
 libgames-support/games-scores-dialog.c  |    8 +-
 libgames-support/games-scores.c         |   42 ++++++-----
 libgames-support/games-scores.h         |    6 ++-
 mahjongg/mahjongg.c                     |    5 +-
 quadrapassel/highscores.cpp             |    6 +--
 14 files changed, 151 insertions(+), 112 deletions(-)
---
diff --git a/glines/glines.c b/glines/glines.c
index 657aa1a..2a53b43 100644
--- a/glines/glines.c
+++ b/glines/glines.c
@@ -522,11 +522,9 @@ static void
 game_over (void)
 {
   int pos;
-  GamesScoreValue hiscore;
 
   set_statusbar_message (_("Game Over!"));
-  hiscore.plain = score;
-  pos = games_scores_add_score (highscores, hiscore);
+  pos = games_scores_add_plain_score (highscores, score);
   show_scores (pos, TRUE);
   return;
 }
diff --git a/gnobots2/game.c b/gnobots2/game.c
index 4b3cfcb..171c894 100644
--- a/gnobots2/game.c
+++ b/gnobots2/game.c
@@ -218,7 +218,6 @@ log_score (gint sc)
 {
   guint pos = 0;
   gchar *sbuf = NULL;
-  GamesScoreValue score;
 
   if (properties_super_safe_moves ()) {
     sbuf =
@@ -234,9 +233,8 @@ log_score (gint sc)
   }
 
   if (sc != 0) {
-    score.plain = (guint32) sc;
     games_scores_set_category (highscores, sbuf);
-    pos = games_scores_add_score (highscores, score);
+    pos = games_scores_add_plain_score (highscores, (guint32) sc);
   }
   g_free (sbuf);
 
diff --git a/gnomine/gnomine.c b/gnomine/gnomine.c
index 4b05454..ff55551 100644
--- a/gnomine/gnomine.c
+++ b/gnomine/gnomine.c
@@ -389,7 +389,6 @@ lose_game (GtkWidget * widget, gpointer data)
 static void
 win_game (GtkWidget * widget, gpointer data)
 {
-  GamesScoreValue score;
   int pos;
   time_t seconds;
 
@@ -400,9 +399,7 @@ win_game (GtkWidget * widget, gpointer data)
   show_face (pm_win);
 
   seconds = games_clock_get_seconds (GAMES_CLOCK (clk));
-  score.time_double = (gfloat) (seconds / 60) + (gfloat) (seconds % 60) / 100;
-
-  pos = games_scores_add_score (highscores, score);
+  pos = games_scores_add_time_score (highscores, (gfloat) (seconds / 60) + (gfloat) (seconds % 60) / 100);
 
   if (show_scores (pos, TRUE) == GTK_RESPONSE_REJECT)
     quit_game ();
diff --git a/gnotravex/gnotravex.c b/gnotravex/gnotravex.c
index 7c592b3..da63969 100644
--- a/gnotravex/gnotravex.c
+++ b/gnotravex/gnotravex.c
@@ -1117,12 +1117,10 @@ game_score (void)
 {
   gint pos = 0;
   time_t seconds;
-  GamesScoreValue score;
 
   if (!have_been_hinted) {
     seconds = games_clock_get_seconds (GAMES_CLOCK (timer));
-    score.time_double = (gfloat) (seconds / 60) + (gfloat) (seconds % 60) / 100;
-    pos = games_scores_add_score (highscores, score);
+    pos = games_scores_add_time_score (highscores, (gfloat) (seconds / 60) + (gfloat) (seconds % 60) / 100);
   }
 
   if (show_score_dialog (pos, TRUE) == GTK_RESPONSE_REJECT) {
diff --git a/gnotski/gnotski.c b/gnotski/gnotski.c
index 59ce5e1..bbd7841 100644
--- a/gnotski/gnotski.c
+++ b/gnotski/gnotski.c
@@ -831,7 +831,6 @@ score_cb (GtkAction * action)
 void
 game_score (void)
 {
-  GamesScoreValue score;
   gint pos;
   gchar *key;
     
@@ -841,8 +840,7 @@ game_score (void)
   g_free (key);
   gtk_image_set_from_stock (GTK_IMAGE(level_image[current_level]), GTK_STOCK_YES, GTK_ICON_SIZE_MENU);
 
-  score.plain = (guint32) moves;
-  pos = games_scores_add_score (highscores, score);
+  pos = games_scores_add_plain_score (highscores, (guint32) moves);
   if (show_score_dialog (pos, TRUE) == GTK_RESPONSE_REJECT)
     gtk_main_quit ();
   else
diff --git a/gtali/gyahtzee.c b/gtali/gyahtzee.c
index 4e32ac3..3050ddf 100644
--- a/gtali/gyahtzee.c
+++ b/gtali/gyahtzee.c
@@ -163,7 +163,6 @@ CheerWinner (void)
 {
   int winner;
   int i;
-  GamesScoreValue score;
   gint pos;
   gchar *message;
 
@@ -186,9 +185,7 @@ CheerWinner (void)
   ShowoffPlayer (ScoreList, winner, 1);
 
   if (winner < NumberOfHumans) {
-    score.plain = (guint32) WinningScore;  
-
-    pos = games_scores_add_score (highscores, score);
+    pos = games_scores_add_plain_score (highscores, (guint32) WinningScore);
 
     if (pos > 0) {
       games_scores_update_score (highscores, players[winner].name);
diff --git a/libgames-support/games-score.c b/libgames-support/games-score.c
index 8fa7f67..f9d279a 100644
--- a/libgames-support/games-score.c
+++ b/libgames-support/games-score.c
@@ -23,6 +23,15 @@
 
 G_DEFINE_TYPE (GamesScore, games_score, G_TYPE_OBJECT)
 
+struct GamesScorePrivate {
+  union {
+    guint32 plain;
+    gdouble time_double;		/* minutes.seconds */
+  } value;
+  time_t time;
+  gchar *name;
+};
+
 /**
  * games_score_new:
  * 
@@ -31,61 +40,108 @@ G_DEFINE_TYPE (GamesScore, games_score, G_TYPE_OBJECT)
  * Return value: the new #GamesScore
  **/
 GamesScore *
-games_score_new (void)
+games_score_new ()
 {
   return g_object_new (GAMES_TYPE_SCORE, NULL);
 }
 
 /**
- * games_score_dup:
- * @orig: The score to duplicate
+ * games_score_new_plain:
+ * @value: The value of the score.
  * 
- * Duplicates a score object.
+ * Creates a new score object.
  * 
- * Return value: (transfer full): A copy of @orig.
+ * Return value: the new #GamesScore
  **/
 GamesScore *
-games_score_dup (GamesScore * orig)
+games_score_new_plain (guint32 value)
+{
+  GamesScore *score = g_object_new (GAMES_TYPE_SCORE, NULL);
+  score->priv->value.plain = value;
+  return score;
+}
+
+/**
+ * games_score_new_time:
+ * @value: The timer value of the score.
+ * 
+ * Creates a new score object.
+ * 
+ * Return value: the new #GamesScore
+ **/
+GamesScore *
+games_score_new_time (gdouble value)
+{
+  GamesScore *score = g_object_new (GAMES_TYPE_SCORE, NULL);
+  score->priv->value.time_double = value;
+  return score;
+}
+
+const gchar *
+games_score_get_name (GamesScore *score)
+{
+  return score->priv->name;
+}
+
+void
+games_score_set_name (GamesScore *score, const gchar *name)
 {
-  GamesScore *duplicate;
+  g_free (score->priv->name);
+  score->priv->name = g_strdup (name);
+}
 
-  duplicate = games_score_new ();
-  duplicate->value = orig->value;
-  duplicate->time = orig->time;
-  g_free (duplicate->name);
-  duplicate->name = g_strdup (orig->name);
+time_t
+games_score_get_time (GamesScore *score)
+{
+  return score->priv->time;
+}
 
-  return duplicate;
+void
+games_score_set_time (GamesScore *score, time_t time)
+{
+  score->priv->time = time;  
+}
+
+guint32
+games_score_get_value_as_plain (GamesScore *score)
+{
+  return score->priv->value.plain;
+}
+
+gdouble
+games_score_get_value_as_time (GamesScore *score)
+{
+  return score->priv->value.time_double;
 }
 
 gint
-games_score_compare_values (GamesScoreStyle style,
-                            GamesScoreValue a,
-                            GamesScoreValue b)
+games_score_compare (GamesScoreStyle style,
+                     GamesScore * a,
+                     GamesScore * b)
 {
   switch (style) {
   case GAMES_SCORES_STYLE_PLAIN_DESCENDING:
-    if (a.plain > b.plain)
+    if (a->priv->value.plain > b->priv->value.plain)
       return +1;
-    if (a.plain < b.plain)
+    if (a->priv->value.plain < b->priv->value.plain)
       return -1;
     return 0;
   case GAMES_SCORES_STYLE_PLAIN_ASCENDING:
-    if (a.plain > b.plain)
+    if (a->priv->value.plain > b->priv->value.plain)
       return -1;
-    if (a.plain < b.plain)
+    if (a->priv->value.plain < b->priv->value.plain)
       return +1;
     return 0;
   case GAMES_SCORES_STYLE_TIME_DESCENDING:
-    if (a.time_double > b.time_double)
+    if (a->priv->value.time_double > b->priv->value.time_double)
       return +1;
-    if (a.time_double < b.time_double)
+    if (a->priv->value.time_double < b->priv->value.time_double)
       return -1;
     return 0;
   case GAMES_SCORES_STYLE_TIME_ASCENDING:
-    if (a.time_double > b.time_double)
+    if (a->priv->value.time_double > b->priv->value.time_double)
       return -1;
-    if (a.time_double < b.time_double)
+    if (a->priv->value.time_double < b->priv->value.time_double)
       return +1;
     return 0;
   default:
@@ -95,18 +151,12 @@ games_score_compare_values (GamesScoreStyle style,
   }
 }
 
-gint
-games_score_compare (GamesScoreStyle style, GamesScore * a, GamesScore * b)
-{
-  return games_score_compare_values (style, a->value, b->value);
-}
-
 static void
 games_score_finalize (GObject * object)
 {
   GamesScore *score = GAMES_SCORE (object);
 
-  g_free (score->name);
+  g_free (score->priv->name);
 
   G_OBJECT_CLASS (games_score_parent_class)->finalize (object);
 }
@@ -117,6 +167,8 @@ games_score_class_init (GamesScoreClass * klass)
   GObjectClass *object_class = (GObjectClass *) klass;
 
   object_class->finalize = games_score_finalize;
+
+  g_type_class_add_private (object_class, sizeof (GamesScorePrivate));
 }
 
 static void
@@ -124,7 +176,7 @@ games_score_init (GamesScore *score)
 {
   const gchar* name;
 
-  score->time = time (NULL);
+  score->priv->time = time (NULL);
   /* FIXME: We don't handle the "Unknown" case. */
   name = g_get_real_name ();
   if (name[0] == '\0' || g_utf8_validate (name, -1, NULL) != TRUE) {
@@ -133,5 +185,5 @@ games_score_init (GamesScore *score)
       name = "";
     }
   }
-  score->name = g_strdup (name);
+  score->priv->name = g_strdup (name);
 }
diff --git a/libgames-support/games-score.h b/libgames-support/games-score.h
index e1dc68f..6d58a57 100644
--- a/libgames-support/games-score.h
+++ b/libgames-support/games-score.h
@@ -31,6 +31,8 @@ G_BEGIN_DECLS
 #define GAMES_IS_SCORE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_SCORE))
 #define GAMES_IS_SCORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_SCORE))
 
+typedef struct GamesScorePrivate GamesScorePrivate;
+
 /* GamesScore and GamesScoresStyle should be kept in sync. */
 typedef enum {
   GAMES_SCORES_STYLE_PLAIN_DESCENDING,
@@ -39,31 +41,28 @@ typedef enum {
   GAMES_SCORES_STYLE_TIME_ASCENDING,
 } GamesScoreStyle;
 
-typedef union {
-  guint32 plain;
-  gdouble time_double;		/* minutes.seconds */
-} GamesScoreValue;
-
 typedef struct {
   GObject parent;
-  GamesScoreValue value;
-  time_t time;
-  gchar *name;
+  GamesScorePrivate *priv;
 } GamesScore;
 
 typedef struct {
   GObjectClass parent_class;
 } GamesScoreClass;
 
-GType       games_score_get_type       (void);
-GamesScore *games_score_new            (void);
-GamesScore *games_score_dup            (GamesScore * orig);
-gint        games_score_compare        (GamesScoreStyle style,
-                                        GamesScore * a,
-			                            GamesScore * b);
-gint        games_score_compare_values (GamesScoreStyle style,
-                                        GamesScoreValue a,
-                                        GamesScoreValue b);
+GType        games_score_get_type           (void);
+GamesScore  *games_score_new                (void);
+GamesScore  *games_score_new_plain          (guint32 value);
+GamesScore  *games_score_new_time           (gdouble value);
+const gchar *games_score_get_name           (GamesScore *score);
+void         games_score_set_name           (GamesScore *score, const gchar *name);
+time_t       games_score_get_time           (GamesScore *score);
+void         games_score_set_time           (GamesScore *score, time_t time);
+guint32      games_score_get_value_as_plain (GamesScore *score);
+gdouble      games_score_get_value_as_time  (GamesScore *score);
+gint         games_score_compare            (GamesScoreStyle style,
+                                             GamesScore * a,
+                                             GamesScore * b);
 
 G_END_DECLS
 
diff --git a/libgames-support/games-scores-backend.c b/libgames-support/games-scores-backend.c
index c6a4b54..1dcdf39 100644
--- a/libgames-support/games-scores-backend.c
+++ b/libgames-support/games-scores-backend.c
@@ -239,21 +239,20 @@ games_scores_backend_get_scores (GamesScoresBackend * self)
       *namestr++ = '\0';
       /* At this point we have three strings, all null terminated. All
        * part of the original buffer. */
-      newscore = games_score_new ();
-      newscore->name = g_strdup (namestr);
-      newscore->time = g_ascii_strtoull (timestr, NULL, 10);
       switch (self->priv->style) {
       case GAMES_SCORES_STYLE_PLAIN_DESCENDING:
       case GAMES_SCORES_STYLE_PLAIN_ASCENDING:
-        newscore->value.plain = g_ascii_strtod (scorestr, NULL);
+        newscore = games_score_new_plain (g_ascii_strtod (scorestr, NULL));
         break;
       case GAMES_SCORES_STYLE_TIME_DESCENDING:
       case GAMES_SCORES_STYLE_TIME_ASCENDING:
-        newscore->value.time_double = g_ascii_strtod (scorestr, NULL);
+        newscore = games_score_new_time (g_ascii_strtod (scorestr, NULL));
         break;
       default:
         g_assert_not_reached ();
       }
+      games_score_set_name (newscore, namestr);
+      games_score_set_time (newscore, g_ascii_strtoull (timestr, NULL, 10));
       self->scores_list = g_list_append (self->scores_list, newscore);
       /* Setup again for the next time around. */
       scorestr = eol;
@@ -290,24 +289,24 @@ games_scores_backend_set_scores (GamesScoresBackend * self, GList * list)
   while (s != NULL) {
     gdouble rscore;
     guint64 rtime;
-    gchar *rname;
+    const gchar *rname;
 
     d = (GamesScore *) s->data;
     rscore = 0.0;
     switch (self->priv->style) {
     case GAMES_SCORES_STYLE_PLAIN_DESCENDING:
     case GAMES_SCORES_STYLE_PLAIN_ASCENDING:
-      rscore = d->value.plain;
+      rscore = games_score_get_value_as_plain (d);
       break;
     case GAMES_SCORES_STYLE_TIME_DESCENDING:
     case GAMES_SCORES_STYLE_TIME_ASCENDING:
-      rscore = d->value.time_double;
+      rscore = games_score_get_value_as_time(d);
       break;
     default:
       g_assert_not_reached ();
     }
-    rtime = d->time;
-    rname = d->name;
+    rtime = games_score_get_time (d);
+    rname = games_score_get_name(d);
 
     buffer = g_strdup_printf ("%s %"G_GUINT64_FORMAT" %s\n",
                               g_ascii_dtostr (dtostrbuf, sizeof (dtostrbuf),
diff --git a/libgames-support/games-scores-dialog.c b/libgames-support/games-scores-dialog.c
index d7aca59..12d200b 100644
--- a/libgames-support/games-scores-dialog.c
+++ b/libgames-support/games-scores-dialog.c
@@ -255,7 +255,7 @@ static void games_scores_dialog_set_hilight_private (GamesScoresDialog *self)
 /* Load up the list with the current set of scores. */
 static void games_scores_dialog_redraw (GamesScoresDialog *self) {
   GtkTreeIter iter;
-  gchar *name;
+  const gchar *name;
   gint score;
   gchar *ss;
   gdouble dscore;
@@ -266,11 +266,11 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
   scorelist = games_scores_get (self->_priv->scores);
 
   while (scorelist) {
-    name = ((GamesScore *)scorelist->data)->name;
+    name = games_score_get_name ((GamesScore *)scorelist->data);
     switch (self->_priv->style) {
     case GAMES_SCORES_STYLE_TIME_ASCENDING:
     case GAMES_SCORES_STYLE_TIME_DESCENDING:
-      dscore = ((GamesScore *)scorelist->data)->value.time_double;
+      dscore = games_score_get_value_as_time ((GamesScore *)scorelist->data);
       score = (int) (100.0 * dscore + 0.5);
       /* Translators: this is for a minutes, seconds time display. */
       ss = g_strdup_printf (_("%dm %ds"), score/100, score%100);
@@ -278,7 +278,7 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
     case GAMES_SCORES_STYLE_PLAIN_ASCENDING:
     case GAMES_SCORES_STYLE_PLAIN_DESCENDING:
     default:
-      score = ((GamesScore *)scorelist->data)->value.plain;
+      score = games_score_get_value_as_plain ((GamesScore *)scorelist->data);
       ss = g_strdup_printf ("%d", score);
     }
     gtk_list_store_append (self->_priv->list, &iter);
diff --git a/libgames-support/games-scores.c b/libgames-support/games-scores.c
index a3c18f4..a658c72 100644
--- a/libgames-support/games-scores.c
+++ b/libgames-support/games-scores.c
@@ -48,7 +48,7 @@ struct _GamesScoresPrivate {
   gchar *basename;
   gboolean last_score_significant;
   gint last_score_position;
-  GamesScoreValue last_score_value;
+  GamesScore *last_score;
   GamesScoreStyle style;
   GamesScoresCategoryInternal dummycat;
 };
@@ -237,7 +237,7 @@ games_scores_set_category (GamesScores * self, gchar * category)
 /**
  * games_scores_add_score:
  * @self: A scores object.
- * @score: A GamesScoreValue - it is up to the caller to convert their
+ * @score: A #GamesScore - it is up to the caller to convert their
  *         raw value to one of the supported types.
  *
  * Add a score to the set of scores. Retention of anything but the
@@ -247,19 +247,15 @@ games_scores_set_category (GamesScores * self, gchar * category)
  *
  **/
 gint
-games_scores_add_score (GamesScores * self, GamesScoreValue score)
+games_scores_add_score (GamesScores * self, GamesScore *score)
 {
   GamesScoresPrivate *priv = self->priv;
-  GamesScore *fullscore;
   GamesScoresCategoryInternal *cat;
   gint place, n;
   GList *s, *scores_list;
 
   g_return_val_if_fail (self != NULL, 0);
 
-  fullscore = games_score_new ();
-  fullscore->value = score;
-
   cat = games_scores_get_current (self);
 
   scores_list = games_scores_backend_get_scores (cat->backend);
@@ -274,9 +270,9 @@ games_scores_add_score (GamesScores * self, GamesScoreValue score)
     n++;
 
     /* If beat someone in the list, add us there. */
-    if (games_score_compare (priv->style, oldscore, fullscore) < 0) {
+    if (games_score_compare (priv->style, oldscore, score) < 0) {
       scores_list = g_list_insert_before (scores_list, s,
-					  games_score_dup (fullscore));
+					  g_object_ref (score));
       place = n;
       break;
     }
@@ -289,7 +285,7 @@ games_scores_add_score (GamesScores * self, GamesScoreValue score)
    * This also handles the empty-file case. */
   if ((place == 0) && (n < GAMES_SCORES_SIGNIFICANT)) {
     place = n + 1;
-    scores_list = g_list_append (scores_list, games_score_dup (fullscore));
+    scores_list = g_list_append (scores_list, g_object_ref (score));
   }
 
   if (g_list_length (scores_list) > GAMES_SCORES_SIGNIFICANT) {
@@ -306,11 +302,24 @@ games_scores_add_score (GamesScores * self, GamesScoreValue score)
 
   priv->last_score_significant = place > 0;
   priv->last_score_position = place;
-  priv->last_score_value = score;
+  g_object_unref (priv->last_score);
+  priv->last_score = g_object_ref (score);
 
   return place;
 }
 
+gint
+games_scores_add_plain_score (GamesScores * self, guint32 value)
+{
+  return games_scores_add_score (self, games_score_new_plain (value));
+}
+
+gint
+games_scores_add_time_score (GamesScores * self, gdouble value)
+{
+  return games_scores_add_score (self, games_score_new_time (value));
+}
+
 /**
  * games_scores_update_score_name:
  * @self: A scores object.
@@ -331,12 +340,10 @@ games_scores_update_score_name (GamesScores * self, gchar * new_name, gchar * ol
   GList *s, *scores_list;
   gint n, place;
   GamesScore *sc;
-  GamesScoreValue score;
 
   g_return_if_fail (self != NULL);
 
   place = priv->last_score_position;
-  score = priv->last_score_value;
 
   if (place == 0)
     return;
@@ -361,10 +368,9 @@ games_scores_update_score_name (GamesScores * self, gchar * new_name, gchar * ol
 
   while ((n >= place) && (s != NULL)) {
     sc = (GamesScore *) (s->data);
-    if ((games_score_compare_values (priv->style, sc->value, score) ==
-	 0) && (g_utf8_collate (old_name, sc->name) == 0)) {
-      g_free (sc->name);
-      sc->name = g_strdup (new_name);
+    if ((games_score_compare (priv->style, sc, priv->last_score) ==
+	 0) && (g_utf8_collate (old_name, games_score_get_name (sc)) == 0)) {
+      games_score_set_name (sc, new_name);
     }
 
     s = g_list_previous (s);
@@ -495,7 +501,7 @@ games_scores_init (GamesScores * self)
 
   priv->last_score_significant = FALSE;
   priv->last_score_position = 0;
-  priv->last_score_value.plain = 0;
+  priv->last_score = games_score_new ();
 }
 
 static void
diff --git a/libgames-support/games-scores.h b/libgames-support/games-scores.h
index 1c09d30..4ea76ee 100644
--- a/libgames-support/games-scores.h
+++ b/libgames-support/games-scores.h
@@ -76,7 +76,11 @@ GamesScores *games_scores_new (const char *app_name,
 
 void games_scores_set_category (GamesScores * self, gchar * category);
 
-gint games_scores_add_score (GamesScores * self, GamesScoreValue score);
+gint games_scores_add_score (GamesScores * self, GamesScore *score);
+
+gint games_scores_add_plain_score (GamesScores * self, guint32 value);
+
+gint games_scores_add_time_score (GamesScores * self, gdouble value);
 
 void games_scores_update_score (GamesScores * self, gchar * new_name);
 
diff --git a/mahjongg/mahjongg.c b/mahjongg/mahjongg.c
index 4b845f5..59df908 100644
--- a/mahjongg/mahjongg.c
+++ b/mahjongg/mahjongg.c
@@ -610,7 +610,6 @@ you_won (void)
 {
   gint pos;
   time_t seconds;
-  GamesScoreValue score;
   static GtkWidget *dialog = NULL;
   gchar *message;
 
@@ -618,9 +617,7 @@ you_won (void)
 
   seconds = games_clock_get_seconds (GAMES_CLOCK (chrono));
 
-  score.time_double = (seconds / 60) * 1.0 + (seconds % 60) / 100.0;
-
-  pos = games_scores_add_score (highscores, score);
+  pos = games_scores_add_time_score (highscores, (seconds / 60) * 1.0 + (seconds % 60) / 100.0);
   update_menu_sensitivities ();
   if (pos > 0) {
     if (dialog) {
diff --git a/quadrapassel/highscores.cpp b/quadrapassel/highscores.cpp
index 475401b..c89f6c0 100644
--- a/quadrapassel/highscores.cpp
+++ b/quadrapassel/highscores.cpp
@@ -39,11 +39,7 @@ HighScores::HighScores ()
 
 gint HighScores::add (gint score)
 {
-	GamesScoreValue value;
-
-	value.plain = score;
-
-	return games_scores_add_score (highscores, value);
+	return games_scores_add_score (highscores, games_score_new_plain (score));
 }
 
 void HighScores::show (GtkWindow *parent_window, gint highlight)



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