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

This patch moves borders radius information to game.ruleset. Server
option now only selects borders mode (currently disabled/enabled).

In addition to borders base radius, ruleset has definition of how fast
borders expand when city grows.


Applies on top of #40629.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aisettler.c freeciv/ai/aisettler.c
--- freeciv/ai/aisettler.c      2009-01-06 16:20:45.000000000 +0200
+++ freeciv/ai/aisettler.c      2009-01-06 16:04:43.000000000 +0200
@@ -493,7 +493,7 @@
        * likelihood go away next turn, or even in a few nanoseconds. */
       continue;
     }
-    if (game.info.borders_sq > 0) {
+    if (game.info.borders > 0) {
       struct player *powner = tile_owner(ptile);
       if (NULL != powner
        && powner != pplayer
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/menu.c 
freeciv/client/gui-gtk-2.0/menu.c
--- freeciv/client/gui-gtk-2.0/menu.c   2008-10-27 04:13:59.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/menu.c   2009-01-06 16:12:49.000000000 +0200
@@ -1443,7 +1443,7 @@
     menus_set_active("<main>/_View/City Output", draw_city_output);
     menus_set_active("<main>/_View/Map _Grid", draw_map_grid);
     menus_set_sensitive("<main>/_View/National _Borders",
-                        game.info.borders_sq > 0);
+                        game.info.borders > 0);
     menus_set_active("<main>/_View/National _Borders", draw_borders);
     menus_set_active("<main>/_View/City _Names", draw_city_names);
 
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/mapview.c 
freeciv/client/gui-sdl/mapview.c
--- freeciv/client/gui-sdl/mapview.c    2008-10-27 04:14:02.000000000 +0200
+++ freeciv/client/gui-sdl/mapview.c    2009-01-06 16:17:08.000000000 +0200
@@ -557,7 +557,7 @@
             2 * h + (DEFAULT_UNITS_H + (pInfo_Window->size.h - 
pInfo_Window->area.h))|| right) {
           struct city *pCity = tile_city(pTile);
 
-          if (game.info.borders_sq > 0 && !pCity) {
+          if (game.info.borders > 0 && !pCity) {
            const char *diplo_nation_plural_adjectives[DS_LAST] =
                         {Q_("?nation:Neutral"), Q_("?nation:Hostile"),
                        "" /* unused, DS_CEASEFIRE*/,
@@ -583,7 +583,7 @@
                 cat_snprintf(buffer, sizeof(buffer), _("\nUnclaimed 
territory"));
               }
            }
-          } /* game.info.borders_sq > 0 && !pCity */
+          } /* game.info.borders > 0 && !pCity */
           
           if (pCity) {
             /* Look at city owner, not tile owner (the two should be the same, 
if
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/menu.c 
freeciv/client/gui-win32/menu.c
--- freeciv/client/gui-win32/menu.c     2008-10-27 04:14:00.000000000 +0200
+++ freeciv/client/gui-win32/menu.c     2009-01-06 16:22:51.000000000 +0200
@@ -1081,7 +1081,7 @@
                   (SSHIP_NONE != client.conn.playing->spaceship.state));
 
     my_check_menu(menu, IDM_VIEW_MAP_GRID, draw_map_grid);
-    my_enable_menu(menu, IDM_VIEW_NATIONAL_BORDERS, game.info.borders_sq > 0);
+    my_enable_menu(menu, IDM_VIEW_NATIONAL_BORDERS, game.info.borders > 0);
     my_check_menu(menu, IDM_VIEW_NATIONAL_BORDERS, draw_borders);
     my_check_menu(menu, IDM_VIEW_CITY_NAMES, draw_city_names);
     my_enable_menu(menu, IDM_VIEW_CITY_GROWTH, draw_city_names);
diff -Nurd -X.diff_ignore freeciv/client/text.c freeciv/client/text.c
--- freeciv/client/text.c       2008-11-04 16:19:19.000000000 +0200
+++ freeciv/client/text.c       2009-01-06 16:14:31.000000000 +0200
@@ -112,7 +112,7 @@
   if (tile_has_special(ptile, S_HUT)) {
     astr_add_line(&str, _("Minor Tribe Village"));
   }
-  if (game.info.borders_sq > 0 && !pcity) {
+  if (game.info.borders > 0 && !pcity) {
     struct player *owner = tile_owner(ptile);
 
     if (NULL != client.conn.playing && owner == client.conn.playing) {
diff -Nurd -X.diff_ignore freeciv/client/tilespec.c freeciv/client/tilespec.c
--- freeciv/client/tilespec.c   2008-12-15 21:55:50.000000000 +0200
+++ freeciv/client/tilespec.c   2009-01-06 16:15:05.000000000 +0200
@@ -4122,7 +4122,7 @@
       }
     }
 
-    if (draw_borders && game.info.borders_sq > 0 && known[0] && known[1]) {
+    if (draw_borders && game.info.borders > 0 && known[0] && known[1]) {
       struct player *owner0 = tile_owner(pedge->tile[0]);
       struct player *owner1 = tile_owner(pedge->tile[1]);
 
diff -Nurd -X.diff_ignore freeciv/common/borders.c freeciv/common/borders.c
--- freeciv/common/borders.c    2009-01-06 16:20:45.000000000 +0200
+++ freeciv/common/borders.c    2009-01-06 16:02:25.000000000 +0200
@@ -36,15 +36,15 @@
   struct city *pcity;
   int radius_sq = 0;
 
-  if (game.info.borders_sq == 0) {
+  if (game.info.borders == 0) {
     return 0;
   }
 
   pcity = tile_city(ptile);
 
   if (pcity) {
-    radius_sq = MAX(game.info.borders_sq, 2*2+1*1);
-    radius_sq += pcity->size;
+    radius_sq = game.info.border_city_radius_sq;
+    radius_sq += pcity->size * game.info.border_size_effect;
   } else {
     base_type_iterate(pbase) {
       if (tile_has_base(ptile, pbase) && base_has_flag(pbase, 
BF_CLAIM_TERRITORY)) {
diff -Nurd -X.diff_ignore freeciv/common/game.c freeciv/common/game.c
--- freeciv/common/game.c       2008-11-04 16:19:04.000000000 +0200
+++ freeciv/common/game.c       2009-01-06 15:54:02.000000000 +0200
@@ -286,7 +286,7 @@
   game.info.spacerace     = GAME_DEFAULT_SPACERACE;
   game.info.turnblock     = GAME_DEFAULT_TURNBLOCK;
   game.info.fogofwar      = GAME_DEFAULT_FOGOFWAR;
-  game.info.borders_sq    = GAME_DEFAULT_BORDERS;
+  game.info.borders       = GAME_DEFAULT_BORDERS;
   game.info.happyborders  = GAME_DEFAULT_HAPPYBORDERS;
   game.info.slow_invasions= GAME_DEFAULT_SLOW_INVASIONS;
   game.info.auto_ai_toggle= GAME_DEFAULT_AUTO_AI_TOGGLE;
diff -Nurd -X.diff_ignore freeciv/common/game.h freeciv/common/game.h
--- freeciv/common/game.h       2008-12-28 14:53:33.000000000 +0200
+++ freeciv/common/game.h       2009-01-06 15:53:36.000000000 +0200
@@ -202,9 +202,9 @@
 #define GAME_DEFAULT_FOGOFWAR        TRUE
 
 /* 0 means no national borders. */
-#define GAME_DEFAULT_BORDERS         (4*4+1*1)
+#define GAME_DEFAULT_BORDERS         1
 #define GAME_MIN_BORDERS             0
-#define GAME_MAX_BORDERS             (13*13-1)
+#define GAME_MAX_BORDERS             1
 
 #define GAME_DEFAULT_HAPPYBORDERS    TRUE
 
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def  2008-12-28 14:53:33.000000000 +0200
+++ freeciv/common/packets.def  2009-01-06 16:00:09.000000000 +0200
@@ -418,7 +418,7 @@
   BOOL fixedlength;
   BOOL auto_ai_toggle;
   BOOL fogofwar;  
-  UINT8 borders_sq;
+  UINT8 borders;
   BOOL happyborders;
   BOOL slow_invasions;
   UINT8 add_to_size_limit;
@@ -444,6 +444,8 @@
   YEAR tech_cost_double_year;
   BOOL killstack;
   BOOL tired_attack;
+  UINT8 border_city_radius_sq;
+  UINT8 border_size_effect;
   UINT8 upgrade_veteran_loss;
   UINT8 autoupgrade_veteran_loss;
   UINT16 incite_improvement_factor;
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c       2008-12-15 21:55:49.000000000 +0200
+++ freeciv/common/unit.c       2009-01-06 16:03:50.000000000 +0200
@@ -1311,7 +1311,7 @@
   if (tile_city(punit->tile)) {
     return FALSE;
   }
-  if (game.info.borders_sq > 0
+  if (game.info.borders > 0
       && game.info.happyborders
       && tile_owner(punit->tile) == unit_owner(punit)) {
     return FALSE;
diff -Nurd -X.diff_ignore freeciv/data/default/game.ruleset 
freeciv/data/default/game.ruleset
--- freeciv/data/default/game.ruleset   2008-12-28 14:53:34.000000000 +0200
+++ freeciv/data/default/game.ruleset   2009-01-06 15:55:48.000000000 +0200
@@ -133,6 +133,12 @@
 ;only fractional moves left.
 tired_attack = 0
 
+[borders]
+; Base border radius from city.
+radius_sq_city = 17
+; Border radius square increased by this amount / point of city size
+size_effect    = 1
+
 [teams]
 names =
  _("Team 0"),
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c    2009-01-06 16:20:45.000000000 +0200
+++ freeciv/server/maphand.c    2009-01-06 16:05:47.000000000 +0200
@@ -1646,7 +1646,7 @@
 *************************************************************************/
 void map_calculate_borders(void)
 {
-  if (game.info.borders_sq == 0) {
+  if (game.info.borders == 0) {
     return;
   }
 
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2008-12-28 14:53:34.000000000 +0200
+++ freeciv/server/ruleset.c    2009-01-06 15:59:15.000000000 +0200
@@ -3113,6 +3113,11 @@
     = secfile_lookup_bool_default(&file, GAME_DEFAULT_TIRED_ATTACK,
                                   "combat_rules.tired_attack");
 
+  game.info.border_city_radius_sq
+    = secfile_lookup_int(&file, "borders.radius_sq_city");
+  game.info.border_size_effect
+    = secfile_lookup_int(&file, "borders.size_effect");
+
   svec = secfile_lookup_str_vec(&file, &game.info.num_teams, "teams.names");
   game.info.num_teams = MIN(MAX_NUM_TEAMS, game.info.num_teams);
   if (game.info.num_teams <= 0) {
diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c 
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c        2009-01-06 16:20:45.000000000 +0200
+++ freeciv/server/sanitycheck.c        2009-01-06 16:06:33.000000000 +0200
@@ -312,7 +312,7 @@
                  city_name(pcity), pcity->size,
                  is_city_center(pcity, ptile) ? "{city center}" : "");
        }
-       if (game.info.borders_sq > 0 && owner && owner != city_owner(pcity)) {
+       if (game.info.borders > 0 && owner && owner != city_owner(pcity)) {
          SANITY_("(%4d,%4d) marked as empty, "
                  "but in enemy territory! "
                  "\"%s\"[%d]%s"),
@@ -348,7 +348,7 @@
                  city_name(pcity), pcity->size,
                  is_city_center(pcity, ptile) ? "{city center}" : "");
        }
-        if (game.info.borders_sq > 0 && owner && owner != city_owner(pcity)) {
+        if (game.info.borders > 0 && owner && owner != city_owner(pcity)) {
          SANITY_("(%4d,%4d) marked as worked, "
                  "but in enemy territory! "
                  "\"%s\"[%d]%s"),
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2009-01-06 16:20:45.000000000 +0200
+++ freeciv/server/savegame.c   2009-01-06 16:08:47.000000000 +0200
@@ -4012,7 +4012,6 @@
   enum tile_special_type *special_order = NULL;
   struct base_type **base_order = NULL;
   char *savefile_options = secfile_lookup_str(file, "savefile.options");
-  int old_borders;
 
   /* [savefile] */
 
@@ -4210,10 +4209,10 @@
     (void) section_file_lookup(file, "game.farmfood");
 
     /* National borders setting. */
-    old_borders = secfile_lookup_int_default(file, 0, "game.borders");
-    game.info.borders_sq = secfile_lookup_int_default(file,
-                                                      old_borders*old_borders,
-                                                      "game.borders_sq");
+    game.info.borders = secfile_lookup_int_default(file, 0, "game.borders");
+    if (game.info.borders > GAME_MAX_BORDERS) {
+      game.info.borders = 1;
+    }
     game.info.happyborders = secfile_lookup_bool_default(file, FALSE, 
                                                    "game.happyborders");
 
@@ -4946,7 +4945,7 @@
   secfile_insert_bool(file, game.info.autoattack, "game.autoattack");
   secfile_insert_str(file, game.demography, "game.demography");
   secfile_insert_str(file, game.allow_take, "game.allow_take");
-  secfile_insert_int(file, game.info.borders_sq, "game.borders_sq");
+  secfile_insert_int(file, game.info.borders, "game.borders");
   secfile_insert_bool(file, game.info.happyborders, "game.happyborders");
   secfile_insert_int(file, game.info.diplomacy, "game.diplomacy");
   secfile_insert_int(file, game.info.allowed_city_names, 
"game.allowed_city_names");
diff -Nurd -X.diff_ignore freeciv/server/score.c freeciv/server/score.c
--- freeciv/server/score.c      2008-10-27 04:13:36.000000000 +0200
+++ freeciv/server/score.c      2009-01-06 16:09:15.000000000 +0200
@@ -178,7 +178,7 @@
       }
     }
 
-    if (game.info.borders_sq > 0) {
+    if (game.info.borders > 0) {
       /* If borders are enabled, use owner information directly from the
        * map.  Otherwise use the calculations above. */
       owner = tile_owner(ptile);
diff -Nurd -X.diff_ignore freeciv/server/settings.c freeciv/server/settings.c
--- freeciv/server/settings.c   2008-10-27 04:13:36.000000000 +0200
+++ freeciv/server/settings.c   2009-01-06 16:10:35.000000000 +0200
@@ -690,16 +690,12 @@
          GAME_MIN_KILLCITIZEN, GAME_MAX_KILLCITIZEN,
          GAME_DEFAULT_KILLCITIZEN)
 
-  GEN_INT("borders", game.info.borders_sq,
+  GEN_INT("borders", game.info.borders,
          SSET_RULES, SSET_MILITARY, SSET_SITUATIONAL, SSET_TO_CLIENT,
          N_("National borders"),
          N_("If this is set to greater than 0, then any land tiles "
             "around a fortress or city will be owned by that nation. "
-             "Size of the claimed area is bigger for greater value. "
-             "Claimed are also grows somewhat depending on city size. "
-             "City always claims at least its workable area, no matter how "
-             "low this setting is. Special rules apply for ocean tiles "
-             "or tiles within range of more than one nation's cities."),
+             "\n 0 - Disabled\n 1 - Enabled"),
          NULL,
          GAME_MIN_BORDERS, GAME_MAX_BORDERS, GAME_DEFAULT_BORDERS)
 
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in  2008-12-28 14:53:34.000000000 +0200
+++ freeciv/version.in  2009-01-06 16:00:24.000000000 +0200
@@ -23,5 +23,5 @@
 #   - 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.2008.Dec.28"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2009.Jan.06"
 NETWORK_CAPSTRING_OPTIONAL=""
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to