Project

General

Profile

Bug #209 » 0017-Unhardcode-wld.map-from-can_unit_paradrop.patch

S3_1 - Marko Lindqvist, 01/30/2024 08:23 PM

View differences:

ai/default/aiparatrooper.c
{
struct city *pcity = tile_city(unit_tile(punit));
struct tile *ptile_dest = NULL;
const struct civ_map *nmap = &(wld.map);
int sanity = punit->id;
/* defend attacking (and be opportunistic too) */
/* Defend attacking (and be opportunistic too) */
if (!dai_military_rampage(punit, RAMPAGE_ANYTHING,
RAMPAGE_FREE_CITY_OR_BETTER)) {
/* dead */
/* Dead */
return;
}
/* check to recover hit points */
/* Check to recover hit points */
if ((punit->hp < unit_type_get(punit)->hp / 2) && pcity) {
UNIT_LOG(LOGLEVEL_PARATROOPER, punit, "Recovering hit points.");
return;
}
/* nothing to do! */
/* Nothing to do! */
if (punit->moves_left == 0) {
return;
}
......
return;
}
if (can_unit_paradrop(punit)) {
if (can_unit_paradrop(nmap, punit)) {
ptile_dest = find_best_tile_to_paradrop_to(ait, punit);
if (ptile_dest) {
......
}
}
} else {
/* we can't paradrop :-( */
/* We can't paradrop :-( */
struct city *acity = NULL;
/* we are in a city, so don't try to find another */
/* We are in a city, so don't try to find another */
if (pcity) {
UNIT_LOG(LOGLEVEL_PARATROOPER, punit,
"waiting in a city for next turn.");
return;
}
/* find a city to go to recover and paradrop from */
/* Find a city to go to recover and paradrop from */
acity = find_nearest_safe_city(punit);
if (acity) {
client/control.c
return;
}
unit_list_iterate(punits, punit) {
if (can_unit_paradrop(punit)) {
if (can_unit_paradrop(&(wld.map), punit)) {
can = TRUE;
break;
}
client/gui-gtk-3.0/menu.c
menu_entry_set_sensitive("UNIT_SENTRY",
can_units_do_activity_client(punits, ACTIVITY_SENTRY));
menu_entry_set_sensitive("DO_PARADROP",
can_units_do(punits, can_unit_paradrop));
can_units_do_on_map(&(wld.map), punits, can_unit_paradrop));
/* FIXME: should conditionally rename "Pillage" to "Pillage..." in cases where
* selecting the command results in a dialog box listing options of what to pillage */
menu_entry_set_sensitive("DO_PILLAGE",
client/gui-gtk-3.22/menu.c
menu_entry_set_sensitive("UNIT_SENTRY",
can_units_do_activity_client(punits, ACTIVITY_SENTRY));
menu_entry_set_sensitive("DO_PARADROP",
can_units_do(punits, can_unit_paradrop));
can_units_do_on_map(&(wld.map), punits, can_unit_paradrop));
/* FIXME: should conditionally rename "Pillage" to "Pillage..." in cases where
* selecting the command results in a dialog box listing options of what to pillage */
menu_entry_set_sensitive("DO_PILLAGE",
client/gui-gtk-4.0/menu.c
can_units_do_activity_client(punits,
ACTIVITY_FORTIFYING));
menu_entry_set_sensitive(map, "PARADROP",
can_units_do(punits, can_unit_paradrop));
can_units_do_on_map(&(wld.map), punits, can_unit_paradrop));
menu_entry_set_sensitive(map, "PILLAGE",
can_units_do_activity_client(punits, ACTIVITY_PILLAGE));
menu_entry_set_sensitive(map, "CLEAN",
client/gui-qt/hudwidget.cpp
}
// Paradrop
if (can_unit_paradrop(current_unit)) {
if (can_unit_paradrop(&(wld.map), current_unit)) {
a = new hud_action(this);
a->action_shortcut = SC_PARADROP;
a->set_pixmap(fc_icons::instance()->get_pixmap("paradrop"));
client/gui-qt/menu.cpp
case POLLUTION:
if (can_units_do_activity_client(punits, ACTIVITY_POLLUTION)
|| can_units_do(punits, can_unit_paradrop)) {
|| can_units_do_on_map(&(wld.map), punits, can_unit_paradrop)) {
i.value()->setEnabled(true);
}
if (units_can_do_action_with_result(punits, ACTRES_PARADROP,
......
unit_owner(punit), punit);
if (pextra != NULL) {
request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra);
} else if (can_unit_paradrop(punit)) {
} else if (can_unit_paradrop(&(wld.map), punit)) {
/* FIXME: This is getting worse, we use a key_unit_*() function
* which assign the order for all units! Very bad! */
* which assign the order for all units! Very bad! */
key_unit_paradrop();
}
} unit_list_iterate_end;
client/gui-sdl2/dialogs.c
#endif /* 0 */
/* FIXME: This logic seems to try to mirror do_paradrop() why? */
if (can_unit_paradrop(focus_unit) && client_tile_get_known(ptile)
if (can_unit_paradrop(&(wld.map), focus_unit) && client_tile_get_known(ptile)
&& !(((pcity && pplayers_non_attack(client.conn.playing, city_owner(pcity)))
|| is_non_attack_unit_tile(ptile, client.conn.playing)))
&& (unit_type_get(focus_unit)->paratroopers_range >=
client/gui-sdl2/menu.c
set_wflag(order_pollution_button, WF_HIDDEN);
}
if (can_unit_paradrop(punit)) {
if (can_unit_paradrop(&(wld.map), punit)) {
local_show(ID_UNIT_ORDER_PARADROP);
} else {
local_hide(ID_UNIT_ORDER_PARADROP);
common/unit.c
a friendly city or on an airbase special, has enough movepoints left, and
has not paradropped yet this turn.
**************************************************************************/
bool can_unit_paradrop(const struct unit *punit)
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
{
const struct civ_map *nmap = &(wld.map);
action_by_result_iterate(paction, ACTRES_PARADROP) {
if (action_maybe_possible_actor_unit(nmap, paction->id, punit)) {
return TRUE;
common/unit.h
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans);
bool can_unit_alight_or_be_unloaded(const struct unit *pcargo,
const struct unit *ptrans);
bool can_unit_paradrop(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,
const struct city *pcity);
const struct city *pcity);
bool can_unit_change_homecity(const struct unit *punit);
const char *get_activity_text(enum unit_activity activity);
bool can_unit_continue_current_activity(struct civ_map *nmap,
common/unitlist.c
return FALSE;
}
/************************************************************************//**
Return TRUE if the function returns true for any of the units,
on specific map.
****************************************************************************/
bool can_units_do_on_map(const struct civ_map *nmap,
const struct unit_list *punits,
bool (can_fn)(const struct civ_map *nmap,
const struct unit *punit))
{
unit_list_iterate(punits, punit) {
if (can_fn(nmap, punit)) {
return TRUE;
}
} unit_list_iterate_end;
return FALSE;
}
/************************************************************************//**
Returns TRUE if any of the units can do the activity.
****************************************************************************/
common/unitlist.h
void unit_list_sort_ord_city(struct unit_list *punitlist);
bool can_units_do(const struct unit_list *punits,
bool (can_fn)(const struct unit *punit));
bool (can_fn)(const struct unit *punit));
bool can_units_do_on_map(const struct civ_map *nmap,
const struct unit_list *punits,
bool (can_fn)(const struct civ_map *nmap,
const struct unit *punit));
bool can_units_do_activity(const struct civ_map *nmap,
const struct unit_list *punits,
enum unit_activity activity);
......
}
#endif /* __cplusplus */
#endif /* FC__UNITLIST_H */
#endif /* FC__UNITLIST_H */
(3-3/3)