Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11317) advances[i].name may be NULL
Home

[Freeciv-Dev] (PR#11317) advances[i].name may be NULL

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: muehlber@xxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11317) advances[i].name may be NULL
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Dec 2004 11:50:39 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11317 >

Here is a patch that changes almost all advances[i].name to
get_tech_name(plr, i).

This is necessary to avoid random problems in some, but not all, cases.
 One example is if you get your research target to be A_UNSET and hover
over the science indicator on the left panel, you'll get a NULL sprintf
(which can cause a crash on some platforms but with glibc just looks
ugly).  I think there are even bigger problems with future techs, and
these are hard to trace.  IMO it's safest just to always use get_tech_name.

I updated client, common, server, and gui-gtk-2.0.  The civmanual can't
easily be updated because there is no player pointer to pass in to
get_tech_name.  I didn't update any other GUIs because it's just too
much.  Gui authors should make these changes themselves.

-jason

? server/generator/output
Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.174.2.3
diff -u -r1.174.2.3 advmilitary.c
--- ai/advmilitary.c    18 Nov 2004 07:43:58 -0000      1.174.2.3
+++ ai/advmilitary.c    3 Dec 2004 19:45:30 -0000
@@ -749,7 +749,7 @@
       pplayer->ai.tech_want[tech_req] += desire;
       
       freelog(LOG_DEBUG, "%s wants %s for defense with desire %d <%d>",
-              pcity->name, advances[tech_req].name, desire,
+              pcity->name, get_tech_name(pplayer, tech_req), desire,
               tech_desire[unit_type]);
     }
   } simple_ai_unit_type_iterate_end;
@@ -920,7 +920,7 @@
           pplayer->ai.tech_want[tech_req] += want;
           
           CITY_LOG(LOG_DEBUG, pcity, "wants %s to build %s to punish 
%s@(%d,%d)"
-                   " with desire %d", advances[tech_req].name, 
+                   " with desire %d", get_tech_name(pplayer, tech_req), 
                    unit_name(unit_type), (acity ? acity->name : "enemy"),
                    ptile, want);
 
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.92
diff -u -r1.92 aihand.c
--- ai/aihand.c 20 Jul 2004 16:27:07 -0000      1.92
+++ ai/aihand.c 3 Dec 2004 19:45:31 -0000
@@ -350,7 +350,7 @@
   }
   pplayer->ai.tech_want[ai->goal.govt.req] += ai->goal.govt.val;
   freelog(LOG_DEBUG, "%s wants %s with want %d", pplayer->name,
-          advances[ai->goal.govt.req].name, 
+          get_tech_name(pplayer, ai->goal.govt.req), 
           pplayer->ai.tech_want[ai->goal.govt.req]);
 }
 
Index: ai/aitech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitech.c,v
retrieving revision 1.45
diff -u -r1.45 aitech.c
--- ai/aitech.c 25 Jun 2004 23:43:01 -0000      1.45
+++ ai/aitech.c 3 Dec 2004 19:45:31 -0000
@@ -159,7 +159,7 @@
     goal_values[i] /= steps;
     if (steps < 6) {
       freelog(LOG_DEBUG, "%s: want = %d, value = %d, goal_value = %d",
-             advances[i].name, pplayer->ai.tech_want[i],
+             get_tech_name(pplayer, i), pplayer->ai.tech_want[i],
              values[i], goal_values[i]);
     }
   } tech_type_iterate_end;
@@ -178,7 +178,7 @@
     }
   } tech_type_iterate_end;
   freelog(LOG_DEBUG, "%s wants %s with desire %d (%d).", 
-         pplayer->name, advances[newtech].name, values[newtech], 
+         pplayer->name, get_tech_name(pplayer, newtech), values[newtech], 
          pplayer->ai.tech_want[newtech]);
   if (choice) {
     choice->choice = newtech;
@@ -194,7 +194,8 @@
     freelog(LOG_DEBUG,
            "Goal->choice = %s, goal->want = %d, goal_value = %d, "
            "num_cities_nonzero = %d",
-           advances[goal->choice].name, goal->want, goal_values[newgoal],
+           get_tech_name(pplayer, goal->choice), goal->want,
+           goal_values[newgoal],
            num_cities_nonzero);
   }
   return;
@@ -220,7 +221,7 @@
   if (goal_choice.choice != A_UNSET) {
     pplayer->ai.tech_goal = goal_choice.choice;
     freelog(LOG_DEBUG, "next_tech_goal for %s is set to %s",
-           pplayer->name, advances[goal_choice.choice].name);
+           pplayer->name, get_tech_name(pplayer, goal_choice.choice));
   }
 }
 
