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

2008/7/22 Jason Dorje Short:
>
> A lower granularity should be possible.  Either the setting should
> allow the border_sq value to be set or it should be a floating-point
> value.

 This version allows setting _sq value directly.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aisettler.c freeciv/ai/aisettler.c
--- freeciv/ai/aisettler.c      2008-03-08 16:32:50.000000000 +0200
+++ freeciv/ai/aisettler.c      2008-07-24 23:00:39.000000000 +0300
@@ -491,7 +491,7 @@
        * likelihood go away next turn, or even in a few nanoseconds. */
       continue;
     }
-    if (game.info.borders > 0) {
+    if (game.info.borders_sq > 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-07-24 19:15:22.000000000 +0300
+++ freeciv/client/gui-gtk-2.0/menu.c   2008-07-24 23:06:47.000000000 +0300
@@ -1433,7 +1433,8 @@
     menus_set_active("<main>/_View/City Outlines", draw_city_outlines);
     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 > 
0);
+    menus_set_sensitive("<main>/_View/National _Borders",
+                        game.info.borders_sq > 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-03-08 16:33:05.000000000 +0200
+++ freeciv/client/gui-sdl/mapview.c    2008-07-24 23:10:00.000000000 +0300
@@ -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 > 0 && !pCity) {
+          if (game.info.borders_sq > 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 > 0 && !pCity */
+          } /* game.info.borders_sq > 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-07-03 21:58:06.000000000 +0300
+++ freeciv/client/gui-win32/menu.c     2008-07-24 23:10:54.000000000 +0300
@@ -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 > 0);
+    my_enable_menu(menu, IDM_VIEW_NATIONAL_BORDERS, game.info.borders_sq > 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-07-21 12:41:52.000000000 +0300
+++ freeciv/client/text.c       2008-07-24 23:07:46.000000000 +0300
@@ -112,7 +112,7 @@
   if (tile_has_special(ptile, S_HUT)) {
     astr_add_line(&str, _("Minor Tribe Village"));
   }
-  if (game.info.borders > 0 && !pcity) {
+  if (game.info.borders_sq > 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-07-24 19:15:22.000000000 +0300
+++ freeciv/client/tilespec.c   2008-07-24 23:08:11.000000000 +0300
@@ -4119,7 +4119,7 @@
       }
     }
 
-    if (draw_borders && game.info.borders > 0 && known[0] && known[1]) {
+    if (draw_borders && game.info.borders_sq > 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/game.c freeciv/common/game.c
--- freeciv/common/game.c       2008-07-03 21:58:05.000000000 +0300
+++ freeciv/common/game.c       2008-07-24 22:56:34.000000000 +0300
@@ -287,7 +287,7 @@
   game.info.spacerace     = GAME_DEFAULT_SPACERACE;
   game.info.turnblock     = GAME_DEFAULT_TURNBLOCK;
   game.info.fogofwar      = GAME_DEFAULT_FOGOFWAR;
-  game.info.borders       = GAME_DEFAULT_BORDERS;
+  game.info.borders_sq    = 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-07-18 22:08:33.000000000 +0300
+++ freeciv/common/game.h       2008-07-24 22:58:47.000000000 +0300
@@ -194,9 +194,9 @@
 #define GAME_DEFAULT_FOGOFWAR        TRUE
 
 /* 0 means no national borders. */
-#define GAME_DEFAULT_BORDERS         4
+#define GAME_DEFAULT_BORDERS         (4*4+1*1)
 #define GAME_MIN_BORDERS             0
-#define GAME_MAX_BORDERS             12
+#define GAME_MAX_BORDERS             (13*13-1)
 
 #define GAME_DEFAULT_HAPPYBORDERS    TRUE
 
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def  2008-07-06 17:49:04.000000000 +0300
+++ freeciv/common/packets.def  2008-07-24 22:51:07.000000000 +0300
@@ -417,7 +417,7 @@
   BOOL fixedlength;
   BOOL auto_ai_toggle;
   BOOL fogofwar;  
-  UINT8 borders;
+  UINT8 borders_sq;
   BOOL happyborders;
   BOOL slow_invasions;
   UINT8 add_to_size_limit;
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c       2008-03-08 16:32:49.000000000 +0200
+++ freeciv/common/unit.c       2008-07-24 22:59:37.000000000 +0300
@@ -1299,7 +1299,7 @@
   if (tile_city(punit->tile)) {
     return FALSE;
   }
-  if (game.info.borders > 0
+  if (game.info.borders_sq > 0
       && game.info.happyborders
       && tile_owner(punit->tile) == unit_owner(punit)) {
     return FALSE;
diff -Nurd -X.diff_ignore freeciv/common/vision.c freeciv/common/vision.c
--- freeciv/common/vision.c     2008-07-06 17:49:04.000000000 +0300
+++ freeciv/common/vision.c     2008-07-24 22:53:57.000000000 +0300
@@ -132,12 +132,7 @@
 
   psite = create_vision_site(-base_number(pbase) - 1, ptile, ptile->owner);
   psite->size = 0;
-  if (game.info.borders) {
-    psite->border_radius_sq = 2; /* FIXME: Should depend on game.info.borders 
value.
-                                  * Currently bigger radius doesn't claim 
territory north */
-  } else {
-    psite->border_radius_sq = 0;
-  }
+  psite->border_radius_sq = game.info.borders_sq;
   sz_strlcpy(psite->name, base_name_translation(pbase));
 
   return psite;
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c  2008-07-18 22:08:35.000000000 +0300
+++ freeciv/server/citytools.c  2008-07-24 22:52:25.000000000 +0300
@@ -2298,13 +2298,16 @@
   int radius_sq = get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ);
 
   if (NULL != psite) {
-    int delta = psite->size - game.info.borders;
-
-    /* TODO: city size effect or ruleset steps instead */
-    if (0 >= delta) {
-      psite->border_radius_sq = 2 * psite->size;
+    /* Exact behavior could be ruleset defined. */
+    if (game.info.borders_sq) {
+      psite->border_radius_sq = game.info.borders_sq;
+      if (psite->identity > 0) {
+        /* City */
+        psite->border_radius_sq = MAX(psite->border_radius_sq, 2*2+1*1);
+      }
+      psite->border_radius_sq += psite->size;
     } else {
-      psite->border_radius_sq = (2 + delta) * game.info.borders;
+      psite->border_radius_sq = 0;
     }
 
     if (radius_sq < psite->border_radius_sq) {
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c    2008-07-06 17:49:05.000000000 +0300
+++ freeciv/server/maphand.c    2008-07-24 23:02:02.000000000 +0300
@@ -1615,7 +1615,7 @@
   struct city *pcity = tile_city(ptile);
   struct vision_site *psite = map_get_player_site(ptile, powner);
 
-  if (0 == game.info.borders) {
+  if (0 == game.info.borders_sq) {
     /* no borders */
     return;
   }
@@ -1683,7 +1683,7 @@
   struct city *pcity = tile_city(ptile);
   struct vision_site *psite = map_get_player_site(ptile, powner);
 
-  if (0 == game.info.borders) {
+  if (0 == game.info.borders_sq) {
     /* no borders */
     return;
   }
@@ -1777,7 +1777,7 @@
 *************************************************************************/
 void map_calculate_borders(void)
 {
-  if (game.info.borders == 0) {
+  if (game.info.borders_sq == 0) {
     return;
   }
 
diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c 
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c        2008-07-03 21:58:06.000000000 +0300
+++ freeciv/server/sanitycheck.c        2008-07-24 23:02:56.000000000 +0300
@@ -315,7 +315,7 @@
                  city_name(pcity), pcity->size,
                  is_city_center(pcity, ptile) ? "{city center}" : "");
        }
-       if (game.info.borders > 0 && owner && owner != city_owner(pcity)) {
+       if (game.info.borders_sq > 0 && owner && owner != city_owner(pcity)) {
          SANITY_("(%4d,%4d) marked as empty, "
                  "but in enemy territory! "
                  "\"%s\"[%d]%s"),
@@ -351,7 +351,7 @@
                  city_name(pcity), pcity->size,
                  is_city_center(pcity, ptile) ? "{city center}" : "");
        }
-       if (game.info.borders > 0 && owner && owner != city_owner(pcity)) {
+        if (game.info.borders_sq > 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   2008-07-18 22:08:35.000000000 +0300
+++ freeciv/server/savegame.c   2008-07-24 23:04:51.000000000 +0300
@@ -3808,6 +3808,7 @@
   char **technology_order = NULL;
   enum tile_special_type *special_order = NULL;
   char *savefile_options = secfile_lookup_str(file, "savefile.options");
+  int old_borders;
 
   /* [savefile] */
 
@@ -3982,7 +3983,10 @@
     (void) section_file_lookup(file, "game.farmfood");
 
     /* National borders setting. */
-    game.info.borders = secfile_lookup_int_default(file, 0, "game.borders");
+    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.happyborders = secfile_lookup_bool_default(file, FALSE, 
                                                    "game.happyborders");
 
@@ -4665,7 +4669,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, "game.borders");
+  secfile_insert_int(file, game.info.borders_sq, "game.borders_sq");
   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-03-08 16:32:28.000000000 +0200
+++ freeciv/server/score.c      2008-07-24 23:05:22.000000000 +0300
@@ -178,7 +178,7 @@
       }
     }
 
-    if (game.info.borders > 0) {
+    if (game.info.borders_sq > 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-06-18 18:49:38.000000000 +0300
+++ freeciv/server/settings.c   2008-07-24 22:50:49.000000000 +0300
@@ -679,13 +679,16 @@
          GAME_MIN_KILLCITIZEN, GAME_MAX_KILLCITIZEN,
          GAME_DEFAULT_KILLCITIZEN)
 
-  GEN_INT("borders", game.info.borders,
+  GEN_INT("borders", game.info.borders_sq,
          SSET_RULES, SSET_MILITARY, SSET_SITUATIONAL, SSET_TO_CLIENT,
-         N_("National borders radius"),
+         N_("National borders"),
          N_("If this is set to greater than 0, then any land tiles "
-            "within the given radius of a city will be owned by that "
-            "nation. Special rules apply for ocean tiles or tiles within "
-            "range of more than one nation's cities."),
+            "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."),
          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-07-06 17:49:05.000000000 +0300
+++ freeciv/version.in  2008-07-24 22:51:18.000000000 +0300
@@ -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.Jul.06"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2008.Jul.24"
 NETWORK_CAPSTRING_OPTIONAL=""
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to