Project

General

Profile

Feature #799 » 0019-Unhardcode-wld.map-from-unit_can_add_or_build_city.patch

main - Marko Lindqvist, 08/22/2024 09:52 PM

View differences:

client/gui-gtk-3.22/menu.c
* not good! */
/* Enable the button for adding to a city in all cases, so we
get an eventual error message from the server if we try. */
if (unit_can_add_or_build_city(punit)) {
if (unit_can_add_or_build_city(&(wld.map), punit)) {
request_unit_build_city(punit);
} else if (utype_can_do_action(unit_type_get(punit),
ACTION_HELP_WONDER)) {
......
/* Enable the button for adding to a city in all cases, so we
* get an eventual error message from the server if we try. */
menu_entry_set_sensitive("BUILD_CITY",
(can_units_do(punits, unit_can_add_or_build_city)
(can_units_do_on_map(&(wld.map), punits,
unit_can_add_or_build_city)
|| can_units_do_on_map(&(wld.map), punits, unit_can_help_build_wonder_here)));
menu_entry_set_sensitive("BUILD_ROAD",
(can_units_do_any_road(&(wld.map), punits)
client/gui-gtk-4.0/menu.c
* not good! */
/* Enable the button for adding to a city in all cases, so we
get an eventual error message from the server if we try. */
if (unit_can_add_or_build_city(punit)) {
if (unit_can_add_or_build_city(&(wld.map), punit)) {
request_unit_build_city(punit);
} else if (utype_can_do_action(unit_type_get(punit),
ACTION_HELP_WONDER)) {
......
/* Enable the button for adding to a city in all cases, so we
* get an eventual error message from the server if we try. */
menu_entry_set_sensitive(map, "BUILD_CITY",
(can_units_do(punits, unit_can_add_or_build_city)
(can_units_do_on_map(&(wld.map), punits,
unit_can_add_or_build_city)
|| can_units_do_on_map(&(wld.map), punits,
unit_can_help_build_wonder_here)));
client/gui-gtk-5.0/menu.c
* not good! */
/* Enable the button for adding to a city in all cases, so we
get an eventual error message from the server if we try. */
if (unit_can_add_or_build_city(punit)) {
if (unit_can_add_or_build_city(&(wld.map), punit)) {
request_unit_build_city(punit);
} else if (utype_can_do_action(unit_type_get(punit),
ACTION_HELP_WONDER)) {
......
/* Enable the button for adding to a city in all cases, so we
* get an eventual error message from the server if we try. */
menu_entry_set_sensitive(map, "BUILD_CITY",
(can_units_do(punits, unit_can_add_or_build_city)
(can_units_do_on_map(&(wld.map), punits,
unit_can_add_or_build_city)
|| can_units_do_on_map(&(wld.map), punits,
unit_can_help_build_wonder_here)));
client/gui-qt/hudwidget.cpp
// Create possible actions
if (unit_can_add_or_build_city(current_unit)) {
if (unit_can_add_or_build_city(&(wld.map), current_unit)) {
a = new hud_action(this);
a->action_shortcut = SC_BUILDCITY;
a->set_pixmap(fc_icons::instance()->get_pixmap("home"));
client/gui-qt/menu.cpp
break;
case BUILD:
if (can_units_do(punits, unit_can_add_or_build_city)) {
if (can_units_do_on_map(&(wld.map), punits,
unit_can_add_or_build_city)) {
i.value()->setEnabled(true);
}
if (city_on_tile
......
* not good! */
/* Enable the button for adding to a city in all cases, so we
get an eventual error message from the server if we try. */
if (unit_can_add_or_build_city(punit)) {
if (unit_can_add_or_build_city(&(wld.map), punit)) {
request_unit_build_city(punit);
} else if (utype_can_do_action(unit_type_get(punit), ACTION_HELP_WONDER)) {
request_unit_caravan_action(punit, ACTION_HELP_WONDER);
client/gui-sdl2/menu.c
/* Enable the button for adding to a city in all cases, so we
* get an eventual error message from the server if we try. */
if (unit_can_add_or_build_city(punit)) {
if (pcity) {
if (unit_can_add_or_build_city(&(wld.map), punit)) {
if (pcity != NULL) {
fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
action_id_name_translation(ACTION_JOIN_CITY), "B");
} else {
client/gui-sdl3/menu.c
/* Enable the button for adding to a city in all cases, so we
* get an eventual error message from the server if we try. */
if (unit_can_add_or_build_city(punit)) {
if (pcity) {
if (unit_can_add_or_build_city(&(wld.map), punit)) {
if (pcity != NULL) {
fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)",
action_id_name_translation(ACTION_JOIN_CITY), "B");
} else {
common/unit.c
Return TRUE iff this unit can add to a current city or build a new city
at its current location.
**************************************************************************/
bool unit_can_add_or_build_city(const struct unit *punit)
bool unit_can_add_or_build_city(const struct civ_map *nmap,
const struct unit *punit)
{
struct city *tgt_city;
const struct civ_map *nmap = &(wld.map);
if ((tgt_city = tile_city(unit_tile(punit)))) {
return action_prob_possible(action_prob_vs_city(nmap, punit,
common/unit.h
const struct tile *ptile, bool omniscient);
bool is_field_unit(const struct unit *punit);
bool is_hiding_unit(const struct unit *punit);
bool unit_can_add_or_build_city(const struct unit *punit);
bool unit_can_add_or_build_city(const struct civ_map *nmap,
const struct unit *punit);
struct astring; /* Forward declaration. */
(1-1/3)