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

2008/4/1 Marko Lindqvist:
>
>  New borders code has several comments to the effect that fortresses
> are not currently supported, and indeed building one immediately
> crashes game.

 Fix


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c   2008-07-03 21:58:06.000000000 +0300
+++ freeciv/client/packhand.c   2008-07-05 16:30:51.000000000 +0300
@@ -2852,6 +2852,7 @@
   sz_strlcpy(pbase->graphic_str, p->graphic_str);
   sz_strlcpy(pbase->graphic_alt, p->graphic_alt);
   sz_strlcpy(pbase->activity_gfx, p->activity_gfx);
+  pbase->buildable = p->buildable;
 
   for (i = 0; i < p->reqs_count; i++) {
     requirement_vector_append(&pbase->reqs, &p->reqs[i]);
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def  2008-07-03 21:58:05.000000000 +0300
+++ freeciv/common/packets.def  2008-07-05 16:30:07.000000000 +0300
@@ -1303,6 +1303,7 @@
 PACKET_RULESET_BASE=120;sc,lsend
   UINT8 id;
   STRING name[MAX_LEN_NAME];
+  BOOL buildable;
   STRING graphic_str[MAX_LEN_NAME];
   STRING graphic_alt[MAX_LEN_NAME];
   STRING activity_gfx[MAX_LEN_NAME];
diff -Nurd -X.diff_ignore freeciv/common/vision.c freeciv/common/vision.c
--- freeciv/common/vision.c     2008-04-05 13:11:52.000000000 +0300
+++ freeciv/common/vision.c     2008-07-05 16:35:45.000000000 +0300
@@ -17,10 +17,13 @@
 
 #include <assert.h>
 
+/* utility */
 #include "log.h"
 #include "mem.h"
 #include "shared.h"
 
+/* common */
+#include "game.h"
 #include "player.h"
 #include "tile.h"
 #include "vision.h"
@@ -114,6 +117,33 @@
 }
 
 /****************************************************************************
+  Build basic vision_site structure based on military base on tile.
+****************************************************************************/
+struct vision_site *create_vision_site_from_base(struct tile *ptile)
+{
+  struct vision_site *psite;
+  struct base_type *pbase;
+
+  pbase = tile_get_base(ptile);
+
+  if (!pbase) {
+    return NULL;
+  }
+
+  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;
+  }
+  sz_strlcpy(psite->name, base_name_translation(pbase));
+
+  return psite;
+}
+
+/****************************************************************************
   Returns the basic structure filled with current elements.
 ****************************************************************************/
 void update_vision_site_from_city(struct vision_site *psite,
diff -Nurd -X.diff_ignore freeciv/common/vision.h freeciv/common/vision.h
--- freeciv/common/vision.h     2008-04-05 13:11:52.000000000 +0300
+++ freeciv/common/vision.h     2008-07-05 16:04:42.000000000 +0300
@@ -134,6 +134,7 @@
 struct vision_site *create_vision_site(int identity, struct tile *location,
                                       struct player *owner);
 struct vision_site *create_vision_site_from_city(const struct city *pcity);
+struct vision_site *create_vision_site_from_base(struct tile *ptile);
 void update_vision_site_from_city(struct vision_site *psite,
                                  const struct city *pcity);
 void copy_vision_site(struct vision_site *dest, struct vision_site *src);
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c    2008-07-03 21:02:59.000000000 +0300
+++ freeciv/server/maphand.c    2008-07-05 16:07:12.000000000 +0300
@@ -1582,12 +1582,11 @@
       }
     } else {
       assert(ptile == psource);
-      assert(NULL != pcity); /* FIXME: temporary IDENTITY_NUMBER_ZERO */
 
       if (NULL != pcity) {
         psite = create_vision_site_from_city(pcity);
       } else {
-        psite = create_vision_site(IDENTITY_NUMBER_ZERO, psource, powner);
+        psite = create_vision_site_from_base(ptile);
       }
       change_playertile_site(playsite, psite);
     }
@@ -1650,6 +1649,7 @@
 
   circle_dxyr_iterate(ptile, psite->border_radius_sq, dtile, dx, dy, dr) {
     struct city *dcity = tile_city(dtile);
+    struct base_type *dbase = tile_get_base(dtile);
     struct player *downer = tile_owner(dtile);
 
     if (NULL != dcity) {
@@ -1657,6 +1657,11 @@
       continue;
     }
 
+    if (dbase && base_has_flag(dbase, BF_CLAIM_TERRITORY)) {
+      /* Cannot affect territory claiming bases */
+      continue;
+    }
+
     if (downer == powner) {
       struct vision_site *dsite = map_get_player_site(dtile, downer);
 
@@ -1712,6 +1717,7 @@
 
   circle_dxyr_iterate(ptile, psite->border_radius_sq, dtile, dx, dy, dr) {
     struct city *dcity = tile_city(dtile);
+    struct base_type *dbase = tile_get_base(dtile);
     struct player *downer = tile_owner(dtile);
 
     if (NULL != dcity) {
@@ -1719,6 +1725,11 @@
       continue;
     }
 
+    if (dbase && base_has_flag(dbase, BF_CLAIM_TERRITORY)) {
+      /* Cannot affect territory claiming bases */
+      continue;
+    }
+
     if (!map_is_known_and_seen(dtile, powner, V_MAIN)) {
       /* without city_reveal_tiles option */
       continue;
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2008-07-03 21:58:06.000000000 +0300
+++ freeciv/server/ruleset.c    2008-07-05 16:31:30.000000000 +0300
@@ -3356,6 +3356,7 @@
     sz_strlcpy(packet.graphic_str, b->graphic_str);
     sz_strlcpy(packet.graphic_alt, b->graphic_alt);
     sz_strlcpy(packet.activity_gfx, b->activity_gfx);
+    packet.buildable = b->buildable;
 
     j = 0;
     requirement_vector_iterate(&b->reqs, preq) {
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in  2008-07-02 01:47:22.000000000 +0300
+++ freeciv/version.in  2008-07-05 16:30: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.01"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2008.Jul.05"
 NETWORK_CAPSTRING_OPTIONAL=""
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to