Project

General

Profile

Feature #677 » 0093-Unhardcode-wld.map-from-unit_being_aggressive.patch

main, S3_2 - Marko Lindqvist, 05/24/2024 03:58 AM

View differences:

ai/default/daicity.c
unit_list_iterate_safe(pcity->units_supported, punit) {
if (city_unhappy(pcity)
&& (utype_happy_cost(unit_type_get(punit), pplayer) > 0
&& (unit_being_aggressive(punit) || is_field_unit(punit)))
&& (unit_being_aggressive(nmap, punit) || is_field_unit(punit)))
&& def_ai_unit_data(punit, ait)->passenger == 0) {
UNIT_LOG(LOG_EMERGENCY, punit, "is causing unrest, disbanded");
/* TODO: if Help Wonder stops blocking Disband Unit there may be
/* TODO: If Help Wonder stops blocking Disband Unit there may be
* cases where Disband Unit should be selected. Example: Field unit
* in allied city that is building a wonder that makes the ally win
* without sharing the victory. */
common/city.c
const struct unit_type *ut;
struct player *plr;
int happy_cost;
const struct civ_map *nmap = &(wld.map);
if (!punit || !free_unhappy) {
if (punit == NULL || free_unhappy == NULL) {
return 0;
}
......
fc_assert_ret_val(0 <= *free_unhappy, 0);
if (!unit_being_aggressive(punit) && !is_field_unit(punit)) {
if (!unit_being_aggressive(nmap, punit) && !is_field_unit(punit)) {
return 0;
}
common/unit.c
- inside a city
- near friendly city and in extra that provides "no aggressive"
**************************************************************************/
bool unit_being_aggressive(const struct unit *punit)
bool unit_being_aggressive(const struct civ_map *nmap,
const struct unit *punit)
{
const struct tile *ptile = unit_tile(punit);
int max_friendliness_range;
const struct civ_map *nmap = &(wld.map);
if (!is_attack_unit(punit)) {
return FALSE;
common/unit.h
? is_plr_zoc_srv(unit_owner, ptile, zmap) : is_plr_zoc_client(unit_owner, ptile, zmap);
}
bool unit_being_aggressive(const struct unit *punit);
bool unit_being_aggressive(const struct civ_map *nmap,
const struct unit *punit);
bool unit_type_really_ignores_zoc(const struct unit_type *punittype);
bool is_build_activity(enum unit_activity activity);
(1-1/2)