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

Good patch.  This variant turns it into a function and sync's the whole
research structure.  I'll commit shortly.

-jason

Index: server/plrhand.c
===================================================================
--- server/plrhand.c	(revision 14848)
+++ server/plrhand.c	(working copy)
@@ -68,6 +68,19 @@
 					     struct player *receiver);
 
 /**************************************************************************
+  Make sure all research of players on the team is in sync with this
+  player's.
+**************************************************************************/
+static void sync_team_research(struct player *plr)
+{
+  players_iterate(pplayer) {
+    if (players_on_same_team(pplayer, plr) && pplayer->is_alive) {
+      pplayer->research = plr->research;
+    }
+  } players_iterate_end;
+}
+
+/**************************************************************************
 ...
 **************************************************************************/
 void do_dipl_cost(struct player *pplayer, Tech_Type_id new_tech)
@@ -543,6 +556,8 @@
   plr->research.bulbs_researched = 
       MAX(plr->research.bulbs_researched - total_bulbs_required(plr), 0);
 
+  sync_team_research(plr);
+
   /* do all the updates needed after finding new tech */
   found_new_tech(plr, plr->research.researching, TRUE, TRUE, A_NONE);
 }
@@ -556,17 +571,10 @@
 
   /* count our research contribution this turn */
   plr->research.bulbs_last_turn += bulbs;
+  plr->research.bulbs_researched += bulbs;
 
-  players_iterate(pplayer) {
-    if (pplayer == plr) {
-      pplayer->research.bulbs_researched += bulbs;
-    } else if (pplayer->diplstates[plr->player_no].type == DS_TEAM
-               && pplayer->is_alive) {
-      /* Share with union partner(s). We'll get in return later. */
-      pplayer->research.bulbs_researched += bulbs;
-    }
-  } players_iterate_end;
-  
+  sync_team_research(plr);
+
   excessive_bulbs =
       (plr->research.bulbs_researched - total_bulbs_required(plr));
 
@@ -576,6 +584,9 @@
       update_tech(plr, 0);
     }
   }
+
+  /* Sanity check */ 
+  sync_team_research(plr);
 }
 
 /**************************************************************************
@@ -697,6 +708,10 @@
     plr->research.changed_from = -1;
   }
   plr->research.researching=tech;
+
+  /* Update team research */
+  sync_team_research(plr);
+  
   if (plr->research.bulbs_researched > total_bulbs_required(plr)) {
     tech_researched(plr);
   }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to