@@ -286,8 +287,9 @@
        penalty + pplayer->research.bulbs_researched <=
        total_bulbs_required(pplayer)) {
       freelog(LOG_DEBUG, "%s switching from %s to %s with penalty of %d.",
-             pplayer->name, advances[pplayer->research.researching].name,
-             advances[choice.choice].name, penalty);
+             pplayer->name,
+             get_tech_name(pplayer, pplayer->research.researching),
+             get_tech_name(pplayer, choice.choice), penalty);
       choose_tech(pplayer, choice.choice);
     }
   }
@@ -297,8 +299,9 @@
    * is practically never used, see the comment for ai_next_tech_goal */
   if (goal.choice != pplayer->ai.tech_goal) {
     freelog(LOG_DEBUG, "%s change goal from %s (want=%d) to %s (want=%d)",
-           pplayer->name, advances[pplayer->ai.tech_goal].name, 
-           goal.current_want, advances[goal.choice].name, goal.want);
+           pplayer->name, get_tech_name(pplayer, pplayer->ai.tech_goal), 
+           goal.current_want, get_tech_name(pplayer, goal.choice),
+           goal.want);
     choose_tech_goal(pplayer, goal.choice);
   }
 }
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.141.2.2
diff -u -r1.141.2.2 climisc.c
--- client/climisc.c    20 Oct 2004 04:34:26 -0000      1.141.2.2
+++ client/climisc.c    3 Dec 2004 19:45:31 -0000
@@ -243,7 +243,7 @@
   case CLAUSE_ADVANCE:
     my_snprintf(buf, bufsiz, _("The %s give %s"),
                get_nation_name_plural(pclause->from->nation),
-               advances[pclause->value].name);
+               get_tech_name(game.player_ptr, pclause->value));
     break;
   case CLAUSE_CITY:
     pcity = find_city_by_id(pclause->value);
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.81.2.4
diff -u -r1.81.2.4 helpdata.c
--- client/helpdata.c   27 Nov 2004 18:53:35 -0000      1.81.2.4
+++ client/helpdata.c   3 Dec 2004 19:45:31 -0000
@@ -253,7 +253,8 @@
          tech_type_iterate(i) {
            if (i != A_NONE && tech_exists(i)) {
              pitem = new_help_item(current_type);
-             my_snprintf(name, sizeof(name), " %s", advances[i].name);
+             my_snprintf(name, sizeof(name), " %s",
+                         get_tech_name(game.player_ptr, i));
              pitem->topic = mystrdup(name);
              pitem->text = mystrdup("");
              help_list_insert_back(&category_nodes, pitem);
@@ -517,7 +518,8 @@
   if (tech_exists(improvement_types[which].obsolete_by)) {
     my_snprintf(buf + strlen(buf), bufsz - strlen(buf),
                _("* The discovery of %s will make %s obsolete.\n"),
-               advances[improvement_types[which].obsolete_by].name,
+               get_tech_name(game.player_ptr,
+                       improvement_types[which].obsolete_by),
                improvement_types[which].name);
   }
 
@@ -534,7 +536,7 @@
     my_snprintf(buf + strlen(buf), bufsz - strlen(buf),
                _("* Allows all players with knowledge of %s "
                  "to build %s units.\n"),
-               advances[t].name, get_unit_type(u)->name);
+               get_tech_name(game.player_ptr, t), get_unit_type(u)->name);
     my_snprintf(buf + strlen(buf), bufsz - strlen(buf), "  ");
   }
 
@@ -553,7 +555,7 @@
        : sz_strlcpy(req_buf, (s)))
 
       if (b->tech_req != A_NONE) {
-       req_append(advances[b->tech_req].name);
+       req_append(get_tech_name(game.player_ptr, b->tech_req));
       }
 
       for (i = 0; b->terr_gate[i] != T_NONE; i++) {
@@ -581,7 +583,7 @@
       if (u->tech_requirement != A_LAST) {
        my_snprintf(buf + strlen(buf), bufsz - strlen(buf),
                    _("* Allows %s (with %s).\n"), u->name,
-                   advances[u->tech_requirement].name);
+                   get_tech_name(game.player_ptr, u->tech_requirement));
       } else {
        my_snprintf(buf + strlen(buf), bufsz - strlen(buf),
                    _("* Allows %s.\n"), u->name);
@@ -880,11 +882,12 @@
     if (tech1 != A_LAST) {
       sprintf(buf + strlen(buf),
              _("* The discovery of %s reduces the risk to 25%%.\n"),
-             advances[tech1].name);
+             get_tech_name(game.player_ptr, tech1));
     }
     if (tech2 != A_LAST) {
       sprintf(buf + strlen(buf),
-             _("* %s reduces the risk to 12%%.\n"), advances[tech2].name);
+             _("* %s reduces the risk to 12%%.\n"),
+             get_tech_name(game.player_ptr, tech2));
     }
   }
   if (utype->fuel > 0) {
@@ -973,14 +976,14 @@
     if (get_invention(game.player_ptr, i) == TECH_REACHABLE) {
       sprintf(buf + strlen(buf),
              _("If we would now start with %s we would need %d bulbs."),
-             advances[i].name,
+             get_tech_name(game.player_ptr, i),
              base_total_bulbs_required(game.player_ptr, i));
     } else if (tech_is_available(game.player_ptr, i)) {
       sprintf(buf + strlen(buf),
              _("To reach %s we need to obtain %d other "
                "technologies first. The whole project "
                "will require %d bulbs to complete."),
-             advances[i].name,
+             get_tech_name(game.player_ptr, i),
              num_unknown_techs_for_goal(game.player_ptr, i) - 1,
              total_bulbs_required_for_goal(game.player_ptr, i));
     } else {
@@ -1005,7 +1008,7 @@
   if (tech_flag(i, TF_BONUS_TECH)) {
     sprintf(buf + strlen(buf), _("* The first player to research %s gets "
                                 "an immediate advance.\n"),
-           advances[i].name);
+           get_tech_name(game.player_ptr, i));
   }
   if (tech_flag(i, TF_BOAT_FAST))
     sprintf(buf + strlen(buf), _("* Gives sea units one extra move.\n"));
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.408.2.13
diff -u -r1.408.2.13 packhand.c
--- client/packhand.c   24 Nov 2004 06:31:26 -0000      1.408.2.13
+++ client/packhand.c   3 Dec 2004 19:45:32 -0000
@@ -2331,8 +2331,7 @@
       freelog(LOG_DEBUG, "  tech_req    %2d/%s",
              b->tech_req,
              (b->tech_req == A_LAST) ?
-             "Never" :
-             advances[b->tech_req].name);
+             "Never" : get_tech_name(game.player_ptr, b->tech_req));
       freelog(LOG_DEBUG, "  bldg_req    %2d/%s",
              b->bldg_req,
              (b->bldg_req == B_LAST) ?
@@ -2362,7 +2361,8 @@
       }
       if (tech_exists(b->obsolete_by)) {
        freelog(LOG_DEBUG, "  obsolete_by %2d/%s",
-               b->obsolete_by, advances[b->obsolete_by].name);
+               b->obsolete_by,
+               get_tech_name(game.player_ptr, b->obsolete_by));
       } else {
        freelog(LOG_DEBUG, "  obsolete_by %2d/Never", b->obsolete_by);
       }
Index: client/text.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.c,v
retrieving revision 1.11.2.5
diff -u -r1.11.2.5 text.c
--- client/text.c       28 Nov 2004 16:01:51 -0000      1.11.2.5
+++ client/text.c       3 Dec 2004 19:45:32 -0000
@@ -534,7 +534,8 @@
 
   add(_("Shows your progress in researching "
        "the current technology.\n%s: %d/%d."),
-      advances[game.player_ptr->research.researching].name,
+      get_tech_name(game.player_ptr,
+                   game.player_ptr->research.researching),
       game.player_ptr->research.bulbs_researched,
       total_bulbs_required(game.player_ptr));
   RETURN;
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.204.2.9
diff -u -r1.204.2.9 tilespec.c
--- client/tilespec.c   24 Nov 2004 04:37:31 -0000      1.204.2.9
+++ client/tilespec.c   3 Dec 2004 19:45:32 -0000
@@ -1581,10 +1581,11 @@
 ***********************************************************************/
 void tilespec_setup_tech_type(int id)
 {
-  advances[id].sprite = lookup_sprite_tag_alt(advances[id].graphic_str,
-                                             advances[id].graphic_alt,
-                                             FALSE, "tech_type",
-                                             advances[id].name);
+  advances[id].sprite
+    = lookup_sprite_tag_alt(advances[id].graphic_str,
+                           advances[id].graphic_alt,
+                           FALSE, "tech_type",
+                           get_tech_name(game.player_ptr, id));
 
   /* should maybe do something if NULL, eg generic default? */
 }
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.75.2.7
diff -u -r1.75.2.7 dialogs.c
--- client/gui-gtk-2.0/dialogs.c        23 Nov 2004 17:24:44 -0000      1.75.2.7
+++ client/gui-gtk-2.0/dialogs.c        3 Dec 2004 19:45:33 -0000
@@ -494,7 +494,8 @@
        gtk_list_store_append(store, &it);
 
        g_value_init(&value, G_TYPE_STRING);
