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

The problem is that the bulb stock is reducted for only the player who
got the tech, not the others...

It just spoilt LT9. Patch attached...

--- server/plrhand.c.old	2007-09-13 17:34:35.000000000 +0200
+++ server/plrhand.c	2007-09-13 18:38:57.000000000 +0200
@@ -543,6 +543,12 @@
   plr->research.bulbs_researched = 
       MAX(plr->research.bulbs_researched - total_bulbs_required(plr), 0);
 
+  players_iterate(pplayer) {
+    if (players_on_same_team(pplayer, plr) && pplayer->is_alive) {
+      pplayer->research.bulbs_researched = plr->research.bulbs_researched;
+    }
+  } players_iterate_end;
+
   /* do all the updates needed after finding new tech */
   found_new_tech(plr, plr->research.researching, TRUE, TRUE, A_NONE);
 }
@@ -556,17 +562,14 @@
 
   /* 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;
+    if (players_on_same_team(pplayer, plr) && pplayer->is_alive) {
+      pplayer->research.bulbs_researched = plr->research.bulbs_researched;
     }
   } players_iterate_end;
-  
+
   excessive_bulbs =
       (plr->research.bulbs_researched - total_bulbs_required(plr));
 
@@ -576,6 +579,16 @@
       update_tech(plr, 0);
     }
   }
+
+  /* Sanity check */ 
+  players_iterate(pplayer) {
+    if (players_on_same_team(pplayer, plr) && pplayer->is_alive) {
+      pplayer->research.researching = plr->research.researching;
+      pplayer->ai.tech_goal = plr->ai.tech_goal;
+      assert(pplayer->research.bulbs_researched
+             == plr->research.bulbs_researched);
+    }
+  } players_iterate_end;
 }
 
 /**************************************************************************
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to