Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2004:
[Freeciv-Dev] (PR#8672) punit->occupy has no value at the server
Home

[Freeciv-Dev] (PR#8672) punit->occupy has no value at the server

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8672) punit->occupy has no value at the server
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Jun 2004 08:56:57 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8672 >

> [jdorje - Tue May 04 17:48:11 2004]:

> The quick fix is that the AI should call get_transporter_occupancy() 
> instead.  However this function is slow.  Better would be to update the 
> punit->occupy value at the server.  It should be renamed 
> (punit->occupancy?) and updated in 
> load_unit_onto_transporter/unload_unit_from_transporter.

The "better" fix seems to be stalled.  This is the quick fix:

- Rename punit->occupy as punit->client.is_occupied.
- Make it always a boolean.
- Owned and allied units have it as a boolean too (network change).
- Don't use it in the server.
- Avoid drawing the unit stack sprite wice (semi-related).

jason

? gmon.out
? profile
? profile-new
? profile-orig
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.319
diff -u -r1.319 aiunit.c
--- ai/aiunit.c 14 Jun 2004 10:37:52 -0000      1.319
+++ ai/aiunit.c 18 Jun 2004 15:54:58 -0000
@@ -2433,7 +2433,7 @@
   }
 
   /* Check if we are an empty barbarian boat and so not needed */
-  if (is_barbarian(pplayer) && !punit->occupy) {
+  if (is_barbarian(pplayer) && get_transporter_occupancy(punit) == 0) {
     wipe_unit(punit);
     return;
   }
@@ -2517,7 +2517,7 @@
       /* Cannot select a passenger-in-charge */
       break;
     }
-  } while (punit->occupy != 0);
+  } while (get_transporter_occupancy(punit) != 0);
 
   /* Not carrying anyone, even the ferryman */
 
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.136
diff -u -r1.136 control.c
--- client/control.c    28 May 2004 19:13:07 -0000      1.136
+++ client/control.c    18 Jun 2004 15:54:58 -0000
@@ -1399,7 +1399,7 @@
     maybe_goto = keyboardless_goto;
   }
   else if (unit_list_size(&ptile->units) == 1
-      && !unit_list_get(&ptile->units, 0)->occupy) {
+          && !unit_list_get(&ptile->units, 0)->client.is_occupied) {
     struct unit *punit=unit_list_get(&ptile->units, 0);
     if(game.player_idx==punit->owner) {
       if(can_unit_do_activity(punit, ACTIVITY_IDLE)) {
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.127
diff -u -r1.127 mapview_common.c
--- client/mapview_common.c     17 Jun 2004 19:45:03 -0000      1.127
+++ client/mapview_common.c     18 Jun 2004 15:54:59 -0000
@@ -734,12 +734,6 @@
                        unit_width, unit_height);
     }
   }
-
-  if (punit->occupy != 0) {
-    canvas_put_sprite(pcanvas, canvas_x, canvas_y,
-                     sprites.unit.stack,
-                     unit_offset_x, unit_offset_y, unit_width, unit_height);
-  }
 }
 
 /**************************************************************************
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.381
diff -u -r1.381 packhand.c
--- client/packhand.c   16 Jun 2004 22:45:39 -0000      1.381
+++ client/packhand.c   18 Jun 2004 15:54:59 -0000
@@ -111,7 +111,7 @@
   punit->paradropped = packet->paradropped;
   punit->connecting = packet->connecting;
   punit->done_moving = packet->done_moving;
-  punit->occupy = packet->occupy;
+  punit->client.is_occupied = packet->is_occupied;
   if (packet->transported) {
     punit->transported_by = packet->transported_by;
   } else {
@@ -152,7 +152,7 @@
   punit->veteran = packet->veteran;
   punit->hp = packet->hp;
   punit->activity = packet->activity;
-  punit->occupy = (packet->occupied ? 1 : 0);
+  punit->client.is_occupied = packet->is_occupied;
   if (packet->transported) {
     punit->transported_by = packet->transported_by;
   } else {
@@ -960,7 +960,7 @@
     ret = TRUE;
     punit->activity_count = packet_unit->activity_count;
     punit->transported_by = packet_unit->transported_by;
-    punit->occupy = packet_unit->occupy;
+    punit->client.is_occupied = packet_unit->client.is_occupied;
     if (punit->ai.control != packet_unit->ai.control) {
       punit->ai.control = packet_unit->ai.control;
       repaint_unit = TRUE;
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.175
diff -u -r1.175 tilespec.c
--- client/tilespec.c   16 Jun 2004 22:45:39 -0000      1.175
+++ client/tilespec.c   18 Jun 2004 15:55:00 -0000
@@ -1671,7 +1671,7 @@
     }
   }
 
-  if (stack || punit->occupy) {
+  if (stack || punit->client.is_occupied) {
     ADD_SPRITE_FULL(sprites.unit.stack);
   } else {
     ADD_SPRITE_FULL(sprites.unit.vet_lev[punit->veteran]);
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.69
diff -u -r1.69 dialogs.c
--- client/gui-gtk-2.0/dialogs.c        6 Jun 2004 21:02:15 -0000       1.69
+++ client/gui-gtk-2.0/dialogs.c        18 Jun 2004 15:55:00 -0000
@@ -1385,7 +1385,7 @@
 
     if (pleaf->transported_by == root_id) {
       unit_select_append(pleaf, &it_leaf, it_root);
-      if (pleaf->occupy > 0) {
+      if (pleaf->client.is_occupied) {
        unit_select_recurse(pleaf->id, &it_leaf);
       }
     }
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.169
diff -u -r1.169 capstr.c
--- common/capstr.c     12 Jun 2004 17:42:27 -0000      1.169
+++ common/capstr.c     18 Jun 2004 15:55:00 -0000
@@ -78,7 +78,7 @@
                    "+starter +union +iso_maps +big_map_size +orders2client " \
                    "+change_production +tilespec1 +no_earth +trans " \
                    "+want_hack invasions bombard +killstack2 spec +spec2 " \
-                   "+city_map"
+                   "+city_map +is_occupied"
 
 /* "+1.14.delta" is the new delta protocol for 1.14.0-dev.
  *
@@ -124,6 +124,8 @@
  * "spec2" is semi-configurable specialists in an array
  *
  * "city_map" means the city_map is sent as an array instead of a bitfield.
+ *
+ * "is_occupied" means unit occupancy is always sent as a boolean.
  */
 
 void init_our_capability(void)
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.29
diff -u -r1.29 packets.def
--- common/packets.def  12 Jun 2004 17:42:27 -0000      1.29
+++ common/packets.def  18 Jun 2004 15:55:02 -0000
@@ -601,11 +601,12 @@
   UINT8 veteran; add-cap(veteran)
   BOOL veteran_old; remove-cap(veteran)
   BOOL ai, paradropped, connecting, transported, done_moving;