-       g_value_set_static_string(&value, advances[i].name);
+       g_value_set_static_string(&value,
+                                 get_tech_name(game.player_ptr, i));
        gtk_list_store_set_value(store, &it, 0, &value);
        g_value_unset(&value);
        gtk_list_store_set(store, &it, 1, i, -1);
Index: client/gui-gtk-2.0/diplodlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/diplodlg.c,v
retrieving revision 1.22.2.1
diff -u -r1.22.2.1 diplodlg.c
--- client/gui-gtk-2.0/diplodlg.c       14 Nov 2004 00:02:03 -0000      1.22.2.1
+++ client/gui-gtk-2.0/diplodlg.c       3 Dec 2004 19:45:33 -0000
@@ -241,7 +241,8 @@
          && (get_invention(plr1, i) == TECH_UNKNOWN
              || get_invention(plr1, i) == TECH_REACHABLE)
           && tech_is_available(plr1, i)) {
-       item = gtk_menu_item_new_with_label(advances[i].name);
+       item
+         = gtk_menu_item_new_with_label(get_tech_name(game.player_ptr, i));
 
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        g_signal_connect(item, "activate",
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/helpdlg.c,v
retrieving revision 1.35.2.4
diff -u -r1.35.2.4 helpdlg.c
--- client/gui-gtk-2.0/helpdlg.c        23 Nov 2004 21:20:21 -0000      1.35.2.4
+++ client/gui-gtk-2.0/helpdlg.c        3 Dec 2004 19:45:33 -0000
@@ -220,7 +220,7 @@
   help_advances[tech] = TRUE;
 
   g_value_init(&value, G_TYPE_STRING);
-  g_value_set_static_string(&value, advances[tech].name);
+  g_value_set_static_string(&value, get_tech_name(game.player_ptr, tech));
   gtk_tree_store_set_value(tstore, &l, 0, &value);
   g_value_unset(&value);
 
@@ -256,7 +256,7 @@
 
   gtk_tree_model_get_iter(GTK_TREE_MODEL(tstore), &it, path);
   gtk_tree_model_get(GTK_TREE_MODEL(tstore), &it, 2, &tech, -1);
-  select_help_item_string(advances[tech].name, HELP_TECH);
+  select_help_item_string(get_tech_name(game.player_ptr, tech), HELP_TECH);
 }
 
 /**************************************************************************
@@ -289,7 +289,8 @@
   /* May be able to skip, or may need to modify, advances[A_NONE].name
      below, depending on which i18n is done elsewhere.
   */
-  if (strcmp(s, _("(Never)")) != 0 && strcmp(s, _("None")) != 0
+  if (strcmp(s, _("(Never)")) != 0
+      && strcmp(s, _("None")) != 0
       && strcmp(s, advances[A_NONE].name) != 0)
     select_help_item_string(s, type);
 }
@@ -691,7 +692,8 @@
     if (imp->tech_req == A_LAST) {
       gtk_label_set_text(GTK_LABEL(help_ilabel[5]), _("(Never)"));
     } else {
-      gtk_label_set_text(GTK_LABEL(help_ilabel[5]), 
advances[imp->tech_req].name);
+      gtk_label_set_text(GTK_LABEL(help_ilabel[5]),
+                        get_tech_name(game.player_ptr, imp->tech_req));
     }
 /*    create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
   }
@@ -725,10 +727,12 @@
     if (imp->tech_req == A_LAST) {
       gtk_label_set_text(GTK_LABEL(help_wlabel[3]), _("(Never)"));
     } else {
-      gtk_label_set_text(GTK_LABEL(help_wlabel[3]), 
advances[imp->tech_req].name);
+      gtk_label_set_text(GTK_LABEL(help_wlabel[3]),
+                        get_tech_name(game.player_ptr, imp->tech_req));
     }
     if (tech_exists(imp->obsolete_by)) {
-      gtk_label_set_text(GTK_LABEL(help_wlabel[5]), 
advances[imp->obsolete_by].name);
+      gtk_label_set_text(GTK_LABEL(help_wlabel[5]),
+                        get_tech_name(game.player_ptr, imp->obsolete_by));
     } else {
       gtk_label_set_text(GTK_LABEL(help_wlabel[5]), _("(Never)"));
     }
@@ -778,7 +782,9 @@
     if(utype->tech_requirement==A_LAST) {
       gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), _("(Never)"));
     } else {
-      gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), 
advances[utype->tech_requirement].name);
+      gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
+                        get_tech_name(game.player_ptr,
+                                      utype->tech_requirement));
     }
 /*    create_tech_tree(help_improvement_tree, 0, utype->tech_requirement, 3);*/
     if(utype->obsoleted_by==-1) {
@@ -930,7 +936,7 @@
           gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
           w = gtk_label_new(_("Allows"));
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
-          w = help_slink_new(advances[j].name, HELP_TECH);
+          w = help_slink_new(get_tech_name(game.player_ptr, j), HELP_TECH);
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
           gtk_widget_show_all(hbox);
        }
@@ -939,11 +945,12 @@
           gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
           w = gtk_label_new(_("Allows"));
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
-          w = help_slink_new(advances[j].name, HELP_TECH);
+          w = help_slink_new(get_tech_name(game.player_ptr, j), HELP_TECH);
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
           w = gtk_label_new(_("with"));
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
-          w = help_slink_new(advances[advances[j].req[1]].name, HELP_TECH);
+          w = help_slink_new(get_tech_name(game.player_ptr,
+                                          advances[j].req[1]), HELP_TECH);
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
           w = gtk_label_new(Q_("?techhelp:"));
           gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
@@ -955,11 +962,12 @@
         gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
         w = gtk_label_new(_("Allows"));
         gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
-        w = help_slink_new(advances[j].name, HELP_TECH);
+        w = help_slink_new(get_tech_name(game.player_ptr, j), HELP_TECH);
         gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
         w = gtk_label_new(_("with"));
         gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
-        w = help_slink_new(advances[advances[j].req[0]].name, HELP_TECH);
+        w = help_slink_new(get_tech_name(game.player_ptr,
+                                        advances[j].req[0]), HELP_TECH);
         gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
         w = gtk_label_new(Q_("?techhelp:"));
         gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
Index: client/gui-gtk-2.0/inteldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/inteldlg.c,v
retrieving revision 1.16
diff -u -r1.16 inteldlg.c
--- client/gui-gtk-2.0/inteldlg.c       18 Sep 2004 21:12:06 -0000      1.16
+++ client/gui-gtk-2.0/inteldlg.c       3 Dec 2004 19:45:33 -0000
@@ -278,9 +278,9 @@
        gtk_list_store_append(intel_techs, &it);
 
        gtk_list_store_set(intel_techs, &it,
-           0, (get_invention(game.player_ptr, i)!=TECH_KNOWN),
-           1, advances[i].name,
-           -1);
+                          0, (get_invention(game.player_ptr, i)!=TECH_KNOWN),
+                          1, get_tech_name(p, i),
+                          -1);
       }
 
     /* table labels. */
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.60.2.9
diff -u -r1.60.2.9 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c       16 Nov 2004 18:05:38 -0000      1.60.2.9
+++ client/gui-gtk-2.0/repodlgs.c       3 Dec 2004 19:45:34 -0000
@@ -282,7 +282,7 @@
   size_t to = (size_t) data;
 
   if (GTK_TOGGLE_BUTTON(science_help_toggle)->active) {
-    popup_help_dialog_typed(advances[to].name, HELP_TECH);
+    popup_help_dialog_typed(get_tech_name(game.player_ptr, to), HELP_TECH);
     /* Following is to make the menu go back to the current research;
      * there may be a better way to do this?  --dwp */
     science_dialog_update();
@@ -317,7 +317,7 @@
   size_t to = (size_t) data;
 
   if (GTK_TOGGLE_BUTTON(science_help_toggle)->active) {
-    popup_help_dialog_typed(advances[to].name, HELP_TECH);
+    popup_help_dialog_typed(get_tech_name(game.player_ptr, to), HELP_TECH);
     /* Following is to make the menu go back to the current goal;
      * there may be a better way to do this?  --dwp */
     science_dialog_update();
@@ -365,8 +365,10 @@
   gchar text_a[512], text_b[512];
   gint a = GPOINTER_TO_INT(a_p), b = GPOINTER_TO_INT(b_p);
 
+  /* FIXME: future techs aren't counted this way but are handled by
+   * get_tech_name() when given a player parameter. */
   if (!is_future_tech(a)) {
-    a_str=advances[a].name;
+    a_str = get_tech_name(game.player_ptr, a);
   } else {
     my_snprintf(text_a,sizeof(text_a), _("Future Tech. %d"),
                a - game.num_tech_types);
@@ -374,7 +376,7 @@
   }
 
   if(!is_future_tech(b)) {
-    b_str=advances[b].name;
+    b_str = get_tech_name(game.player_ptr, b);
   } else {
     my_snprintf(text_b,sizeof(text_b), _("Future Tech. %d"),
                b - game.num_tech_types);
@@ -425,7 +427,7 @@
     gtk_list_store_append(science_model[i%ARRAY_SIZE(science_model)], &it);
 
     g_value_init(&value, G_TYPE_STRING);
-    g_value_set_static_string(&value, advances[j].name);
+    g_value_set_static_string(&value, get_tech_name(game.player_ptr, j));
     gtk_list_store_set_value(science_model[i%ARRAY_SIZE(science_model)], &it,
        0, &value);
     g_value_unset(&value);
@@ -454,7 +456,8 @@
   gtk_widget_queue_resize(science_current_label);
  
   if (game.player_ptr->research.researching == A_UNSET) {
-    item = gtk_menu_item_new_with_label(advances[A_NONE].name);
+    item = gtk_menu_item_new_with_label(get_tech_name(game.player_ptr,
+                                                     A_NONE));
     gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), item);
   }
 
@@ -485,7 +488,8 @@
 
     if (GPOINTER_TO_INT(g_list_nth_data(sorting_list, i)) <
        game.num_tech_types) {
-      data=advances[GPOINTER_TO_INT(g_list_nth_data(sorting_list, i))].name;
+      data = get_tech_name(game.player_ptr,
+                       GPOINTER_TO_INT(g_list_nth_data(sorting_list, i)));
     } else {
       my_snprintf(text, sizeof(text), _("Future Tech. %d"),
                  GPOINTER_TO_INT(g_list_nth_data(sorting_list, i))
@@ -521,7 +525,8 @@
   gtk_label_set_text(GTK_LABEL(science_goal_label), text);
 
   if (game.player_ptr->ai.tech_goal == A_UNSET) {
-    item = gtk_menu_item_new_with_label(advances[A_NONE].name);
+    item = gtk_menu_item_new_with_label(get_tech_name(game.player_ptr,
+                                                     A_NONE));
     gtk_menu_shell_append(GTK_MENU_SHELL(goalmenu), item);
   }
 
@@ -555,7 +560,7 @@
     hbox = gtk_hbox_new(FALSE, 18);
     gtk_container_add(GTK_CONTAINER(item), hbox);
 
-    label = gtk_label_new(advances[tech].name);
+    label = gtk_label_new(get_tech_name(game.player_ptr, tech));
     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
     gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
     gtk_size_group_add_widget(group1, label);
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.76
diff -u -r1.76 tech.c
--- common/tech.c       23 Sep 2004 20:48:08 -0000      1.76
+++ common/tech.c       3 Dec 2004 19:45:34 -0000
@@ -109,8 +109,9 @@
   BV_SET(pplayer->research.inventions[goal].required_techs, tech);
 
   if (advances[tech].req[0] == goal || advances[tech].req[1] == goal) {
+    /* TRANS: Obscure ruleset error */
     freelog(LOG_FATAL, _("tech \"%s\": requires itself"),
-           advances[goal].name);
+           get_tech_name(pplayer, goal));
     assert(0);
     exit(EXIT_FAILURE);
   }
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.87
diff -u -r1.87 diplhand.c
--- server/diplhand.c   29 Sep 2004 02:24:23 -0000      1.87
+++ server/diplhand.c   3 Dec 2004 19:45:34 -0000
@@ -135,22 +135,22 @@
             * can never possess it (the client should enforce this). */
            freelog(LOG_ERROR, "Treaty: The %s can't have tech %s",
                     get_nation_name_plural(pother->nation),
-                    advances[pclause->value].name);
+                   get_tech_name(pplayer, pclause->value));
            notify_player(pplayer,
                           _("Game: The %s can't accept %s."),
                           get_nation_name_plural(pother->nation),
-                          advances[pclause->value].name);
+                         get_tech_name(pplayer, pclause->value));
            return;
           }
          if (get_invention(pplayer, pclause->value) != TECH_KNOWN) {
            freelog(LOG_ERROR,
                     "The %s don't know tech %s, but try to give it to the %s.",
                    get_nation_name_plural(pplayer->nation),
-                   advances[pclause->value].name,
+                   get_tech_name(pplayer, pclause->value),
                    get_nation_name_plural(pother->nation));
            notify_player(pplayer,
                          _("Game: You don't have tech %s, you can't accept 
treaty."),
-                         advances[pclause->value].name);
+                         get_tech_name(pplayer, pclause->value));
            return;
          }
          break;
