Feature #1313 ยป 0029-Make-Upkeep_Factor-to-consider-individual-unit-s-pro.patch
ai/default/daiair.c | ||
---|---|---|
continue;
|
||
}
|
||
if (!allow_gold_upkeep && utype_upkeep_cost(punittype, pplayer, O_GOLD) > 0) {
|
||
if (!allow_gold_upkeep
|
||
&& utype_upkeep_cost(punittype, nullptr, pplayer, O_GOLD) > 0) {
|
||
continue;
|
||
}
|
||
ai/default/daicity.c | ||
---|---|---|
**************************************************************************/
|
||
static int unit_food_upkeep(struct unit *punit)
|
||
{
|
||
struct player *pplayer = unit_owner(punit);
|
||
int upkeep = utype_upkeep_cost(unit_type_get(punit), pplayer, O_FOOD);
|
||
int upkeep = unit_upkeep_cost(punit, O_FOOD);
|
||
if (punit->id != 0 && punit->homecity == 0)
|
||
upkeep = 0; /* thanks, Peter */
|
||
if (punit->id != 0 && punit->homecity == 0) {
|
||
upkeep = 0; /* Thanks, Peter */
|
||
}
|
||
return upkeep;
|
||
}
|
ai/default/daidomestic.c | ||
---|---|---|
}
|
||
if (worker_type != NULL
|
||
&& pcity->surplus[O_FOOD] > utype_upkeep_cost(worker_type,
|
||
&& pcity->surplus[O_FOOD] > utype_upkeep_cost(worker_type, nullptr,
|
||
pplayer, O_FOOD)) {
|
||
if (worker_want > 0) {
|
||
CITY_LOG(LOG_DEBUG, pcity,
|
||
... | ... | |
/ TRAIT_DEFAULT_VALUE;
|
||
if (founder_type
|
||
&& pcity->surplus[O_FOOD] >= utype_upkeep_cost(founder_type,
|
||
&& pcity->surplus[O_FOOD] >= utype_upkeep_cost(founder_type, nullptr,
|
||
pplayer, O_FOOD)) {
|
||
if (founder_want > choice->want) {
|
ai/default/daihunter.c | ||
---|---|---|
struct unit_type_ai *utai = utype_ai_data(ut, ait);
|
||
int desire;
|
||
if (!allow_gold_upkeep && utype_upkeep_cost(ut, pplayer, O_GOLD) > 0) {
|
||
if (!allow_gold_upkeep && utype_upkeep_cost(ut, nullptr,
|
||
pplayer, O_GOLD) > 0) {
|
||
continue;
|
||
}
|
||
ai/default/daimilitary.c | ||
---|---|---|
struct player *pplayer = city_owner(pcity);
|
||
simple_ai_unit_type_iterate(putype) {
|
||
if (!allow_gold_upkeep && utype_upkeep_cost(putype, pplayer, O_GOLD) > 0) {
|
||
if (!allow_gold_upkeep
|
||
&& utype_upkeep_cost(putype, nullptr, pplayer, O_GOLD) > 0) {
|
||
continue;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
if (!allow_gold_upkeep && utype_upkeep_cost(putype, pplayer, O_GOLD) > 0) {
|
||
if (!allow_gold_upkeep
|
||
&& utype_upkeep_cost(putype, nullptr, pplayer, O_GOLD) > 0) {
|
||
continue;
|
||
}
|
||
ai/default/daiparadrop.c | ||
---|---|---|
continue;
|
||
}
|
||
if (!allow_gold_upkeep && utype_upkeep_cost(u_type, pplayer, O_GOLD) > 0) {
|
||
if (!allow_gold_upkeep
|
||
&& utype_upkeep_cost(u_type, nullptr, pplayer, O_GOLD) > 0) {
|
||
continue;
|
||
}
|
||
client/repodlgs_common.c | ||
---|---|---|
}
|
||
unit_type_iterate(unittype) {
|
||
cost = utype_upkeep_cost(unittype, client.conn.playing, O_GOLD);
|
||
cost = utype_upkeep_cost(unittype, nullptr, client_player(), O_GOLD);
|
||
if (cost == 0) {
|
||
/* Short-circuit all of the following checks. */
|
common/unit.c | ||
---|---|---|
return act_act[act];
|
||
}
|
||
/**********************************************************************//**
|
||
Get the upkeep of a unit.
|
||
@param punit Unit to get upkeep for
|
||
@param otype What kind of upkeep we are interested about
|
||
@return Upkeep of the specified type
|
||
**************************************************************************/
|
||
int unit_upkeep_cost(const struct unit *punit, Output_type_id otype)
|
||
{
|
||
return utype_upkeep_cost(unit_type_get(punit), punit, unit_owner(punit),
|
||
otype);
|
||
}
|
common/unit.h | ||
---|---|---|
int stack_bribe_cost(const struct tile *ptile, const struct player *briber,
|
||
const struct unit *briber_unit);
|
||
int unit_upkeep_cost(const struct unit *punit, Output_type_id otype);
|
||
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
|
||
bool force);
|
||
bool unit_transport_unload(struct unit *pcargo);
|
common/unittype.c | ||
---|---|---|
/**********************************************************************//**
|
||
Returns the upkeep of a unit of this type.
|
||
**************************************************************************/
|
||
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer,
|
||
int utype_upkeep_cost(const struct unit_type *ut, const struct unit *punit,
|
||
struct player *pplayer,
|
||
Output_type_id otype)
|
||
{
|
||
int val = ut->upkeep[otype], gold_upkeep_factor;
|
||
struct tile *ptile;
|
||
struct city *pcity;
|
||
if (punit != nullptr) {
|
||
ptile = unit_tile(punit);
|
||
pcity = game_city_by_number(punit->homecity);
|
||
} else {
|
||
ptile = nullptr;
|
||
pcity = nullptr;
|
||
}
|
||
if (BV_ISSET(ut->flags, UTYF_FANATIC)
|
||
&& get_player_bonus(pplayer, EFT_FANATICS) > 0) {
|
||
... | ... | |
&(const struct req_context) {
|
||
.player = pplayer,
|
||
.output = get_output_type(otype),
|
||
.unittype = ut
|
||
.unittype = ut,
|
||
.unit = punit,
|
||
.tile = ptile,
|
||
.city = pcity
|
||
},
|
||
NULL, EFT_UPKEEP_FACTOR);
|
||
common/unittype.h | ||
---|---|---|
enum unit_move_type utype_move_type(const struct unit_type *punittype);
|
||
void set_unit_move_type(struct unit_class *puclass);
|
||
/* player related unit functions */
|
||
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer,
|
||
/* Player related unit functions */
|
||
int utype_upkeep_cost(const struct unit_type *ut, const struct unit *punit,
|
||
struct player *pplayer,
|
||
Output_type_id otype);
|
||
int utype_happy_cost(const struct unit_type *ut, const struct player *pplayer);
|
||
server/citytools.c | ||
---|---|---|
****************************************************************************/
|
||
void update_unit_upkeep(struct unit *punit, int free_uk[O_LAST])
|
||
{
|
||
const struct unit_type *ut = unit_type_get(punit);
|
||
struct player *plr = unit_owner(punit);
|
||
bool update = FALSE;
|
||
int cost;
|
||
output_type_iterate(o) {
|
||
cost = utype_upkeep_cost(ut, plr, o);
|
||
cost = unit_upkeep_cost(punit, o);
|
||
if (cost > 0) {
|
||
if (free_uk[o] > cost) {
|
||
free_uk[o] -= cost;
|
server/cityturn.c | ||
---|---|---|
if (pcity->surplus[O_SHIELD] < 0) {
|
||
unit_list_iterate_safe(pcity->units_supported, punit) {
|
||
if (utype_upkeep_cost(unit_type_get(punit), pplayer, O_SHIELD) > 0
|
||
if (unit_upkeep_cost(punit, O_SHIELD) > 0
|
||
&& pcity->surplus[O_SHIELD] < 0) {
|
||
const char *punit_link = unit_link(punit);
|
||
... | ... | |
* it! If we make it here all normal units are already disbanded, so only
|
||
* undisbandable ones remain. */
|
||
unit_list_iterate_safe(pcity->units_supported, punit) {
|
||
int upkeep = utype_upkeep_cost(unit_type_get(punit), pplayer, O_SHIELD);
|
||
int upkeep = unit_upkeep_cost(punit, O_SHIELD);
|
||
if (upkeep > 0 && pcity->surplus[O_SHIELD] < 0) {
|
||
server/plrhand.c | ||
---|---|---|
&& game.info.homeless_gold_upkeep) {
|
||
unit_list_iterate(pplayer->units, punit) {
|
||
if (is_unit_homeless(punit)) {
|
||
int gold = utype_upkeep_cost(unit_type_get(punit), pplayer, O_GOLD);
|
||
int gold = unit_upkeep_cost(punit, O_GOLD);
|
||
punit->upkeep[O_GOLD] = gold;
|
||
punit->server.upkeep_paid[O_GOLD] = gold;
|
server/savegame/savegame2.c | ||
---|---|---|
* otherwise these don't get initialized (and AI calculations
|
||
* etc may use junk values). */
|
||
output_type_iterate(o) {
|
||
punit->upkeep[o] = utype_upkeep_cost(unit_type_get(punit), plr, o);
|
||
punit->upkeep[o] = unit_upkeep_cost(punit, o);
|
||
} output_type_iterate_end;
|
||
punit->action_decision_want
|
server/savegame/savegame3.c | ||
---|---|---|
* otherwise these don't get initialized (and AI calculations
|
||
* etc may use junk values). */
|
||
output_type_iterate(o) {
|
||
punit->upkeep[o] = utype_upkeep_cost(unit_type_get(punit), plr, o);
|
||
punit->upkeep[o] = unit_upkeep_cost(punit, o);
|
||
} output_type_iterate_end;
|
||
sg_warn_ret_val(secfile_lookup_int(loading->file, &unconverted,
|