+  BOOL is_occupied;
 
   UNIT_TYPE type;
   UNIT transported_by; /* Only valid if transported is set. */
   UINT8 movesleft, hp, fuel, activity_count;
-  UINT8 unhappiness, upkeep, upkeep_food, upkeep_gold, occupy;
+  UINT8 unhappiness, upkeep, upkeep_food, upkeep_gold;
   COORD goto_dest_x,goto_dest_y;
   ACTIVITY activity;
   SPECIAL activity_target;
@@ -625,7 +626,7 @@
 
   UINT8 veteran; add-cap(veteran)
   BOOL veteran_old; remove-cap(veteran)
-  BOOL occupied, goes_out_of_sight, transported;
+  BOOL is_occupied, goes_out_of_sight, transported;
 
   UINT8 hp, activity;
   UNIT transported_by; /* Only valid if transported is set. */
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.210
diff -u -r1.210 unit.c
--- common/unit.c       19 May 2004 00:49:31 -0000      1.210
+++ common/unit.c       18 Jun 2004 15:55:02 -0000
@@ -1723,7 +1723,7 @@
   punit->ord_map = 0;
   punit->ord_city = 0;
   set_unit_activity(punit, ACTIVITY_IDLE);
-  punit->occupy = 0;
+  punit->client.is_occupied = FALSE;
   punit->has_orders = FALSE;
 
   return punit;
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.118
diff -u -r1.118 unit.h
--- common/unit.h       19 May 2004 00:49:31 -0000      1.118
+++ common/unit.h       18 Jun 2004 15:55:02 -0000
@@ -171,7 +171,10 @@
   bool done_moving;
 
   int transported_by;
-  int occupy; /* number of units that occupy transporter */
+
+  struct {
+    bool is_occupied;
+  } client;
 
   bool has_orders;
   struct {
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.294
diff -u -r1.294 unittools.c
--- server/unittools.c  1 Jun 2004 19:44:24 -0000       1.294
+++ server/unittools.c  18 Jun 2004 15:55:02 -0000
@@ -1862,7 +1862,7 @@
     packet->transported = TRUE;
     packet->transported_by = punit->transported_by;
   }
-  packet->occupy = get_transporter_occupancy(punit);
+  packet->is_occupied = (get_transporter_occupancy(punit) > 0);
   packet->has_orders = punit->has_orders;
   if (punit->has_orders) {
     int i;
@@ -1912,7 +1912,7 @@
   packet->veteran = punit->veteran;
   packet->type = punit->type;
   packet->hp = punit->hp;
-  packet->occupied = (get_transporter_occupancy(punit) > 0);
+  packet->is_occupied = (get_transporter_occupancy(punit) > 0);
   if (punit->activity == ACTIVITY_EXPLORE
       || punit->activity == ACTIVITY_GOTO) {
     packet->activity = ACTIVITY_IDLE;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8672) punit->occupy has no value at the server, Jason Short <=