Author: cazfi
Date: Fri Jul 31 19:32:33 2015
New Revision: 29283

URL: http://svn.gna.org/viewcvs/freeciv?rev=29283&view=rev
Log:
Consistently take 'first_timeout' setting in to account instead of the regular 
'timeout' during
first turn.

Reported anonymously

See bug #23324

Modified:
    branches/S2_5/client/client_main.c
    branches/S2_5/client/client_main.h
    branches/S2_5/client/gui-gtk-2.0/mapview.c
    branches/S2_5/client/gui-gtk-3.0/mapview.c
    branches/S2_5/client/packhand.c
    branches/S2_5/client/text.c
    branches/S2_5/server/gamehand.c
    branches/S2_5/server/sernet.c
    branches/S2_5/server/srv_main.c
    branches/S2_5/server/srv_main.h
    branches/S2_5/server/unittools.c

Modified: branches/S2_5/client/client_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/client_main.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/client/client_main.c  (original)
+++ branches/S2_5/client/client_main.c  Fri Jul 31 19:32:33 2015
@@ -993,7 +993,7 @@
 **************************************************************************/
 void set_seconds_to_turndone(double seconds)
 {
-  if (game.info.timeout > 0) {
+  if (client_current_turn_timeout() > 0) {
     seconds_to_turndone = seconds;
     turndone_timer = timer_renew(turndone_timer, TIMER_USER, TIMER_ACTIVE);
     timer_start(turndone_timer);
@@ -1006,11 +1006,11 @@
 
 /**************************************************************************
   Return the number of seconds until turn-done.  Don't call this unless
-  game.info.timeout != 0.
+  client_current_turn_timeout() != 0.
 **************************************************************************/
 int get_seconds_to_turndone(void)
 {
-  if (game.info.timeout > 0) {
+  if (client_current_turn_timeout() > 0) {
     return seconds_shown_to_turndone;
   } else {
     /* This shouldn't happen. */
@@ -1050,9 +1050,9 @@
     time_until_next_call = MIN(time_until_next_call, blink_time);
   }
 
-  /* It is possible to have game.info.timeout > 0 but !turndone_timer, in the
-   * first moments after the timeout is set. */
-  if (game.info.timeout > 0 && turndone_timer) {
+  /* It is possible to have client_current_turn_timeout() > 0 but 
!turndone_timer,
+   * in the first moments after the timeout is set. */
+  if (client_current_turn_timeout() > 0 && turndone_timer) {
     double seconds = seconds_to_turndone - timer_read_seconds(turndone_timer);
     int iseconds = ceil(seconds) + 0.1; /* Turn should end right on 0. */
 
@@ -1304,3 +1304,23 @@
 
   return NULL;
 }
+
+/****************************************************************************
+  Return timeout value for the current turn.
+****************************************************************************/
+int client_current_turn_timeout(void)
+{
+  if (game.info.turn == 0) {
+    struct option *opt = optset_option_by_name(server_optset, "first_timeout");
+
+    if (opt != NULL) {
+      int val = option_int_get(opt);
+
+      if (val != -1) {
+        return val;
+      }
+    }
+  }
+
+  return game.info.timeout;
+}

Modified: branches/S2_5/client/client_main.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/client_main.h?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/client/client_main.h  (original)
+++ branches/S2_5/client/client_main.h  Fri Jul 31 19:32:33 2015
@@ -109,6 +109,8 @@
 
 void client_exit(void);
 
+int client_current_turn_timeout(void);
+
 /* Set in GUI code. */
 extern const char * const gui_character_encoding;
 extern const bool gui_use_transliteration;

Modified: branches/S2_5/client/gui-gtk-2.0/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/mapview.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/mapview.c  (original)
+++ branches/S2_5/client/gui-gtk-2.0/mapview.c  Fri Jul 31 19:32:33 2015
@@ -99,7 +99,7 @@
 {
   gtk_label_set_text(GTK_LABEL(timeout_label), get_timeout_label_text());
 
-  if (game.info.timeout > 0) {
+  if (client_current_turn_timeout() > 0) {
     gtk_widget_set_tooltip_text(timeout_label, _("Time to forced turn 
change"));
   } else {
     gtk_widget_set_tooltip_text(timeout_label, _("Turn timeout disabled"));

Modified: branches/S2_5/client/gui-gtk-3.0/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/mapview.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/mapview.c  (original)
+++ branches/S2_5/client/gui-gtk-3.0/mapview.c  Fri Jul 31 19:32:33 2015
@@ -101,7 +101,7 @@
 {
   gtk_label_set_text(GTK_LABEL(timeout_label), get_timeout_label_text());
 
-  if (game.info.timeout > 0) {
+  if (client_current_turn_timeout() > 0) {
     gtk_widget_set_tooltip_text(timeout_label, _("Time to forced turn 
change"));
   } else {
     gtk_widget_set_tooltip_text(timeout_label, _("Turn timeout disabled"));

Modified: branches/S2_5/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/packhand.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/client/packhand.c     (original)
+++ branches/S2_5/client/packhand.c     Fri Jul 31 19:32:33 2015
@@ -1104,7 +1104,7 @@
   update_unit_info_label(get_units_in_focus());
   menus_update();
 
-  set_seconds_to_turndone(game.info.timeout);
+  set_seconds_to_turndone(client_current_turn_timeout());
 
 #if 0
   /* This information shouldn't be needed, but if it is this is the only
@@ -1844,7 +1844,7 @@
 
   boot_help = (can_client_change_view()
               && game.info.spacerace != pinfo->spacerace);
-  if (game.info.timeout != 0 && pinfo->seconds_to_phasedone >= 0) {
+  if (client_current_turn_timeout() != 0 && pinfo->seconds_to_phasedone >= 0) {
     /* If this packet is received in the middle of a turn, this value
      * represents the number of seconds from now to the end of the turn
      * (not from the start of the turn). So we need to restart our

Modified: branches/S2_5/client/text.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/text.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/client/text.c (original)
+++ branches/S2_5/client/text.c Fri Jul 31 19:32:33 2015
@@ -1578,7 +1578,7 @@
 
   astr_clear(&str);
 
-  if (game.info.timeout <= 0) {
+  if (client_current_turn_timeout() <= 0) {
     astr_add(&str, "%s", Q_("?timeout:off"));
   } else {
     astr_add(&str, "%s", format_duration(get_seconds_to_turndone()));

Modified: branches/S2_5/server/gamehand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/gamehand.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/server/gamehand.c     (original)
+++ branches/S2_5/server/gamehand.c     Fri Jul 31 19:32:33 2015
@@ -871,7 +871,7 @@
 
   /* Sometimes this function is called before the phase_timer is
    * initialized.  In that case we want to send the dummy value. */
-  if (game.info.timeout > 0 && game.server.phase_timer) {
+  if (current_turn_timeout() > 0 && game.server.phase_timer) {
     /* Whenever the client sees this packet, it starts a new timer at 0;
      * but the server's timer is only ever reset at the start of a phase
      * (and game.info.seconds_to_phasedone is relative to this).
@@ -970,7 +970,7 @@
 **************************************************************************/
 void increase_timeout_because_unit_moved(void)
 {
-  if (game.info.timeout > 0 && game.server.timeoutaddenemymove > 0) {
+  if (current_turn_timeout() > 0 && game.server.timeoutaddenemymove > 0) {
     double maxsec = (timer_read_seconds(game.server.phase_timer)
                     + (double) game.server.timeoutaddenemymove);
 

Modified: branches/S2_5/server/sernet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/sernet.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/server/sernet.c       (original)
+++ branches/S2_5/server/sernet.c       Fri Jul 31 19:32:33 2015
@@ -683,7 +683,7 @@
       /* timeout */
       call_ai_refresh();
       (void) send_server_info_to_metaserver(META_REFRESH);
-      if (game.info.timeout > 0
+      if (current_turn_timeout() > 0
          && S_S_RUNNING == server_state()
          && game.server.phase_timer
          && (timer_read_seconds(game.server.phase_timer)
@@ -876,7 +876,7 @@
 
   call_ai_refresh();
 
-  if (game.info.timeout > 0
+  if (current_turn_timeout() > 0
       && S_S_RUNNING == server_state()
       && game.server.phase_timer
       && (timer_read_seconds(game.server.phase_timer)

Modified: branches/S2_5/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_main.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/server/srv_main.c     (original)
+++ branches/S2_5/server/srv_main.c     Fri Jul 31 19:32:33 2015
@@ -975,11 +975,7 @@
 
   sanity_check();
 
-  if (game.info.turn == 0 && game.server.first_timeout != -1) {
-    game.info.seconds_to_phasedone = (double)game.server.first_timeout;
-  } else {
-    game.info.seconds_to_phasedone = (double)game.info.timeout;
-  }
+  game.info.seconds_to_phasedone = (double)current_turn_timeout();
   game.server.phase_timer = timer_renew(game.server.phase_timer,
                                         TIMER_USER, TIMER_ACTIVE);
   timer_start(game.server.phase_timer);
@@ -1701,7 +1697,7 @@
   }
 
   /* fixedlength is only applicable if we have a timeout set */
-  if (game.server.fixedlength && game.info.timeout != 0) {
+  if (game.server.fixedlength && current_turn_timeout() != 0) {
     return;
   }
 
@@ -3054,3 +3050,15 @@
 {
   return playercolor_get(i);
 }
+
+/****************************************************************************
+  Return timeout value for the current turn.
+****************************************************************************/
+int current_turn_timeout(void)
+{
+  if (game.info.turn == 0 && game.server.first_timeout != -1) {
+    return game.server.first_timeout;
+  } else {
+    return game.info.timeout;
+  }
+}

Modified: branches/S2_5/server/srv_main.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_main.h?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/server/srv_main.h     (original)
+++ branches/S2_5/server/srv_main.h     Fri Jul 31 19:32:33 2015
@@ -118,4 +118,7 @@
 extern bool force_end_of_sniff;
 
 void update_nations_with_startpos(void);
+
+int current_turn_timeout(void);
+
 #endif /* FC__SRV_MAIN_H */

Modified: branches/S2_5/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/unittools.c?rev=29283&r1=29282&r2=29283&view=diff
==============================================================================
--- branches/S2_5/server/unittools.c    (original)
+++ branches/S2_5/server/unittools.c    Fri Jul 31 19:32:33 2015
@@ -3587,7 +3587,7 @@
   } unit_move_data_list_iterate_end;
 
   /* Check timeout settings. */
-  if (game.info.timeout != 0 && game.server.timeoutaddenemymove > 0) {
+  if (current_turn_timeout() != 0 && game.server.timeoutaddenemymove > 0) {
     bool new_information_for_enemy = FALSE;
 
     phase_players_iterate(penemy) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to