Index: happiness.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/happiness.c,v retrieving revision 1.1 diff -u -r1.1 happiness.c --- happiness.c 2001/10/26 08:07:11 1.1 +++ happiness.c 2001/11/05 09:13:06 @@ -15,6 +15,7 @@ #endif #include +#include #include "city.h" #include "fcintl.h" @@ -285,38 +286,41 @@ int nleft = sizeof(buf); struct city *pcity = pdialog->pcity; struct government *g = get_gov_pcity(pcity); + int buildings[] = {B_TEMPLE, B_COLOSSEUM, B_COURTHOUSE, B_CATHEDRAL, -1}; + int building; my_snprintf(bptr, nleft, _("Buildings: ")); bptr = end_of_strn(bptr, &nleft); - if (city_got_building(pcity, B_TEMPLE)) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_TEMPLE)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); - } - if (city_got_building(pcity, B_COURTHOUSE) && g->corruption_level == 0) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_COURTHOUSE)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); - } - if (city_got_building(pcity, B_COLOSSEUM)) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_COLOSSEUM)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); + for (building = 0; buildings[building] >= 0; building++) { + if (city_got_building(pcity, buildings[building])) { + if (building == B_COURTHOUSE && g->corruption_level != 0) + continue; + faces++; + my_snprintf(bptr, nleft, get_improvement_name(buildings[building])); + bptr = end_of_strn(bptr, &nleft); + my_snprintf(bptr, nleft, _(". ")); + bptr = end_of_strn(bptr, &nleft); + } } + /* hack for eliminating gtk_set_line_wrap() -mck */ + /* This hack is a bitch, as the GTK interface uses a proportional font + * which will clearly not line out nicely with spaces. + * Nevertheless, supposing it works as designed, it should use the + * translated string, so here it is. The trailing spaces are obviously + * empirical and only reflect the original coding. + * TODO: change this to a method which does not suffer from font + * characteristics. + * -pjk + */ if (faces > 2) { - /* sizeof("Buildings: ") */ - my_snprintf(bptr, nleft, _("\n ")); + int length = strlen(_("Buildings: ")); + my_snprintf(bptr, nleft, "\n%*.*s ", length, length, ""); bptr = end_of_strn(bptr, &nleft); } - if (city_got_effect(pcity, B_CATHEDRAL)) { + + if ((!city_got_building(pcity, B_CATHEDRAL)) && city_got_effect(pcity, B_CATHEDRAL)) { faces++; my_snprintf(bptr, nleft, get_improvement_name(B_CATHEDRAL)); bptr = end_of_strn(bptr, &nleft); @@ -383,43 +387,34 @@ char buf[512], *bptr = buf; int nleft = sizeof(buf); struct city *pcity = pdialog->pcity; + int wonders[] = { B_HANGING, B_ORACLE, B_MICHELANGELO, B_BACH, + B_SHAKESPEARE, B_CURE, -1 + }; + int wonder; + int firsttime = 1; my_snprintf(bptr, nleft, _("Wonders: ")); bptr = end_of_strn(bptr, &nleft); - if (city_affected_by_wonder(pcity, B_HANGING)) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_HANGING)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); - } - if (city_affected_by_wonder(pcity, B_BACH)) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_BACH)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); - } - /* hack for eliminating gtk_set_line_wrap() -mck */ - if (faces > 1) { - /* sizeof("Wonders: ") */ - my_snprintf(bptr, nleft, _("\n ")); - bptr = end_of_strn(bptr, &nleft); - } - if (city_affected_by_wonder(pcity, B_SHAKESPEARE)) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_SHAKESPEARE)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); - } - if (city_affected_by_wonder(pcity, B_CURE)) { - faces++; - my_snprintf(bptr, nleft, get_improvement_name(B_CURE)); - bptr = end_of_strn(bptr, &nleft); - my_snprintf(bptr, nleft, _(". ")); - bptr = end_of_strn(bptr, &nleft); + for (wonder = 0; wonders[wonder] >= 0; wonder++) { + if (city_affected_by_wonder(pcity, wonders[wonder])) { + /* Special case for Oracle, as it only enhances the effect of a temple -pjk */ + if (wonder == B_ORACLE && !city_got_building(pcity, B_TEMPLE)) + continue; + faces++; + my_snprintf(bptr, nleft, get_improvement_name(wonders[wonder])); + bptr = end_of_strn(bptr, &nleft); + my_snprintf(bptr, nleft, _(". ")); + bptr = end_of_strn(bptr, &nleft); + /* hack for eliminating gtk_set_line_wrap() -mck */ + /* See comment in happiness_dialog_update_buildings() -pjk */ + if (firsttime && faces > 1) { + int length = strlen(_("Wonders: ")); + my_snprintf(bptr, nleft, "\n%*.*s ", length, length, ""); + bptr = end_of_strn(bptr, &nleft); + firsttime = 0; + } + } } if (faces == 0) {