diff -u -r freeciv-orig/client/gui-gtk/citydlg.c freeciv-mod/client/gui-gtk/citydlg.c --- freeciv-orig/client/gui-gtk/citydlg.c Sun Jan 2 12:55:24 2000 +++ freeciv-mod/client/gui-gtk/citydlg.c Thu Jan 13 00:24:58 2000 @@ -936,14 +936,19 @@ void city_dialog_update_building(struct city_dialog *pdialog) { char buf[32], buf2[64]; + int turns; struct city *pcity=pdialog->pcity; gtk_widget_set_sensitive(pdialog->buy_command, !pcity->did_buy); gtk_widget_set_sensitive(pdialog->sell_command, !pcity->did_sell); if(pcity->is_building_unit) { - my_snprintf(buf, sizeof(buf), "%3d/%3d", pcity->shield_stock, - get_unit_type(pcity->currently_building)->build_cost); + turns = city_turns_to_build (pcity, pcity->currently_building, TRUE); + my_snprintf(buf, sizeof(buf), "%3d/%3d %3d", pcity->shield_stock, + get_unit_type(pcity->currently_building)->build_cost, + turns); + + sz_strlcat (buf, turns == 1 ? _(" turn left") : _(" turns left")); sz_strlcpy(buf2, get_unit_type(pcity->currently_building)->name); } else { if(pcity->currently_building==B_CAPITAL) { @@ -951,8 +956,11 @@ my_snprintf(buf, sizeof(buf), "%3d/XXX", pcity->shield_stock); gtk_widget_set_sensitive(pdialog->buy_command, FALSE); } else { - my_snprintf(buf, sizeof(buf), "%3d/%3d", pcity->shield_stock, - get_improvement_type(pcity->currently_building)->build_cost); + turns = city_turns_to_build (pcity, pcity->currently_building, FALSE); + my_snprintf(buf, sizeof(buf), "%3d/%3d %3d", pcity->shield_stock, + get_improvement_type(pcity->currently_building)->build_cost, + turns); + sz_strlcat (buf, turns == 1 ? _(" turn left") : _(" turns left")); } sz_strlcpy(buf2, get_imp_name_ex(pcity, pcity->currently_building)); } @@ -1642,7 +1650,7 @@ { GtkWidget *cshell, *button, *scrolled; struct city_dialog *pdialog; - int i, n; + int i, n, turns; static gchar *title_[1] = { N_("Select new production") }; static gchar **title = NULL; GtkAccelGroup *accel=gtk_accel_group_new(); @@ -1698,11 +1706,21 @@ for(i=0, n=0; ipcity, i)) { - my_snprintf(pdialog->change_list_names[n], - sizeof(pdialog->change_list_names[n]), "%s (%d)", - get_imp_name_ex(pdialog->pcity, i), - get_improvement_type(i)->build_cost); - + if (i==B_CAPITAL) { /* Turns left makes no sense when building captialization */ + my_snprintf(pdialog->change_list_names[n], + sizeof(pdialog->change_list_names[n]), "%s (%d)", + get_imp_name_ex(pdialog->pcity, i), + get_improvement_type(i)->build_cost); + } else { + turns = city_turns_to_build (pdialog->pcity, i, FALSE); + my_snprintf(pdialog->change_list_names[n], + sizeof(pdialog->change_list_names[n]), "%s (%d) %3d", + get_imp_name_ex(pdialog->pcity, i), + get_improvement_type(i)->build_cost, + turns); + + sz_strlcat ( pdialog->change_list_names[n], turns == 1 ? _(" turn") : _(" turns")); + } pdialog->change_list_names_ptrs[n]=pdialog->change_list_names[n]; pdialog->change_list_ids[n++]=i; } @@ -1712,9 +1730,12 @@ for(i=0; ipcity, i)) { + turns = city_turns_to_build (pdialog->pcity, i, TRUE); my_snprintf(pdialog->change_list_names[n], - sizeof(pdialog->change_list_names[n]), "%s (%d)", - get_unit_name(i), get_unit_type(i)->build_cost); + sizeof(pdialog->change_list_names[n]), "%s (%d) %3d", + get_unit_name(i), get_unit_type(i)->build_cost, turns); + + sz_strlcat ( pdialog->change_list_names[n], turns == 1 ? _(" turn") : _(" turns")); pdialog->change_list_names_ptrs[n]=pdialog->change_list_names[n]; pdialog->change_list_ids[n++]=i; diff -u -r freeciv-orig/common/city.c freeciv-mod/common/city.c --- freeciv-orig/common/city.c Wed Jan 5 18:39:53 2000 +++ freeciv-mod/common/city.c Thu Jan 13 00:24:38 2000 @@ -1130,3 +1130,34 @@ else return -1; } + +/************************************************************************** + Calculates the turns which are needed to build the requested + type in the city. GUI Independend +**************************************************************************/ +int city_turns_to_build(struct city *pcity, int id, int id_is_unit) +{ + if (pcity->shield_surplus > 0) + { + int rounds, cost; + int shield_stock = pcity->shield_stock; + + if (id_is_unit) + { + if (!pcity->is_building_unit) + shield_stock /= 2; + cost = get_unit_type(id)->build_cost; + } + else + { + if (pcity->is_building_unit || (is_wonder(pcity->currently_building) != is_wonder(id))) + shield_stock /= 2; + cost = get_improvement_type(id)->build_cost; + } + + rounds = (cost - shield_stock + pcity->shield_surplus - 1) / pcity->shield_surplus; + + return (rounds > 0) ? rounds : 1; + } + return 999; +} diff -u -r freeciv-orig/common/city.h freeciv-mod/common/city.h --- freeciv-orig/common/city.h Mon Dec 27 15:42:10 1999 +++ freeciv-mod/common/city.h Thu Jan 13 00:24:38 2000 @@ -263,7 +263,7 @@ int city_got_effect(struct city *pcity, enum improvement_type_id id); int city_got_citywalls(struct city *pcity); int wonder_replacement(struct city *pcity, enum improvement_type_id id); - +int city_turns_to_build(struct city *pcity, int id, int id_is_unit); /* textual representation of buildings */ char *get_improvement_name(enum improvement_type_id id);