Project

General

Profile

Bug #2496 » 0001-resolve_city_emergency-Disband-an-idle-boat-too-S3_3.patch

Sweet Tea Dorminy, 11/22/2026 03:09 AM

View differences:

ai/default/aiferry.c
&& (ferry_type->fuel == 0 || utype_has_flag(ferry_type, UTYF_COAST)));
}
/**********************************************************************//**
Does the boat carry units, or has a passenger booked it? The passenger
field alone cannot tell: it is negative, never 0, for a boat nobody
has booked.
**************************************************************************/
bool dai_ferry_in_use(struct ai_type *ait, struct unit *pferry)
{
return get_transporter_occupancy(pferry) > 0
|| def_ai_unit_data(pferry, ait)->passenger > 0;
}
/**********************************************************************//**
Check if unit is boss in ferry
**************************************************************************/
ai/default/aiferry.h
bool is_boat_free(struct ai_type *ait, struct unit *boat,
struct unit *punit, int cap);
bool is_boss_of_boat(struct ai_type *ait, struct unit *punit);
bool dai_ferry_in_use(struct ai_type *ait, struct unit *pferry);
/*
* Main boat managing function. Gets units on board to where they want to
ai/default/daicity.c
#include "handicaps.h"
/* ai/default */
#include "aiferry.h"
#include "aihand.h"
#include "daidata.h"
#include "daidiplomacy.h"
......
if (city_unhappy(pcity)
&& (utype_happy_cost(unit_type_get(punit), pplayer) > 0
&& (unit_being_aggressive(nmap, punit) || is_field_unit(punit)))
&& def_ai_unit_data(punit, ait)->passenger == 0) {
&& !dai_ferry_in_use(ait, punit)) {
UNIT_LOG(LOG_EMERGENCY, punit, "is causing unrest, disbanded");
/* TODO: If Help Wonder stops blocking Disband Unit there may be
* cases where Disband Unit should be selected. Example: Field unit
(2-2/3)