Feature #2488 ยป 0071-daitech.c-Replace-NULL-with-nullptr.patch
| ai/default/daitech.c | ||
|---|---|---|
|
struct research *pres = research_get(pplayer);
|
||
|
Tech_type_id tech = advance_number(padv);
|
||
|
enum tech_state old_state = research_invention_state(pres, tech);
|
||
|
struct adv_data *adv = adv_data_get(pplayer, NULL);
|
||
|
adv_want orig_want = dai_city_want(pplayer, pcity, adv, NULL);
|
||
|
struct adv_data *adv = adv_data_get(pplayer, nullptr);
|
||
|
adv_want orig_want = dai_city_want(pplayer, pcity, adv, nullptr);
|
||
|
adv_want final_want;
|
||
|
bool world_knew = game.info.global_advances[tech];
|
||
|
int world_count = game.info.global_advance_count;
|
||
|
research_invention_set(pres, tech, TECH_KNOWN);
|
||
|
final_want = dai_city_want(pplayer, pcity, adv, NULL);
|
||
|
final_want = dai_city_want(pplayer, pcity, adv, nullptr);
|
||
|
research_invention_set(pres, tech, old_state);
|
||
|
game.info.global_advances[tech] = world_knew;
|
||
| ... | ... | |
|
{
|
||
|
/* TODO: Currently this duplicates code from daicity.c improvement effect
|
||
|
* evaluating almost verbose - refactor so that they can share code. */
|
||
|
struct adv_data *adv = adv_data_get(pplayer, NULL);
|
||
|
struct adv_data *adv = adv_data_get(pplayer, nullptr);
|
||
|
struct ai_plr *aip = def_ai_player_data(pplayer, ait);
|
||
|
int turns = 9999; /* TODO: Set to correct value */
|
||
|
int nplayers = normal_player_count();
|
||
| ... | ... | |
|
present = preq->present;
|
||
|
continue;
|
||
|
}
|
||
|
if (!is_req_active(&context, NULL, preq, RPT_POSSIBLE)) {
|
||
|
if (!is_req_active(&context, nullptr, preq, RPT_POSSIBLE)) {
|
||
|
active = FALSE;
|
||
|
break; /* presence doesn't matter for inactive effects. */
|
||
|
break; /* Presence doesn't matter for inactive effects. */
|
||
|
}
|
||
|
} requirement_vector_iterate_end;
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the best defense multiplier unit we can build, or NULL if none.
|
||
|
Returns the best defense multiplier unit we can build, or nullptr if none.
|
||
|
Assigns tech wants for techs to get better units, but only for the
|
||
|
cheapest to research.
|
||
|
**************************************************************************/
|
||
| ... | ... | |
|
{
|
||
|
struct research *presearch = research_get(pplayer);
|
||
|
int best_avl_def = 0;
|
||
|
struct unit_type *best_avl = NULL;
|
||
|
struct unit_type *best_avl = nullptr;
|
||
|
int best_cost = FC_INFINITY;
|
||
|
struct advance *best_tech = A_NEVER;
|
||
|
struct unit_type *best_unit = NULL;
|
||
|
struct unit_type *best_unit = nullptr;
|
||
|
struct tile *ptile = city_tile(pcity);
|
||
|
int def_values[U_LAST];
|
||
|
int att_idx = utype_index(att);
|
||
|
int defbonus = 100
|
||
|
+ get_unittype_bonus(pplayer, ptile, att, NULL, EFT_DEFEND_BONUS);
|
||
|
+ get_unittype_bonus(pplayer, ptile, att, nullptr, EFT_DEFEND_BONUS);
|
||
|
unit_type_iterate(deftype) {
|
||
|
int mp_pct = deftype->cache.defense_mp_bonuses_pct[att_idx] + 100;
|
||
| ... | ... | |
|
} unit_tech_reqs_iterate_end;
|
||
|
building = utype_needs_improvement(deftype, pcity);
|
||
|
if (building != NULL
|
||
|
if (building != nullptr
|
||
|
&& !can_player_build_improvement_direct(pplayer, building,
|
||
|
RPT_CERTAIN)) {
|
||
|
const struct req_context context = {
|
||
| ... | ... | |
|
};
|
||
|
requirement_vector_iterate(&building->reqs, preq) {
|
||
|
if (!is_req_active(&context, NULL, preq, RPT_CERTAIN)) {
|
||
|
if (!is_req_active(&context, nullptr, preq, RPT_CERTAIN)) {
|
||
|
if (VUT_ADVANCE == preq->source.kind && preq->present) {
|
||
|
int iimprtech = advance_number(preq->source.value.advance);
|
||
| ... | ... | |
|
struct ai_plr *plr_data = def_ai_player_data(pplayer, ait);
|
||
|
/* Crank up chosen tech want */
|
||
|
if (best_avl != NULL
|
||
|
if (best_avl != nullptr
|
||
|
&& def_values[utype_index(best_unit)] <= 1.5 * best_avl_def) {
|
||
|
/* We already have almost as good unit suitable for defending against this attacker */
|
||
|
/* We already have almost as good unit suitable for defending against
|
||
|
* this attacker */
|
||
|
want /= 2;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the best unit we can build, or NULL if none. "Best" here
|
||
|
Returns the best unit we can build, or nullptr if none. "Best" here
|
||
|
means last in the unit list as defined in the ruleset. Assigns tech
|
||
|
wants for techs to get better units with given role, but only for the
|
||
|
cheapest to research "next" unit up the "chain".
|
||
| ... | ... | |
|
int i, n;
|
||
|
int best_cost = FC_INFINITY;
|
||
|
struct advance *best_tech = A_NEVER;
|
||
|
struct unit_type *best_unit = NULL;
|
||
|
struct unit_type *build_unit = NULL;
|
||
|
struct unit_type *best_unit = nullptr;
|
||
|
struct unit_type *build_unit = nullptr;
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
|
n = num_role_units(role);
|
||
| ... | ... | |
|
} unit_tech_reqs_iterate_end;
|
||
|
building = utype_needs_improvement(iunit, pcity);
|
||
|
if (building != NULL
|
||
|
if (building != nullptr
|
||
|
&& !can_player_build_improvement_direct(pplayer, building,
|
||
|
RPT_CERTAIN)) {
|
||
|
requirement_vector_iterate(&building->reqs, preq) {
|
||
| ... | ... | |
|
struct ai_plr *plr_data = def_ai_player_data(pplayer, ait);
|
||
|
/* Crank up chosen tech want */
|
||
|
if (build_unit != NULL) {
|
||
|
if (build_unit != nullptr) {
|
||
|
/* We already have a role unit of this kind */
|
||
|
want /= 2;
|
||
|
}
|
||