@@ -351,7 +351,7 @@
          freelog(LOG_VERBOSE,
                   "The %s already know tech %s, that %s want to give them.",
                  get_nation_name_plural(pdest->nation),
-                 advances[pclause->value].name,
+                 get_tech_name(pplayer, pclause->value),
                  get_nation_name_plural(pgiver->nation));
           break;
         }
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.61.2.2
diff -u -r1.61.2.2 diplomats.c
--- server/diplomats.c  19 Nov 2004 02:29:35 -0000      1.61.2.2
+++ server/diplomats.c  3 Dec 2004 19:45:35 -0000
@@ -629,8 +629,8 @@
        }
       }
     } tech_type_iterate_end;
-    freelog (LOG_DEBUG, "steal-tech: random: targeted technology: %d (%s)",
-            target, advances[target].name);
+    freelog(LOG_DEBUG, "steal-tech: random: targeted technology: %d (%s)",
+           target, get_tech_name(pplayer, target));
   } else {
     /*
      * Told which technology to steal:
@@ -639,18 +639,18 @@
     if ((get_invention (pplayer, technology) != TECH_KNOWN) &&
        (get_invention (cplayer, technology) == TECH_KNOWN)) {
        target = technology;
-       freelog (LOG_DEBUG, "steal-tech: specified target technology: %d (%s)",
-              target, advances[target].name);
+       freelog(LOG_DEBUG, "steal-tech: specified target technology: %d (%s)",
+               target, get_tech_name(pplayer, target));
     } else {
       notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
                       _("Game: Your %s could not find the %s technology"
                         " to steal in %s."),
                       unit_name(pdiplomat->type),
-                      advances[technology].name, pcity->name);
+                      get_tech_name(pplayer, technology), pcity->name);
       diplomat_charge_movement (pdiplomat, pcity->tile);
       send_unit_info (pplayer, pdiplomat);
-      freelog (LOG_DEBUG, "steal-tech: target technology not found: %d (%s)",
-              technology, advances[technology].name);
+      freelog(LOG_DEBUG, "steal-tech: target technology not found: %d (%s)",
+             technology, get_tech_name(pplayer, technology));
       return;
     }
   }
@@ -686,21 +686,22 @@
     notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_THEFT,
                     _("Game: Your %s stole %s from %s."),
                     unit_name(pdiplomat->type),
-                    advances[target].name, cplayer->name);
+                    get_tech_name(pplayer, target), cplayer->name);
     notify_player_ex(cplayer, pcity->tile, E_ENEMY_DIPLOMAT_THEFT,
                     _("Game: %s's %s stole %s from %s."),
                     pplayer->name, unit_name(pdiplomat->type),
-                    advances[target].name, pcity->name);
+                    get_tech_name(cplayer, target), pcity->name);
     notify_embassies(pplayer, cplayer,
                     _("Game: The %s have stolen %s from the %s."),
                     get_nation_name_plural(pplayer->nation),
-                    advances[target].name,
+                    get_tech_name(cplayer, target),
                     get_nation_name_plural(cplayer->nation));
     gamelog(GAMELOG_TECH, _("%s steals %s from the %s"),
-           get_nation_name_plural(pplayer->nation), advances[target].name,
+           get_nation_name_plural(pplayer->nation),
+           get_tech_name(cplayer, target),
            get_nation_name_plural(cplayer->nation));
-    freelog (LOG_DEBUG, "steal-tech: stole %s",
-            advances[target].name);
+    freelog(LOG_DEBUG, "steal-tech: stole %s",
+           get_tech_name(cplayer, target));
   }
 
   /* Update stealing player's science progress and research fields */
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.330.2.11
diff -u -r1.330.2.11 plrhand.c
--- server/plrhand.c    3 Dec 2004 19:01:08 -0000       1.330.2.11
+++ server/plrhand.c    3 Dec 2004 19:45:35 -0000
@@ -151,19 +151,15 @@
          && tech_is_available(pplayer, i)
          && game.global_advances[i] >= mod) {
        notify_player_ex(pplayer, NULL, E_TECH_GAIN,
-           _("Game: %s acquired from %s!"),
-           advances[i].name,
-           buf);
+                        _("Game: %s acquired from %s!"),
+                        get_tech_name(pplayer, i), buf);
        gamelog(GAMELOG_TECH, _("%s discover %s (%s)"),
-           get_nation_name_plural(pplayer->nation),
-           advances[i].name,
-           buf);
+               get_nation_name_plural(pplayer->nation),
+               get_tech_name(pplayer, i), buf);
        notify_embassies(pplayer, NULL,
-           _("Game: The %s have acquired %s"
-             " from %s."),
-           get_nation_name_plural(pplayer->nation),
-           advances[i].name,
-           buf);
+                        _("Game: The %s have acquired %s from %s."),
+                        get_nation_name_plural(pplayer->nation),
+                        get_tech_name(pplayer, i), buf);
 
        do_free_cost(pplayer);
        found_new_tech(pplayer, i, FALSE, TRUE, A_NONE);
