Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] (PR#4611) put the 'occupied' flag in the city_info packet
Home

[Freeciv-Dev] (PR#4611) put the 'occupied' flag in the city_info packet

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4611) put the 'occupied' flag in the city_info packet
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Jul 2003 11:37:42 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Currently the occupied flag is only sent as part of the short_city 
packet.  But when the city_info packet is sent out instead the shorter 
packet is usually not sent.  This patch sends the 'occupied' flag along 
with the city_info packet as well.

jason

? rc
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.316
diff -u -r1.316 packhand.c
--- client/packhand.c   2003/07/17 18:56:50     1.316
+++ client/packhand.c   2003/07/18 18:36:06
@@ -419,6 +419,15 @@
                            ARRAY_SIZE(pcity->improvements));
   }
   copy_worklist(&pcity->worklist, &packet->worklist);
+
+  pcity->occupied = packet->occupied;
+  if (!pcity->occupied
+      && (unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0)) {
+    freelog(LOG_ERROR, _("%s claims to be unoccupied but contains units!"),
+           pcity->name);
+    pcity->occupied = TRUE;
+  }
+
   pcity->did_buy=packet->did_buy;
   pcity->did_sell=packet->did_sell;
   pcity->was_happy=packet->was_happy;
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.138
diff -u -r1.138 capstr.c
--- common/capstr.c     2003/07/14 21:01:49     1.138
+++ common/capstr.c     2003/07/18 18:36:06
@@ -79,7 +79,7 @@
                    "+impr_req +waste +fastfocus +continent +small_dipl " \
                    "+no_nation_selected +diplomacy +no_extra_tiles " \
                    "+diplomacy2 +citizens_style +root_tech auth " \
-                   "+nat_ulimit retake"
+                   "+nat_ulimit retake occupied"
 
 /* "+1.14.0" is protocol for 1.14.0 release.
  *
@@ -137,6 +137,8 @@
  * allowing easy adding of arbitrarily many nations.
  *
  * "retake" means that a client can switch players during a running game.
+ *
+ * "occupied" means pcity->occupied is sent by the city info packet.
  */
 
 void init_our_capability(void)
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.249
diff -u -r1.249 packets.c
--- common/packets.c    2003/07/10 03:34:30     1.249
+++ common/packets.c    2003/07/18 18:36:06
@@ -1358,7 +1358,8 @@
                        COND_SET_BIT(req->was_happy, 3) |
                        COND_SET_BIT(req->airlift, 4) |
                        COND_SET_BIT(req->diplomat_investigate, 5) |
-                       COND_SET_BIT(req->changed_from_is_unit, 6)));
+                       COND_SET_BIT(req->changed_from_is_unit, 6) |
+                       COND_SET_BIT(req->occupied, 7)));
 
   dio_put_city_map(&dout, (char *) req->city_map);
   dio_put_bit_string(&dout, (char *) req->improvements);
@@ -1449,6 +1450,11 @@
   packet->airlift = TEST_BIT(data, 4);
   packet->diplomat_investigate = TEST_BIT(data, 5);
   packet->changed_from_is_unit = TEST_BIT(data, 6);
+  if (has_capability("occupied", pc->capability)) {
+    packet->occupied = TEST_BIT(data, 7);
+  } else {
+    packet->occupied = FALSE; /* ? */
+  }
 
   dio_get_city_map(&din, (char *) packet->city_map,
                   sizeof(packet->city_map));
Index: common/packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.148
diff -u -r1.148 packets.h
--- common/packets.h    2003/07/10 03:34:30     1.148
+++ common/packets.h    2003/07/18 18:36:06
@@ -371,6 +371,7 @@
   char improvements[B_LAST+1];
   char city_map[CITY_MAP_SIZE*CITY_MAP_SIZE+1];
 
+  bool occupied;
   bool did_buy, did_sell;
   bool was_happy;
   bool airlift;
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.222
diff -u -r1.222 citytools.c
--- server/citytools.c  2003/07/18 17:11:18     1.222
+++ server/citytools.c  2003/07/18 18:36:06
@@ -1608,6 +1608,12 @@
   packet->diplomat_investigate=dipl_invest;
 
   packet->airlift=pcity->airlift;
+
+  /* pcity->occupied isn't used at the server, so we go straight to the
+   * unit list to check the occupied status. */
+  packet->occupied =
+    (unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0);
+
   packet->did_buy=pcity->did_buy;
   packet->did_sell=pcity->did_sell;
   packet->was_happy=pcity->was_happy;

[Prev in Thread] Current Thread [Next in Thread]