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

My previous patches are wrong. It seems that global_init_tech, init_tech
and techlevel never worked well with team games, since the team research
is polled.

Index: server/srv_main.c
===================================================================
--- server/srv_main.c	(révision 13773)
+++ server/srv_main.c	(copie de travail)
@@ -2010,9 +2010,10 @@
     } players_iterate_end;
 
     players_iterate(pplayer) {
+      /* Nation specific techs */
       give_initial_techs(pplayer);
     } players_iterate_end;
-    
+
     players_iterate(pplayer) {
       int i;
       bool free_techs_already_given = FALSE;
@@ -2024,23 +2025,25 @@
 	  break;
         }
       } players_iterate_end;
-      
+
       if (free_techs_already_given) {
-        break;
+        continue;
       }
-      
-      for (i = 0; i < game.info.tech; i++) {
+
+      /* Global techs */
+      give_global_initial_techs(pplayer);
+      /* Note that A_NONE is always marked as researched, so the real number
+       * of techs_researched is (techs_researched - 1). */
+      for (i = get_player_research(pplayer)->techs_researched - 1;
+           i < game.info.tech; i++) {
         give_random_initial_tech(pplayer);
       }
     } players_iterate_end;
-    
-    
-    if(game.info.is_new_game) {
-      /* If we're starting a new game, reset the rules.max_players to be the
-       * number of players currently in the game.  But when loading a game
-       * we don't want to change it. */
-      game.info.max_players = game.info.nplayers;
-    }
+
+    /* If we're starting a new game, reset the rules.max_players to be the
+     * number of players currently in the game.  But when loading a game
+     * we don't want to change it. */
+    game.info.max_players = game.info.nplayers;
   }
 
   /* Set up alliances based on team selections */
Index: server/techtools.c
===================================================================
--- server/techtools.c	(révision 13773)
+++ server/techtools.c	(copie de travail)
@@ -594,29 +594,43 @@
 /****************************************************************************
   Gives initial techs to the player
 ****************************************************************************/
-void give_initial_techs(struct player* plr)
+void give_initial_techs(struct player *pplayer)
 {
-  struct nation_type *nation = nation_of_player(plr);
+  struct nation_type *nation = nation_of_player(pplayer);
   int i;
   
   /*
-   * Give game wide initial techs
+   * Give nation specific initial techs
    */
   for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
-    if (game.rgame.global_init_techs[i] == A_LAST) {
+    if (nation->init_techs[i] == A_LAST) {
       break;
     }
-    found_new_tech(plr, game.rgame.global_init_techs[i], FALSE, TRUE);
+    /* Maybe the player already got this tech by an other way (example: team) */
+    if (get_invention(pplayer, nation->init_techs[i]) != TECH_KNOWN) {
+      found_new_tech(pplayer, nation->init_techs[i], FALSE, TRUE);
+    }
   }
+}
 
+/****************************************************************************
+  Gives global initial techs to the player
+****************************************************************************/
+void give_global_initial_techs(struct player *pplayer)
+{
+  int i;
+  
   /*
-   * Give nation specific initial techs
+   * Give game wide initial techs
    */
   for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
-    if (nation->init_techs[i] == A_LAST) {
+    if (game.rgame.global_init_techs[i] == A_LAST) {
       break;
     }
-    found_new_tech(plr, nation->init_techs[i], FALSE, TRUE);
+    /* Maybe the player already got this tech by an other way (example: team) */
+    if (get_invention(pplayer, game.rgame.global_init_techs[i]) != TECH_KNOWN) {
+      found_new_tech(pplayer, game.rgame.global_init_techs[i], FALSE, TRUE);
+    }
   }
 }
 
Index: server/techtools.h
===================================================================
--- server/techtools.h	(révision 13773)
+++ server/techtools.h	(copie de travail)
@@ -34,7 +34,8 @@
 
 Tech_type_id give_random_free_tech(struct player *pplayer);
 Tech_type_id give_immediate_free_tech(struct player *pplayer);
-void give_initial_techs(struct player* plr);
-Tech_type_id give_random_initial_tech(struct player* pplayer);
+void give_initial_techs(struct player *pplayer);
+void give_global_initial_techs(struct player *pplayer);
+Tech_type_id give_random_initial_tech(struct player *pplayer);
 
 #endif
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to