@@ -296,7 +292,8 @@
 
   if (was_first) {
     gamelog(GAMELOG_TECH, _("%s are first to learn %s"),
-           get_nation_name_plural(plr->nation), advances[tech_found].name);
+           get_nation_name_plural(plr->nation),
+           get_tech_name(plr, tech_found));
     
     /* Alert the owners of any wonders that have been made obsolete */
     impr_type_iterate(id) {
@@ -305,7 +302,8 @@
          (pcity = find_city_by_id(game.global_wonders[id]))) {
        notify_player_ex(city_owner(pcity), NULL, E_WONDER_OBSOLETE,
                         _("Game: Discovery of %s OBSOLETES %s in %s!"), 
-                        advances[tech_found].name, get_improvement_name(id),
+                        get_tech_name(city_owner(pcity), tech_found),
+                        get_improvement_name(id),
                         pcity->name);
       }
     } impr_type_iterate_end;
@@ -316,7 +314,7 @@
       notify_player_ex(plr, NULL, E_NEW_GOVERNMENT,
                       _("Game: Discovery of %s makes the government form %s"
                         " available. You may want to start a revolution."),
-                      advances[tech_found].name, gov->name);
+                      get_tech_name(plr, tech_found), gov->name);
     }
   } government_iterate_end;
 
