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

 This patch adds is-info -packet send-functions parameter to force
send even if it's identical.

 This is required for properly fixing #39627. This would also allow
restoring is-info to some packet types it has been removed from
because similar problems.


 - ML

diff -Nurd -X.diff_ignore freeciv/common/generate_packets.py freeciv/common/generate_packets.py
--- freeciv/common/generate_packets.py	2008-03-19 05:04:21.000000000 +0200
+++ freeciv/common/generate_packets.py	2008-06-19 19:08:26.000000000 +0300
@@ -544,6 +544,7 @@
         if len(self.fields)>5 or string.split(self.name,"_")[1]=="ruleset":
             self.handle_via_packet=1
 
+        self.extra_force_arg=""
         self.extra_send_args=""
         self.extra_send_args2=""
         self.extra_send_args3=string.join(
@@ -555,9 +556,10 @@
         if not self.no_packet:
             self.extra_send_args=', const struct %(packet_name)s *packet'%self.__dict__+self.extra_send_args
             self.extra_send_args2=', packet'+self.extra_send_args2
-
+        if not self.is_action:
+            self.extra_force_arg=', bool force_send'
         self.receive_prototype='static struct %(packet_name)s *receive_%(name)s(struct connection *pc, enum packet_type type)'%self.__dict__
-        self.send_prototype='static int send_%(name)s(struct connection *pc%(extra_send_args)s)'%self.__dict__
+        self.send_prototype='static int send_%(name)s(struct connection *pc%(extra_force_arg)s%(extra_send_args)s)'%self.__dict__
 
     # See Field.get_dict
     def get_dict(self,vars):
@@ -714,12 +716,12 @@
             if self.delta:
                 body=self.get_delta_send_body()
                 if self.is_action:
-                    force_send="TRUE"
+                    force_send_var="\n  bool force_send = TRUE;"
                 else:
-                    force_send="FALSE"
+                    force_send_var=""
                 delta_header='''  %(name)s_fields fields;
   struct %(packet_name)s *old, *clone;
-  bool differ, old_from_hash, force_send_of_unchanged = %(force_send)s;
+  bool differ, old_from_hash;%(force_send_var)s
   struct hash_table **hash = &pc->phs.sent[%(type)s];
   int different = 0;
 '''
@@ -762,7 +764,7 @@
   if (!old) {
     old = fc_malloc(sizeof(*old));
     memset(old, 0, sizeof(*old));
-    force_send_of_unchanged = TRUE;
+    force_send = TRUE;
   }
 
 '''
@@ -778,7 +780,7 @@
             s='    stats_%(name)s_discarded++;\n'
         else:
             s=""
-        body=body+'''  if (different == 0 && !force_send_of_unchanged) {
+        body=body+'''  if (different == 0 && !force_send) {
 %(fl)s%(s)s<pre2>    return 0;
   }
 
@@ -926,7 +928,7 @@
             self.dirs.append("cs")
             arr.remove("cs")
         assert len(self.dirs)>0,repr(self.name)+repr(self.dirs)
-            
+
         self.is_action="is-info" not in arr
         if not self.is_action: arr.remove("is-info")
         
@@ -1001,11 +1003,16 @@
             self.extra_send_args2=', packet'+self.extra_send_args2
 
         self.receive_prototype='struct %(name)s *receive_%(name)s(struct connection *pc, enum packet_type type)'%self.__dict__
-        self.send_prototype='int send_%(name)s(struct connection *pc%(extra_send_args)s)'%self.__dict__
+        self.force_arg=""
+        self.force_value=""
+        if not self.is_action:
+            self.force_arg=", bool force_send"
+            self.force_value=", force_send"
+        self.send_prototype='int send_%(name)s(struct connection *pc%(force_arg)s%(extra_send_args)s)'%self.__dict__
         if self.want_lsend:
-            self.lsend_prototype='void lsend_%(name)s(struct conn_list *dest%(extra_send_args)s)'%self.__dict__
+            self.lsend_prototype='void lsend_%(name)s(struct conn_list *dest%(force_arg)s%(extra_send_args)s)'%self.__dict__
         if self.want_dsend:
-            self.dsend_prototype='int dsend_%(name)s(struct connection *pc%(extra_send_args3)s)'%self.__dict__
+            self.dsend_prototype='int dsend_%(name)s(struct connection *pc%(force_arg)s%(extra_send_args3)s)'%self.__dict__
             if self.want_lsend:
                 self.dlsend_prototype='void dlsend_%(name)s(struct conn_list *dest%(extra_send_args3)s)'%self.__dict__
 
@@ -1165,10 +1172,11 @@
 
   switch(pc->phs.variant[%(type)s]) {
 '''%self.get_dict(vars())
+        args="pc"
+        if not self.is_action:
+            args=args+', force_send'
         if not self.no_packet:
-            args="pc, packet"
-        else:
-            args="pc"
+            args=args+', packet'
         for v in self.variants:
             name2=v.name
             no=v.no
@@ -1195,7 +1203,7 @@
         return '''%(lsend_prototype)s
 {
   conn_list_iterate(dest, pconn) {
-    send_%(name)s(pconn%(extra_send_args2)s);
+    send_%(name)s(pconn%(force_value)s%(extra_send_args2)s);
   } conn_list_iterate_end;
 }
 
@@ -1212,7 +1220,7 @@
 
 %(fill)s
   
-  return send_%(name)s(pc, real_packet);
+  return send_%(name)s(pc, real_packet%(force_value)s);
 }
 
 '''%self.get_dict(vars())
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c	2008-06-18 17:45:27.000000000 +0300
+++ freeciv/server/maphand.c	2008-06-19 19:10:14.000000000 +0300
@@ -708,7 +708,7 @@
         info.special[spe] = tile_has_base(ptile, pbase);
       } base_type_iterate_end;
 
-      send_packet_tile_info(pconn, &info);
+      send_packet_tile_info(pconn, FALSE, &info);
     } else if (pplayer && map_is_known(ptile, pplayer)
 	       && map_get_seen(ptile, pplayer, V_MAIN) == 0) {
       struct player_tile *plrtile = map_get_player_tile(ptile, pplayer);
@@ -739,7 +739,7 @@
         info.special[spe] = player_tile_has_base(plrtile, pbase);
       } base_type_iterate_end;
 
-      send_packet_tile_info(pconn, &info);
+      send_packet_tile_info(pconn, FALSE, &info);
     } else if (send_unknown) {
       info.known = TILE_UNKNOWN;
       info.continent = 0;
@@ -761,7 +761,7 @@
         info.special[spe] = FALSE;
       } base_type_iterate_end;
 
-      send_packet_tile_info(pconn, &info);
+      send_packet_tile_info(pconn, FALSE, &info);
     }
   }
   conn_list_iterate_end;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to