Feature #2308 ยป 0081-advisors-Replace-NULL-with-nullptr.patch
| server/advisors/advbuilding.c | ||
|---|---|---|
|
punittype = best_role_unit_for_player(pplayer,
|
||
|
action_id_get_role(ACTION_HELP_WONDER));
|
||
|
if (punittype == NULL) {
|
||
|
if (punittype == nullptr) {
|
||
|
/* Simulate future unit */
|
||
|
punittype = get_role_unit(action_id_get_role(ACTION_HELP_WONDER), 0);
|
||
|
}
|
||
| ... | ... | |
|
fc_assert_msg(utype_can_do_action(punittype, ACTION_HELP_WONDER),
|
||
|
"Non existence of wonder helper unit not caught");
|
||
|
ghost = unit_virtual_create(pplayer, NULL, punittype, 0);
|
||
|
ghost = unit_virtual_create(pplayer, nullptr, punittype, 0);
|
||
|
range = unit_move_rate(ghost) * 4;
|
||
|
city_list_iterate(pplayer->cities, pcity) {
|
||
| ... | ... | |
|
if (move_cost > range) {
|
||
|
break;
|
||
|
}
|
||
|
if (acity == NULL) {
|
||
|
if (acity == nullptr) {
|
||
|
continue;
|
||
|
}
|
||
|
if (city_owner(acity) == pplayer) {
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
void building_advisor(struct player *pplayer)
|
||
|
{
|
||
|
struct adv_data *adv = adv_data_get(pplayer, NULL);
|
||
|
struct adv_data *adv = adv_data_get(pplayer, nullptr);
|
||
|
struct city *wonder_city = game_city_by_number(adv->wonder_city);
|
||
|
CALL_FUNC_EACH_AI(build_adv_init, pplayer);
|
||
| ... | ... | |
|
if (wonder_city && city_owner(wonder_city) != pplayer) {
|
||
|
/* We lost it to the enemy! */
|
||
|
adv->wonder_city = 0;
|
||
|
wonder_city = NULL;
|
||
|
wonder_city = nullptr;
|
||
|
}
|
||
|
/* Preliminary analysis - find our Wonder City. Also check if it
|
||
|
* is sane to continue building the wonder in it. If either does
|
||
|
* not check out, make a Wonder City. */
|
||
|
if (NULL == wonder_city
|
||
|
if (wonder_city == nullptr
|
||
|
|| 0 >= wonder_city->surplus[O_SHIELD]
|
||
|
|| VUT_UTYPE == wonder_city->production.kind /* changed to defender? */
|
||
|
|| VUT_UTYPE == wonder_city->production.kind /* Changed to defender? */
|
||
|
|| !is_wonder(wonder_city->production.value.building)
|
||
|
|| !can_city_build_improvement_now(wonder_city,
|
||
|
wonder_city->production.value.building,
|
||
| ... | ... | |
|
wonder_city->production.value.building)) {
|
||
|
/* Find a new wonder city! */
|
||
|
int best_candidate_value = 0;
|
||
|
struct city *best_candidate = NULL;
|
||
|
struct city *best_candidate = nullptr;
|
||
|
/* Whether ruleset has a help wonder unit type */
|
||
|
bool has_help =
|
||
|
(num_role_units(action_id_get_role(ACTION_HELP_WONDER)) > 0);
|
||
|
bool has_help
|
||
|
= (num_role_units(action_id_get_role(ACTION_HELP_WONDER)) > 0);
|
||
|
calculate_city_clusters(pplayer);
|
||
| ... | ... | |
|
void building_advisor_choose(struct city *pcity, struct adv_choice *choice)
|
||
|
{
|
||
|
struct player *plr = city_owner(pcity);
|
||
|
struct impr_type *chosen = NULL;
|
||
|
struct impr_type *chosen = nullptr;
|
||
|
adv_want want = 0;
|
||
|
improvement_iterate(pimprove) {
|
||
| ... | ... | |
|
choice->want = want;
|
||
|
choice->value.building = chosen;
|
||
|
if (chosen != NULL) {
|
||
|
if (chosen != nullptr) {
|
||
|
choice->type = CT_BUILDING;
|
||
|
CITY_LOG(LOG_DEBUG, pcity, "advisor wants to build %s with want "
|
||
| server/advisors/advchoice.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
void adv_init_choice(struct adv_choice *choice)
|
||
|
{
|
||
|
choice->value.utype = NULL;
|
||
|
choice->value.utype = nullptr;
|
||
|
choice->want = 0;
|
||
|
choice->type = CT_NONE;
|
||
|
choice->need_boat = FALSE;
|
||
|
#ifdef ADV_CHOICE_TRACK
|
||
|
choice->use = NULL;
|
||
|
choice->use = nullptr;
|
||
|
choice->log_if_chosen = FALSE;
|
||
|
#endif /* ADV_CHOICE_TRACK */
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
void adv_deinit_choice(struct adv_choice *choice)
|
||
|
{
|
||
|
#ifdef ADV_CHOICE_TRACK
|
||
|
if (choice->use != NULL) {
|
||
|
if (choice->use != nullptr) {
|
||
|
free(choice->use);
|
||
|
choice->use = NULL;
|
||
|
choice->use = nullptr;
|
||
|
}
|
||
|
#endif /* ADV_CHOICE_TRACK */
|
||
|
}
|
||
| ... | ... | |
|
void adv_free_choice(struct adv_choice *choice)
|
||
|
{
|
||
|
#ifdef ADV_CHOICE_TRACK
|
||
|
if (choice->use != NULL) {
|
||
|
if (choice->use != nullptr) {
|
||
|
free(choice->use);
|
||
|
}
|
||
|
#endif /* ADV_CHOICE_TRACK */
|
||
|
free(choice);
|
||
|
}
|
||
| ... | ... | |
|
dest->value = src->value;
|
||
|
dest->want = src->want;
|
||
|
dest->need_boat = src->need_boat;
|
||
|
if (dest->use != NULL) {
|
||
|
if (dest->use != nullptr) {
|
||
|
free(dest->use);
|
||
|
}
|
||
|
if (src->use != NULL) {
|
||
|
if (src->use != nullptr) {
|
||
|
dest->use = fc_strdup(src->use);
|
||
|
} else {
|
||
|
dest->use = NULL;
|
||
|
dest->use = nullptr;
|
||
|
}
|
||
|
dest->log_if_chosen = src->log_if_chosen;
|
||
|
}
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
void adv_choice_set_use(struct adv_choice *choice, const char *use)
|
||
|
{
|
||
|
if (choice->use != NULL) {
|
||
|
if (choice->use != nullptr) {
|
||
|
free(choice->use);
|
||
|
}
|
||
|
choice->use = fc_strdup(use);
|
||
| ... | ... | |
|
const char *use;
|
||
|
const char *name;
|
||
|
if (choice->use != NULL) {
|
||
|
if (choice->use != nullptr) {
|
||
|
use = choice->use;
|
||
|
} else {
|
||
|
use = "<unknown>";
|
||
| ... | ... | |
|
name = adv_choice_rule_name(choice);
|
||
|
if (loc2 != NULL) {
|
||
|
if (loc2 != nullptr) {
|
||
|
log_base(ADV_CHOICE_LOG_LEVEL, "Choice at \"%s:%s\": %s, "
|
||
|
"want " ADV_WANT_PRINTF " as %s (%d)",
|
||
|
loc1, loc2, name, choice->want, use, choice->type);
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
const char *adv_choice_get_use(const struct adv_choice *choice)
|
||
|
{
|
||
|
if (choice->use == NULL) {
|
||
|
if (choice->use == nullptr) {
|
||
|
return "(unset)";
|
||
|
}
|
||
| server/advisors/advruleset.c | ||
|---|---|---|
|
bool move_sea_disabled = FALSE; /* Cannot move at some ocean terrains */
|
||
|
terrain_type_iterate(pterrain) {
|
||
|
if (is_native_to_class(pclass, pterrain, NULL)) {
|
||
|
if (is_native_to_class(pclass, pterrain, nullptr)) {
|
||
|
/* Can move at terrain */
|
||
|
if (is_ocean(pterrain)) {
|
||
|
move_sea_enabled = TRUE;
|
||
| ... | ... | |
|
effect_list_iterate(get_effects(EFT_DEFEND_BONUS), peffect) {
|
||
|
if (peffect->value > 0) {
|
||
|
requirement_vector_iterate(&peffect->reqs, preq) {
|
||
|
if (!is_req_active(&context, NULL, preq, RPT_POSSIBLE)) {
|
||
|
if (!is_req_active(&context, nullptr, preq, RPT_POSSIBLE)) {
|
||
|
ptype->adv.igwall = FALSE;
|
||
|
break;
|
||
|
}
|
||