Author: cazfi
Date: Fri Jul 31 19:32:24 2015
New Revision: 29282

URL: http://svn.gna.org/viewcvs/freeciv?rev=29282&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_6/client/client_main.c
    branches/S2_6/client/gui-gtk-2.0/mapview.c
    branches/S2_6/client/gui-gtk-3.0/mapview.c
    branches/S2_6/client/packhand.c
    branches/S2_6/client/text.c
    branches/S2_6/common/game.c
    branches/S2_6/common/game.h
    branches/S2_6/common/packets.def
    branches/S2_6/fc_version
    branches/S2_6/server/gamehand.c
    branches/S2_6/server/sernet.c
    branches/S2_6/server/settings.c
    branches/S2_6/server/srv_main.c
    branches/S2_6/server/srv_main.h
    branches/S2_6/server/unittools.c

Modified: branches/S2_6/client/client_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/client_main.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/client/client_main.c  (original)
+++ branches/S2_6/client/client_main.c  Fri Jul 31 19:32:24 2015
@@ -1038,7 +1038,7 @@
 **************************************************************************/
 void set_seconds_to_turndone(double seconds)
 {
-  if (game.info.timeout > 0) {
+  if (current_turn_timeout() > 0) {
     seconds_to_turndone = seconds;
     turndone_timer = timer_renew(turndone_timer, TIMER_USER, TIMER_ACTIVE);
     timer_start(turndone_timer);
@@ -1050,12 +1050,12 @@
 }
 
 /**************************************************************************
-  Return the number of seconds until turn-done.  Don't call this unless
-  game.info.timeout != 0.
+  Return the number of seconds until turn-done. Don't call this unless
+  current_turn_timeout() != 0.
 **************************************************************************/
 int get_seconds_to_turndone(void)
 {
-  if (game.info.timeout > 0) {
+  if (current_turn_timeout() > 0) {
     return seconds_shown_to_turndone;
   } else {
     /* This shouldn't happen. */
@@ -1095,9 +1095,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 current_turn_timeout() > 0 but !turndone_timer,
+   * in the first moments after the timeout is set. */
+  if (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. */
 

Modified: branches/S2_6/client/gui-gtk-2.0/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/mapview.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/mapview.c  (original)
+++ branches/S2_6/client/gui-gtk-2.0/mapview.c  Fri Jul 31 19:32:24 2015
@@ -99,7 +99,7 @@
 {
   gtk_label_set_text(GTK_LABEL(timeout_label), get_timeout_label_text());
 
-  if (game.info.timeout > 0) {
+  if (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_6/client/gui-gtk-3.0/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/mapview.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/mapview.c  (original)
+++ branches/S2_6/client/gui-gtk-3.0/mapview.c  Fri Jul 31 19:32:24 2015
@@ -101,7 +101,7 @@
 {
   gtk_label_set_text(GTK_LABEL(timeout_label), get_timeout_label_text());
 
-  if (game.info.timeout > 0) {
+  if (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_6/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/packhand.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/client/packhand.c     (original)
+++ branches/S2_6/client/packhand.c     Fri Jul 31 19:32:24 2015
@@ -1153,7 +1153,7 @@
   update_unit_info_label(get_units_in_focus());
   menus_update();
 
-  set_seconds_to_turndone(game.info.timeout);
+  set_seconds_to_turndone(current_turn_timeout());
 
 #if 0
   /* This information shouldn't be needed, but if it is this is the only
@@ -1915,7 +1915,7 @@
 **************************************************************************/
 void handle_timeout_info(float seconds_to_phasedone)
 {
-  if (game.info.timeout != 0 && seconds_to_phasedone >= 0) {
+  if (current_turn_timeout() != 0 && 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_6/client/text.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/text.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/client/text.c (original)
+++ branches/S2_6/client/text.c Fri Jul 31 19:32:24 2015
@@ -1463,7 +1463,7 @@
 
   astr_clear(&str);
 
-  if (game.info.timeout <= 0) {
+  if (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_6/common/game.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/common/game.c (original)
+++ branches/S2_6/common/game.c Fri Jul 31 19:32:24 2015
@@ -764,3 +764,15 @@
     flag->helptxt = NULL;
   }
 }
+
+/****************************************************************************
+  Return timeout value for the current turn.
+****************************************************************************/
+int current_turn_timeout(void)
+{
+  if (game.info.turn == 0 && game.info.first_timeout != -1) {
+    return game.info.first_timeout;
+  } else {
+    return game.info.timeout;
+  }
+}

Modified: branches/S2_6/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.h?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/common/game.h (original)
+++ branches/S2_6/common/game.h Fri Jul 31 19:32:24 2015
@@ -246,8 +246,6 @@
         fc_mutex city_list;
       } mutexes;
 
-      int first_timeout;
-
       struct trait_limits default_traits[TRAIT_COUNT];
       struct government *default_government;
 
@@ -296,6 +294,8 @@
 
 void user_flag_init(struct user_flag *flag);
 void user_flag_free(struct user_flag *flag);
+
+int current_turn_timeout(void);
 
 extern struct civ_game game;
 

Modified: branches/S2_6/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/packets.def?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/common/packets.def    (original)
+++ branches/S2_6/common/packets.def    Fri Jul 31 19:32:24 2015
@@ -518,6 +518,7 @@
   FTM free_tech_method;
   GLS gameloss_style;
   UINT32 timeout;
+  UINT32 first_timeout;
   BOOL tired_attack;
   UINT16 trademindist;
   BOOL force_trade_route;

Modified: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Fri Jul 31 19:32:24 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Jun.22"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Jul.31"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/gamehand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/gamehand.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/server/gamehand.c     (original)
+++ branches/S2_6/server/gamehand.c     Fri Jul 31 19:32:24 2015
@@ -868,7 +868,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.tinfo.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_6/server/sernet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/sernet.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/server/sernet.c       (original)
+++ branches/S2_6/server/sernet.c       Fri Jul 31 19:32:24 2015
@@ -687,7 +687,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)
@@ -875,7 +875,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_6/server/settings.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/settings.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/server/settings.c     (original)
+++ branches/S2_6/server/settings.c     Fri Jul 31 19:32:24 2015
@@ -2363,7 +2363,7 @@
           timeout_callback, timeout_action,
           GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT)
 
-  GEN_INT("first_timeout", game.server.first_timeout,
+  GEN_INT("first_timeout", game.info.first_timeout,
           SSET_META, SSET_INTERNAL, SSET_VITAL, SSET_TO_CLIENT,
           N_("First turn timeout"),
           /* TRANS: The strings between single quotes are setting names and

Modified: branches/S2_6/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/srv_main.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/server/srv_main.c     (original)
+++ branches/S2_6/server/srv_main.c     Fri Jul 31 19:32:24 2015
@@ -1045,11 +1045,7 @@
 
   sanity_check();
 
-  if (game.info.turn == 0 && game.server.first_timeout != -1) {
-    game.tinfo.seconds_to_phasedone = (double)game.server.first_timeout;
-  } else {
-    game.tinfo.seconds_to_phasedone = (double)game.info.timeout;
-  }
+  game.tinfo.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);
@@ -1850,7 +1846,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;
   }
 
@@ -3225,4 +3221,3 @@
 {
   return playercolor_get(i);
 }
-

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

Modified: branches/S2_6/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=29282&r1=29281&r2=29282&view=diff
==============================================================================
--- branches/S2_6/server/unittools.c    (original)
+++ branches/S2_6/server/unittools.c    Fri Jul 31 19:32:24 2015
@@ -3494,7 +3494,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