<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40359 >
2008/7/5 Marko Lindqvist: > > 2008/7/4 Marko Lindqvist: >> >> $subject. >> >> See forum thread about Dune modpack: >> http://forum.freeciv.org/viewtopic.php?t=4892 > > Fix S2_2 / TRUNK version - ML
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/wldlg.c freeciv/client/gui-gtk-2.0/wldlg.c --- freeciv/client/gui-gtk-2.0/wldlg.c 2008-04-25 15:54:36.000000000 +0300 +++ freeciv/client/gui-gtk-2.0/wldlg.c 2008-07-05 15:23:33.000000000 +0300 @@ -986,8 +986,11 @@ g_object_set(rend, "text", row[column], NULL); if (NULL != *pcity && VUT_IMPROVEMENT == target.kind) { - useless = improvement_obsolete(city_owner(*pcity), target.value.building) - || is_building_replaced(*pcity, target.value.building, RPT_CERTAIN); + struct player *plr = city_owner(*pcity); + + useless = improvement_obsolete(plr, target.value.building) + || (! impr_provides_buildable_units(plr, target.value.building) + && is_building_replaced(*pcity, target.value.building, RPT_CERTAIN)); /* Mark building redundant if we are really certain that there is * no use for it. */ g_object_set(rend, "strikethrough", useless, NULL); diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2008-07-03 21:58:06.000000000 +0300 +++ freeciv/client/packhand.c 2008-07-05 15:24:52.000000000 +0300 @@ -2666,7 +2666,15 @@ } improvement_iterate_end; } #endif - + + b->allows_units = FALSE; + unit_type_iterate(ut) { + if (ut->need_improvement == b) { + b->allows_units = TRUE; + break; + } + } unit_type_iterate_end; + tileset_setup_impr_type(tileset, b); } diff -Nurd -X.diff_ignore freeciv/common/improvement.c freeciv/common/improvement.c --- freeciv/common/improvement.c 2008-06-15 16:44:37.000000000 +0300 +++ freeciv/common/improvement.c 2008-07-05 15:15:14.000000000 +0300 @@ -365,6 +365,28 @@ } /************************************************************************** + Returns TRUE iff improvement provides units buildable by player +**************************************************************************/ +bool impr_provides_buildable_units(const struct player *pplayer, + const struct impr_type *pimprove) +{ + /* Fast check */ + if (! pimprove->allows_units) { + return FALSE; + } + + unit_type_iterate(ut) { + if (ut->need_improvement == pimprove) { + if (can_player_build_unit_now(pplayer, ut)) { + return TRUE; + } + } + } unit_type_iterate_end; + + return FALSE; +} + +/************************************************************************** Whether player can build given building somewhere, ignoring whether it is obsolete. **************************************************************************/ diff -Nurd -X.diff_ignore freeciv/common/improvement.h freeciv/common/improvement.h --- freeciv/common/improvement.h 2007-09-14 14:51:37.000000000 +0300 +++ freeciv/common/improvement.h 2008-07-05 15:08:24.000000000 +0300 @@ -68,6 +68,8 @@ char *helptext; char soundtag[MAX_LEN_NAME]; char soundtag_alt[MAX_LEN_NAME]; + + bool allows_units; /* Cache */ }; @@ -117,6 +119,8 @@ /* player related improvement functions */ bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove); +bool impr_provides_buildable_units(const struct player *pplayer, + const struct impr_type *pimprove); bool can_player_build_improvement_direct(const struct player *p, struct impr_type *pimprove); @@ -146,4 +150,3 @@ } \ } #endif /* FC__IMPROVEMENT_H */ - diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c --- freeciv/server/ruleset.c 2008-07-03 21:58:06.000000000 +0300 +++ freeciv/server/ruleset.c 2008-07-05 15:21:11.000000000 +0300 @@ -1503,6 +1503,14 @@ secfile_lookup_str_default(file, "-", "%s.sound_alt", sec[i])); b->helptext = lookup_helptext(file, sec[i]); + + b->allows_units = FALSE; + unit_type_iterate(ut) { + if (ut->need_improvement == b) { + b->allows_units = TRUE; + break; + } + } unit_type_iterate_end; } /* Some more consistency checking: */
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev