Author: cazfi
Date: Fri Feb 19 14:23:36 2016
New Revision: 31992

URL: http://svn.gna.org/viewcvs/freeciv?rev=31992&view=rev
Log:
Split calendar_info to separate packet from game_info

See patch #6969

Modified:
    trunk/client/packhand.c
    trunk/common/calendar.c
    trunk/common/dataio.c
    trunk/common/game.c
    trunk/common/game.h
    trunk/common/packets.def
    trunk/fc_version
    trunk/server/gamehand.c
    trunk/server/ruleset.c
    trunk/tools/ruledit/rulesave.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Fri Feb 19 14:23:36 2016
@@ -1980,11 +1980,10 @@
   bool boot_help;
   bool update_aifill_button = FALSE;
 
-
   if (game.info.aifill != pinfo->aifill) {
     update_aifill_button = TRUE;
   }
-  
+
   if (game.info.is_edit_mode != pinfo->is_edit_mode) {
     popdown_all_city_dialogs();
     /* Clears the current goto command. */
@@ -2037,6 +2036,14 @@
   }
 
   editgui_notify_object_changed(OBJTYPE_GAME, 1, FALSE);
+}
+
+/****************************************************************************
+  Packet calendar_info handler.
+****************************************************************************/
+void handle_calendar_info(const struct packet_calendar_info *pcalendar)
+{
+  game.calendar = *pcalendar;
 }
 
 /**************************************************************************

Modified: trunk/common/calendar.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/calendar.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/common/calendar.c     (original)
+++ trunk/common/calendar.c     Fri Feb 19 14:23:36 2016
@@ -66,17 +66,17 @@
     }
   }
 
-  if (game.info.calendar_fragments) {
+  if (game.calendar.calendar_fragments) {
     game.info.fragment_count += get_world_bonus(EFT_TURN_FRAGMENTS);
-    fragment_years = game.info.fragment_count / game.info.calendar_fragments;
+    fragment_years = game.info.fragment_count / 
game.calendar.calendar_fragments;
 
     increase += fragment_years;
-    game.info.fragment_count -= fragment_years * game.info.calendar_fragments;
+    game.info.fragment_count -= fragment_years * 
game.calendar.calendar_fragments;
   }
 
   year += increase;
 
-  if (year == 0 && game.info.calendar_skip_0) {
+  if (year == 0 && game.calendar.calendar_skip_0) {
     year = 1;
     game.info.year_0_hack = TRUE;
   }
@@ -104,11 +104,11 @@
   if (year < 0) {
     /* TRANS: <year> <label> -> "1000 BC" */
     fc_snprintf(y, sizeof(y), _("%d %s"), -year,
-                _(game.info.negative_year_label));
+                _(game.calendar.negative_year_label));
   } else {
     /* TRANS: <year> <label> -> "1000 AD" */
     fc_snprintf(y, sizeof(y), _("%d %s"), year,
-                _(game.info.positive_year_label));
+                _(game.calendar.positive_year_label));
   }
 
   return y;
