Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12444) more phase_timer bugs
Home

[Freeciv-Dev] (PR#12444) more phase_timer bugs

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12444) more phase_timer bugs
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 6 Mar 2005 09:59:43 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12444 >

The code insists on accessing the phase_timer when it's NULL.  I get 
this now when re-loading a game that has a timeout.  It happens when you 
load the game, when you connect, and when you start the game - all 
separate bugs really.

The easy and safe way to fix this is to always check if

   timeout > 0
   server_state == RUN_GAME_STATE
   game.phase_timer != NULL

before checking the timer.

-jason

? vgcore.pid4109
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.155
diff -u -r1.155 gamehand.c
--- server/gamehand.c   6 Mar 2005 16:24:26 -0000       1.155
+++ server/gamehand.c   6 Mar 2005 17:56:35 -0000
@@ -345,7 +345,9 @@
     ginfo.great_wonders[i] = game.great_wonders[i];
   /* the following values are computed every
      time a packet_game_info packet is created */
-  if (game.timeout > 0) {
+  if (game.timeout > 0 && game.phase_timer) {
+    /* Sometimes this function is called before the phase_timer is
+     * initialized.  In that case we want to send the dummy value. */
     ginfo.seconds_to_phasedone
       = game.seconds_to_phase_done - read_timer_seconds(game.phase_timer);
   } else {
Index: server/sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.136
diff -u -r1.136 sernet.c
--- server/sernet.c     6 Mar 2005 16:24:26 -0000       1.136
+++ server/sernet.c     6 Mar 2005 17:56:36 -0000
@@ -500,8 +500,10 @@
     if(select(max_desc+1, &readfs, &writefs, &exceptfs, &tv)==0) { /* timeout 
*/
       (void) send_server_info_to_metaserver(META_REFRESH);
       if (game.timeout > 0
-         && read_timer_seconds(game.phase_timer) > game.seconds_to_phase_done
-         && server_state == RUN_GAME_STATE) {
+         && server_state == RUN_GAME_STATE
+         && game.phase_timer
+         && (read_timer_seconds(game.phase_timer)
+             > game.seconds_to_phase_done)) {
        con_prompt_off();
        return 0;
       }
@@ -671,6 +673,8 @@
   con_prompt_off();
 
   if (game.timeout > 0
+      && server_state == RUN_GAME_STATE
+      && game.phase_timer
       && read_timer_seconds(game.phase_timer) > game.seconds_to_phase_done) {
     return 0;
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12444) more phase_timer bugs, Jason Short <=