gnome-games r7394 - branches/gnome-2-20/aisleriot
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r7394 - branches/gnome-2-20/aisleriot
- Date: Tue, 19 Feb 2008 13:01:20 +0000 (GMT)
Author: chpe
Date: Tue Feb 19 13:01:20 2008
New Revision: 7394
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7394&view=rev
Log:
2008-02-19 Christian Persch <chpe gnome org>
* game.c: (set_game_state), (update_statistics),
(aisleriot_game_init), (aisleriot_game_finalize),
(aisleriot_game_set_paused): Stop the game time when the game is over.
Fixes bug #514239.
Modified:
branches/gnome-2-20/aisleriot/ChangeLog
branches/gnome-2-20/aisleriot/game.c
Modified: branches/gnome-2-20/aisleriot/game.c
==============================================================================
--- branches/gnome-2-20/aisleriot/game.c (original)
+++ branches/gnome-2-20/aisleriot/game.c Tue Feb 19 13:01:20 2008
@@ -56,7 +56,7 @@
guint32 seed;
guint delayed_call_timeout_id;
- time_t start_time;
+ GTimer *timer;
double width;
double height;
@@ -135,8 +135,11 @@
game->state = state;
if (state == GAME_RUNNING) {
- /* Record start time */
- game->start_time = time (NULL);
+ /* Reset the timer */
+ g_timer_start (game->timer);
+ } else if (state >= GAME_OVER) {
+ /* Stop the timer now so we will record the right time. See bug #FIXME */
+ g_timer_stop (game->timer);
}
g_object_notify (G_OBJECT (game), "state");
@@ -204,12 +207,7 @@
if (game->state == GAME_WON) {
current_stats.wins++;
- if (game->paused) {
- t = game->start_time;
- } else {
- t = time (NULL) - game->start_time;
- }
-
+ t = (time_t) (g_timer_elapsed (game->timer, NULL) + 0.5);
if (t > 0) {
if ((current_stats.best == 0) || (t < current_stats.best)) {
current_stats.best = t;
@@ -1125,6 +1123,8 @@
game->slots = g_ptr_array_sized_new (SLOT_CARDS_N_PREALLOC);
+ game->timer = g_timer_new ();
+
game->timeout = 60 * 60;
}
@@ -1162,6 +1162,8 @@
g_free (game->game_file);
+ g_timer_destroy (game->timer);
+
app_game = NULL;
G_OBJECT_CLASS (aisleriot_game_parent_class)->finalize (object);
@@ -1436,8 +1438,11 @@
game->paused = paused;
- /* (Re)store the start time */
- game->start_time = time (NULL) - game->start_time;
+ if (paused) {
+ g_timer_stop (game->timer);
+ } else {
+ g_timer_continue (game->timer);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]