@@ -355,9 +353,9 @@
       notify_player_ex(plr, NULL, E_TECH_LEARNED,
                       _("Game: Learned %s.  "
                         "Our scientists focus on %s, goal is %s."),
-                      advances[tech_found].name,
-                      advances[plr->research.researching].name,
-                      advances[plr->ai.tech_goal].name);
+                      get_tech_name(plr, tech_found),
+                      get_tech_name(plr, plr->research.researching),
+                      get_tech_name(plr, plr->ai.tech_goal));
     } else {
       if (plr->ai.control || !was_discovery) {
         choose_random_tech(plr);
@@ -373,7 +371,7 @@
        notify_player_ex(plr, NULL, E_TECH_LEARNED,
                         _("Game: Learned %s.  Scientists "
                           "choose to research %s."),
-                        advances[tech_found].name,
+                        get_tech_name(plr, tech_found),
                         get_tech_name(plr, plr->research.researching));
       } else if (plr->research.researching != A_UNSET) {
        char buffer1[300];
@@ -390,7 +388,7 @@
        notify_player_ex(plr, NULL, E_TECH_LEARNED,
                         _("Game: Learned %s.  Scientists "
                           "do not know what to research next."),
-                        advances[tech_found].name);
+                        get_tech_name(plr, tech_found));
       }
     }
   } else if (tech_found == plr->research.researching && next_tech > A_NONE) {
@@ -468,13 +466,13 @@
         notify_player_ex(aplayer, NULL, E_TECH_LEARNED,
                          _("Game: Learned %s in cooperation with %s. "
                            "Scientists choose to research %s."),
-                         advances[tech_found].name, plr->name,
+                         get_tech_name(aplayer, tech_found), plr->name,
                          get_tech_name(plr, plr->research.researching));
       } else {
         notify_player_ex(aplayer, NULL, E_TECH_LEARNED,
                          _("Game: Learned %s in cooperation with %s. "
                            "Scientists do not know what to research next."),
-                         advances[tech_found].name, plr->name);
+                         get_tech_name(aplayer, tech_found), plr->name);
       }
       found_new_tech(aplayer, tech_found, was_discovery, saving_bulbs,
                      plr->research.researching);
@@ -503,11 +501,11 @@
     notify_embassies(plr, NULL,
                     _("Game: The %s have researched %s."), 
                     get_nation_name_plural(plr->nation),
-                    advances[plr->research.researching].name);
+                    get_tech_name(plr, plr->research.researching));
 
     gamelog(GAMELOG_TECH, _("%s discover %s"),
            get_nation_name_plural(plr->nation),
-           advances[plr->research.researching].name);
+           get_tech_name(plr, plr->research.researching));
   } else {
     notify_embassies(plr, NULL,
                     _("Game: The %s have researched Future Tech. %d."), 

[Prev in Thread] Current Thread [Next in Thread]