Feature #809 » 0013-Unhardcode-wld.map-from-can_unit_change_homecity_to.patch
client/gui-gtk-3.22/citydlg.c | ||
---|---|---|
G_CALLBACK(unit_homecity_callback),
|
||
GINT_TO_POINTER(punit->id));
|
||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
|
||
gtk_widget_set_sensitive(item, can_unit_change_homecity_to(punit, pcity));
|
||
gtk_widget_set_sensitive(item, can_unit_change_homecity_to(&(wld.map),
|
||
punit, pcity));
|
||
item = gtk_menu_item_new_with_mnemonic(_("U_pgrade unit"));
|
||
gtk_widget_set_sensitive(item, action_ever_possible(ACTION_UPGRADE_UNIT));
|
client/gui-gtk-3.22/menu.c | ||
---|---|---|
units_can_upgrade(&(wld.map), punits));
|
||
/* "UNIT_CONVERT" dealt with below */
|
||
menu_entry_set_sensitive("UNIT_HOMECITY",
|
||
can_units_do(punits, can_unit_change_homecity));
|
||
can_units_do_on_map(&(wld.map), punits, can_unit_change_homecity));
|
||
menu_entry_set_sensitive("UNIT_UNLOAD_TRANSPORTER",
|
||
units_are_occupied(punits));
|
||
menu_entry_set_sensitive("UNIT_BOARD",
|
client/gui-gtk-4.0/citydlg.c | ||
---|---|---|
g_signal_connect(act, "activate", G_CALLBACK(unit_homecity_callback),
|
||
GINT_TO_POINTER(punit->id));
|
||
g_simple_action_set_enabled(G_SIMPLE_ACTION(act),
|
||
can_unit_change_homecity_to(punit,
|
||
can_unit_change_homecity_to(&(wld.map), punit,
|
||
pdialog->pcity));
|
||
menu_item_append_unref(menu,
|
||
g_menu_item_new(action_id_name_translation(ACTION_HOME_CITY),
|
client/gui-gtk-4.0/menu.c | ||
---|---|---|
units_have_activity_on_tile(punits,
|
||
ACTIVITY_SENTRY));
|
||
menu_entry_set_sensitive(map, "UNIT_HOMECITY",
|
||
can_units_do(punits, can_unit_change_homecity));
|
||
can_units_do_on_map(&(wld.map), punits, can_unit_change_homecity));
|
||
menu_entry_set_sensitive(map, "UNIT_UPGRADE", units_can_upgrade(&(wld.map), punits));
|
||
menu_entry_set_sensitive(map, "UNIT_CONVERT", units_can_convert(&(wld.map), punits));
|
||
menu_entry_set_sensitive(map, "UNIT_DISBAND",
|
client/gui-qt/citydlg.cpp | ||
---|---|---|
disband_action = NULL;
|
||
}
|
||
if (can_unit_change_homecity(qunit)) {
|
||
if (can_unit_change_homecity(&(wld.map), qunit)) {
|
||
change_home = new QAction(action_id_name_translation(ACTION_HOME_CITY),
|
||
this);
|
||
connect(change_home, &QAction::triggered, this, &unit_item::change_homecity);
|
client/gui-qt/hudwidget.cpp | ||
---|---|---|
// Set homecity
|
||
if (tile_city(unit_tile(current_unit))) {
|
||
if (can_unit_change_homecity_to(current_unit,
|
||
if (can_unit_change_homecity_to(&(wld.map), current_unit,
|
||
tile_city(unit_tile(current_unit)))) {
|
||
a = new hud_action(this);
|
||
a->action_shortcut = SC_SETHOME;
|
client/gui-qt/menu.cpp | ||
---|---|---|
break;
|
||
case HOMECITY:
|
||
if (can_units_do(punits, can_unit_change_homecity)) {
|
||
if (can_units_do_on_map(&(wld.map), punits, can_unit_change_homecity)) {
|
||
i.value()->setEnabled(true);
|
||
}
|
||
break;
|
client/gui-sdl2/menu.c | ||
---|---|---|
local_hide(ID_UNIT_ORDER_PILLAGE);
|
||
}
|
||
if (pcity && can_unit_change_homecity(punit)
|
||
if (pcity != NULL && can_unit_change_homecity(&(wld.map), punit)
|
||
&& pcity->id != punit->homecity) {
|
||
local_show(ID_UNIT_ORDER_HOMECITY);
|
||
} else {
|
client/gui-sdl3/menu.c | ||
---|---|---|
local_hide(ID_UNIT_ORDER_PILLAGE);
|
||
}
|
||
if (pcity && can_unit_change_homecity(punit)
|
||
if (pcity != NULL && can_unit_change_homecity(&(wld.map), punit)
|
||
&& pcity->id != punit->homecity) {
|
||
local_show(ID_UNIT_ORDER_HOMECITY);
|
||
} else {
|
common/unit.c | ||
---|---|---|
/**********************************************************************//**
|
||
Return TRUE iff the unit can change homecity to the given city.
|
||
**************************************************************************/
|
||
bool can_unit_change_homecity_to(const struct unit *punit,
|
||
bool can_unit_change_homecity_to(const struct civ_map *nmap,
|
||
const struct unit *punit,
|
||
const struct city *pcity)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (pcity == NULL) {
|
||
/* Can't change home city to a non existing city. */
|
||
return FALSE;
|
||
... | ... | |
/**********************************************************************//**
|
||
Return TRUE iff the unit can change homecity at its current location.
|
||
**************************************************************************/
|
||
bool can_unit_change_homecity(const struct unit *punit)
|
||
bool can_unit_change_homecity(const struct civ_map *nmap,
|
||
const struct unit *punit)
|
||
{
|
||
return can_unit_change_homecity_to(punit, tile_city(unit_tile(punit)));
|
||
return can_unit_change_homecity_to(nmap, punit, tile_city(unit_tile(punit)));
|
||
}
|
||
/**********************************************************************//**
|
common/unit.h | ||
---|---|---|
const struct unit *ptrans);
|
||
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit);
|
||
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit);
|
||
bool can_unit_change_homecity_to(const struct unit *punit,
|
||
bool can_unit_change_homecity_to(const struct civ_map *nmap,
|
||
const struct unit *punit,
|
||
const struct city *pcity);
|
||
bool can_unit_change_homecity(const struct unit *punit);
|
||
bool can_unit_change_homecity(const struct civ_map *nmap,
|
||
const struct unit *punit);
|
||
const char *get_activity_text(enum unit_activity activity);
|
||
bool can_unit_continue_current_activity(const struct civ_map *nmap,
|
||
struct unit *punit);
|