@@ -120,12 +120,12 @@
 ****************************************************************************/
 const char *calendar_text(void)
 {
-  if (game.info.calendar_fragments) {
+  if (game.calendar.calendar_fragments) {
     static char buffer[128];
 
-    if (game.info.calendar_fragment_name[game.info.fragment_count][0] != '\0') 
{
+    if (game.calendar.calendar_fragment_name[game.info.fragment_count][0] != 
'\0') {
       fc_snprintf(buffer, sizeof(buffer), "%s/%s", textyear(game.info.year),
-                  
_(game.info.calendar_fragment_name[game.info.fragment_count]));
+                  
_(game.calendar.calendar_fragment_name[game.info.fragment_count]));
     } else {
       /* Human readable fragment count starts from 1, not 0 */
       fc_snprintf(buffer, sizeof(buffer), "%s/%d", textyear(game.info.year),

Modified: trunk/common/dataio.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/dataio.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/common/dataio.c       (original)
+++ trunk/common/dataio.c       Fri Feb 19 14:23:36 2016
@@ -73,7 +73,7 @@
 static DIO_GET_CONV_FUN get_conv_callback = get_conv;
 
 /* Uncomment to make field range tests to asserts, fatal with -F */
-/* #define FIELD_RANGE_ASSERT */
+#define FIELD_RANGE_ASSERT */
 
 #if defined(TESTMATIC_ENABLED) && !defined(FIELD_RANGE_ASSERT)
 #define FIELD_RANGE_ASSERT

Modified: trunk/common/game.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/game.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/common/game.c (original)
+++ trunk/common/game.c Fri Feb 19 14:23:36 2016
@@ -283,7 +283,7 @@
   game.info.airlifting_style = GAME_DEFAULT_AIRLIFTINGSTYLE;
   game.info.angrycitizen     = GAME_DEFAULT_ANGRYCITIZEN;
   game.info.borders          = GAME_DEFAULT_BORDERS;
-  game.info.calendar_skip_0  = FALSE;
+  game.calendar.calendar_skip_0 = FALSE;
   game.info.celebratesize    = GAME_DEFAULT_CELEBRATESIZE;
   game.info.citymindist      = GAME_DEFAULT_CITYMINDIST;
   game.info.cooling          = 0;
@@ -312,11 +312,11 @@
   game.info.is_new_game      = TRUE;
   game.info.killstack        = GAME_DEFAULT_KILLSTACK;
   game.info.killcitizen      = GAME_DEFAULT_KILLCITIZEN;
-  game.info.negative_year_label[0] = '\0';
+  game.calendar.negative_year_label[0] = '\0';
   game.info.notradesize      = GAME_DEFAULT_NOTRADESIZE;
   game.info.nuclearwinter    = 0;
   game.info.nuclear_winter   = GAME_DEFAULT_NUCLEAR_WINTER;
-  game.info.positive_year_label[0] = '\0';
+  game.calendar.positive_year_label[0] = '\0';
   game.info.rapturedelay     = GAME_DEFAULT_RAPTUREDELAY;
   game.info.disasters        = GAME_DEFAULT_DISASTERS;
   game.info.restrictinfra    = GAME_DEFAULT_RESTRICTINFRA;
@@ -633,7 +633,7 @@
   }
 
   for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
-    game.info.calendar_fragment_name[i][0] = '\0';
+    game.calendar.calendar_fragment_name[i][0] = '\0';
   }
 
   if (game.ruleset_summary != NULL) {
@@ -721,9 +721,9 @@
   char *c = safe_year_suffix;
 
   if (game.info.year < 0) {
-    suffix = game.info.negative_year_label;
+    suffix = game.calendar.negative_year_label;
   } else {
-    suffix = game.info.positive_year_label;
+    suffix = game.calendar.positive_year_label;
   }
 
   /* Remove all non alphanumeric characters from the year suffix. */

Modified: trunk/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/common/game.h (original)
+++ trunk/common/game.h Fri Feb 19 14:23:36 2016
@@ -84,6 +84,7 @@
   char *ruleset_description;
   struct packet_scenario_info scenario;
   struct packet_game_info info;
+  struct packet_calendar_info calendar;
   struct packet_timeout_info tinfo;
 
   struct government *government_during_revolution;

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Fri Feb 19 14:23:36 2016
@@ -3,7 +3,7 @@
 Max used id:
 ============
 
-Max id: 254
+Max id: 255
 
 Packets are not ordered by their id, but by their category. New packet
 with higher id may get added to existing category, and not to the end of file.
@@ -457,7 +457,6 @@
   UINT32 culture_vic_points;
   UINT16 culture_vic_lead;
   UINT16 culture_migration_pml;
-  BOOL calendar_skip_0;
   /* size limit for cities before they can celebrate */
   UINT8 celebratesize;
   BOOL changable_tax;
@@ -508,7 +507,6 @@
   BOOL muuk_food_wipe;
   BOOL muuk_gold_wipe;
   BOOL muuk_shield_wipe;
-  STRING negative_year_label[MAX_LEN_NAME];
   UINT8 notradesize;
   BOOL nuclear_winter;
   UINT32 nuclearwinter;
@@ -520,7 +518,6 @@
   BOOL tech_trade_loss_allow_holes;
   BOOL tech_parasite_allow_holes;
   BOOL tech_loss_allow_holes;
-  STRING positive_year_label[MAX_LEN_NAME];
   UINT8 rapturedelay;
   UINT16 disasters;
   BOOL restrictinfra;
@@ -553,11 +550,17 @@
   UINT32 warminglevel;
   YEAR year;
   BOOL year_0_hack;
-  UINT16 calendar_fragments;
   UINT16 fragment_count;
-  STRING calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME];
   BOOL civil_war_enabled;
   BOOL paradrop_to_transport;
+end
+
+PACKET_CALENDAR_INFO = 255; sc, is-info, handle-via-packet
+  STRING positive_year_label[MAX_LEN_NAME];
+  STRING negative_year_label[MAX_LEN_NAME];
+  UINT16 calendar_fragments;
+  STRING calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME];
+  BOOL calendar_skip_0;
 end
 
 # This cannot have is-info set. Sending the same value a second time after a

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Fri Feb 19 14:23:36 2016
@@ -55,7 +55,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-3.0-2016.Feb.16"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Feb.19"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/gamehand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/gamehand.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/server/gamehand.c     (original)
+++ trunk/server/gamehand.c     Fri Feb 19 14:23:36 2016
@@ -887,9 +887,12 @@
   }
 
   conn_list_iterate(dest, pconn) {
-    /* These are separate packets as first one may not get sent at all
-     * if there's no changes in it */
+    /* Timeout info is separate from other packets since it has to
+     * be sent always (it's not 'is-info') while the others are 'is-info'
+     * Calendar info has been split from Game info packet to make packet
+     * size more tolerable when json protocol is in use. */
     send_packet_game_info(pconn, &(game.info));
+    send_packet_calendar_info(pconn, &(game.calendar));
     send_packet_timeout_info(pconn, &tinfo);
   }
   conn_list_iterate_end;

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Fri Feb 19 14:23:36 2016
@@ -5971,37 +5971,37 @@
                                    "culture.migration_pml");
 
     /* section: calendar */
-    game.info.calendar_skip_0
+    game.calendar.calendar_skip_0
       = secfile_lookup_bool_default(file, RS_DEFAULT_CALENDAR_SKIP_0,
                                     "calendar.skip_year_0");
     game.server.start_year
       = secfile_lookup_int_default(file, GAME_START_YEAR,
                                    "calendar.start_year");
-    game.info.calendar_fragments
+    game.calendar.calendar_fragments
       = secfile_lookup_int_default(file, 0, "calendar.fragments");
 
-    if (game.info.calendar_fragments > MAX_CALENDAR_FRAGMENTS) {
+    if (game.calendar.calendar_fragments > MAX_CALENDAR_FRAGMENTS) {
       ruleset_error(LOG_ERROR, "Too many calendar fragments. Max is %d",
                     MAX_CALENDAR_FRAGMENTS);
       ok = FALSE;
-      game.info.calendar_fragments = 0;
-    }
-    sz_strlcpy(game.info.positive_year_label,
+      game.calendar.calendar_fragments = 0;
+    }
+    sz_strlcpy(game.calendar.positive_year_label,
                secfile_lookup_str_default(file,
                                           RS_DEFAULT_POS_YEAR_LABEL,
                                           "calendar.positive_label"));
-    sz_strlcpy(game.info.negative_year_label,
+    sz_strlcpy(game.calendar.negative_year_label,
                secfile_lookup_str_default(file,
                                           RS_DEFAULT_NEG_YEAR_LABEL,
                                           "calendar.negative_label"));
 
-    for (cf = 0; cf < game.info.calendar_fragments; cf++) {
+    for (cf = 0; cf < game.calendar.calendar_fragments; cf++) {
       const char *fname;
 
       fname = secfile_lookup_str_default(file, NULL, 
"calendar.fragment_name%d", cf);
       if (fname != NULL) {
-        strncpy(game.info.calendar_fragment_name[cf], fname,
-                sizeof(game.info.calendar_fragment_name[cf]));
+        strncpy(game.calendar.calendar_fragment_name[cf], fname,
+                sizeof(game.calendar.calendar_fragment_name[cf]));
       }
     }
   }

Modified: trunk/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=31992&r1=31991&r2=31992&view=diff
==============================================================================
--- trunk/tools/ruledit/rulesave.c      (original)
+++ trunk/tools/ruledit/rulesave.c      Fri Feb 19 14:23:36 2016
@@ -1046,28 +1046,28 @@
                    RS_DEFAULT_CULTURE_MIGRATION_PML,
                    "culture.migration_pml", NULL);
 
-  save_default_bool(sfile, game.info.calendar_skip_0,
+  save_default_bool(sfile, game.calendar.calendar_skip_0,
                     RS_DEFAULT_CALENDAR_SKIP_0,
                     "calendar.skip_year_0", NULL);
   save_default_int(sfile, game.server.start_year,
                    GAME_START_YEAR,
                    "calendar.start_year", NULL);
-  save_default_int(sfile, game.info.calendar_fragments,
+  save_default_int(sfile, game.calendar.calendar_fragments,
                    0, "calendar.fragments", NULL);
 
   for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
-    if (game.info.calendar_fragment_name[i][0] != '\0') {
-      secfile_insert_str(sfile, game.info.calendar_fragment_name[i],
+    if (game.calendar.calendar_fragment_name[i][0] != '\0') {
+      secfile_insert_str(sfile, game.calendar.calendar_fragment_name[i],
                          "calendar.fragment_name%d", i);
     }
   }
 
-  if (strcmp(game.info.positive_year_label, RS_DEFAULT_POS_YEAR_LABEL)) {
-    secfile_insert_str(sfile, game.info.positive_year_label,
+  if (strcmp(game.calendar.positive_year_label, RS_DEFAULT_POS_YEAR_LABEL)) {
+    secfile_insert_str(sfile, game.calendar.positive_year_label,
                        "calendar.positive_label");
   }
-  if (strcmp(game.info.negative_year_label, RS_DEFAULT_NEG_YEAR_LABEL)) {
-    secfile_insert_str(sfile, game.info.negative_year_label,
+  if (strcmp(game.calendar.negative_year_label, RS_DEFAULT_NEG_YEAR_LABEL)) {
+    secfile_insert_str(sfile, game.calendar.negative_year_label,
                        "calendar.negative_label");
   }
 


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

Reply via email to