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

The problem was in some assumptions of the patch.  Believing my own lying
eyes, the code seemed to pass a string in the packet handler that was
(nearly) identical to the savegame.

Unfortunately, there turned out to be intervening reformatting by the
packet handler....  Rather than change my assumptions, changed the
definition to a simple STRING.

Left some DEBUG logging, as this makes it obvious there are *way* too many
packet repetitions showing up!  (15 times for the same other player?
Half a dozen times for myself?  And that's just starting up....)

Committed revision 13315.

Index: server/plrhand.c
===================================================================
--- server/plrhand.c    (revision 13314)
+++ server/plrhand.c    (working copy)
@@ -1002,7 +1002,6 @@
       packet->inventions[i] = 
         research->inventions[i].state + '0';
     } advance_index_iterate_end;
-    packet->inventions[advance_count()] = '\0';
     packet->tax             = plr->economic.tax;
     packet->science         = plr->economic.science;
     packet->luxury          = plr->economic.luxury;
@@ -1015,7 +1014,6 @@
     advance_index_iterate(A_FIRST, i) {
       packet->inventions[i] = '0';
     } advance_index_iterate_end;
-    packet->inventions[advance_count()] = '\0';
     packet->tax             = 0;
     packet->science         = 0;
     packet->luxury          = 0;
@@ -1029,6 +1027,12 @@
   /* We have to inform the client that the other players also know
    * A_NONE. */
   packet->inventions[A_NONE] = research->inventions[A_NONE].state + '0';
+  packet->inventions[advance_count()] = '\0';
+#ifdef DEBUG
+  freelog(LOG_VERBOSE, "Player%d inventions:%s",
+          player_number(plr),
+          packet->inventions);
+#endif
 
   if (info_level >= INFO_FULL
       || (receiver
Index: common/packets.def
===================================================================
--- common/packets.def  (revision 13314)
+++ common/packets.def  (working copy)
@@ -686,7 +686,7 @@
   UINT8 ai_skill_level;
   UINT8 barbarian_type;
   VISION gives_shared_vision;
-  BIT_STRING inventions[A_LAST+1];
+  STRING inventions[A_LAST+1];
   SINT16 love[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
 
   UINT16 small_wonders[B_LAST]; diff
@@ -1480,7 +1480,7 @@
   BOOL ai;
   UINT8 barbarian_type;
   VISION gives_shared_vision;
-  BIT_STRING inventions[A_LAST+1];
+  STRING inventions[A_LAST+1];
   SINT16 love[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
   UINT16 small_wonders[B_LAST]; diff
 end
Index: client/packhand.c
===================================================================
--- client/packhand.c   (revision 13314)
+++ client/packhand.c   (working copy)
@@ -1461,12 +1461,16 @@
 {
   bool need_effect_update = FALSE;
 
+#ifdef DEBUG
+  freelog(LOG_VERBOSE, "Player%d inventions:%s",
+          player_number(pplayer),
+          inventions);
+#endif
+
   advance_index_iterate(A_NONE, i) {
-    enum tech_state oldstate
-      = get_player_research(pplayer)->inventions[i].state;
     enum tech_state newstate = inventions[i] - '0';
+    enum tech_state oldstate = player_invention_set(pplayer, i, newstate);
 
-    get_player_research(pplayer)->inventions[i].state = newstate;
     if (newstate != oldstate
        && (newstate == TECH_KNOWN || oldstate == TECH_KNOWN)) {
       need_effect_update = TRUE;
@@ -2318,7 +2322,7 @@
   a->preset_cost = p->preset_cost;
   a->num_reqs = p->num_reqs;
   a->helptext = mystrdup(p->helptext);
-  
+
   tileset_setup_tech_type(tileset, a);
 }
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to