Feature #2271 ยป 0069-tex-Replace-NULL-with-nullptr.patch
| ai/tex/texai.c | ||
|---|---|---|
|
static void texai_init_self(struct ai_type *ai);
|
||
|
static struct ai_type *self = NULL;
|
||
|
static struct ai_type *self = nullptr;
|
||
|
/**********************************************************************//**
|
||
|
Set pointer to ai type of the tex ai.
|
||
| ai/tex/texaicity.c | ||
|---|---|---|
|
struct texai_city *cdata = texai_city_data(ait, pcity);
|
||
|
int *wants = cdata->unit_wants;
|
||
|
int maxwant = 0;
|
||
|
struct unit_type *type = NULL;
|
||
|
struct unit_type *type = nullptr;
|
||
|
Continent_id place = tile_continent(city_tile(pcity));
|
||
|
struct ai_plr *dai = dai_plr_data_get(ait, pplayer, NULL);
|
||
|
struct adv_data *adv = adv_data_get(pplayer, NULL);
|
||
|
struct ai_plr *dai = dai_plr_data_get(ait, pplayer, nullptr);
|
||
|
struct adv_data *adv = adv_data_get(pplayer, nullptr);
|
||
|
unit_type_iterate(ptype) {
|
||
|
wants[utype_index(ptype)] = 0;
|
||
| ... | ... | |
|
bool possible = FALSE;
|
||
|
enum extra_cause cause;
|
||
|
enum extra_rmcause rmcause;
|
||
|
struct extra_type *tgt = NULL;
|
||
|
struct extra_type *tgt = nullptr;
|
||
|
/* Do not request activities that already are under way. */
|
||
|
unit_list_iterate(ptile->units, punit) {
|
||
| ... | ... | |
|
worked->want = TWMP * (value - orig_value);
|
||
|
worked->ptile = ptile;
|
||
|
worked->act = action_id_get_activity(act);
|
||
|
worked->tgt = NULL;
|
||
|
worked->tgt = nullptr;
|
||
|
if (limit == TWTL_BUILDABLE_UNITS) {
|
||
|
unit_list_iterate(units, punit) {
|
||
|
if (action_prob_possible(
|
||
| ... | ... | |
|
unworked->want = TWMP * (value - orig_value);
|
||
|
unworked->ptile = ptile;
|
||
|
unworked->act = action_id_get_activity(act);
|
||
|
unworked->tgt = NULL;
|
||
|
unworked->tgt = nullptr;
|
||
|
if (limit == TWTL_BUILDABLE_UNITS) {
|
||
|
unit_list_iterate(units, punit) {
|
||
|
if (action_prob_possible(
|
||
| ... | ... | |
|
} aw_transform_action_iterate_end;
|
||
|
extra_type_iterate(tgt) {
|
||
|
struct action *paction = NULL;
|
||
|
struct action *paction = nullptr;
|
||
|
bool removing = tile_has_extra(ptile, tgt);
|
||
|
unit_list_iterate(units, punit) {
|
||
| ... | ... | |
|
}
|
||
|
} unit_list_iterate_end;
|
||
|
if (paction != NULL) {
|
||
|
if (paction != nullptr) {
|
||
|
adv_want base_value;
|
||
|
int value;
|
||
|
adv_want extra;
|
||
| ... | ... | |
|
base_value = adv_city_worker_extra_get(pcity, cindex, tgt);
|
||
|
}
|
||
|
if (proad != NULL && road_provides_move_bonus(proad)) {
|
||
|
if (proad != nullptr && road_provides_move_bonus(proad)) {
|
||
|
int old_move_cost;
|
||
|
int mc_multiplier = 1;
|
||
|
int mc_divisor = 1;
|
||
| ... | ... | |
|
enum texai_worker_task_limitation limit)
|
||
|
{
|
||
|
struct worker_task *selected;
|
||
|
struct worker_task worked = { .ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL };
|
||
|
struct worker_task unworked = { .ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL };
|
||
|
struct texai_tile_state state = { .uw_max = 0, .uw_max_base = 0, .worst_worked = FC_INFINITY,
|
||
|
.orig_worst_worked = 0, .old_worst_worked = FC_INFINITY };
|
||
|
struct unit_list *units = NULL;
|
||
|
struct worker_task worked
|
||
|
= { .ptile = nullptr, .want = 0, .act = ACTIVITY_IDLE, .tgt = nullptr };
|
||
|
struct worker_task unworked
|
||
|
= { .ptile = nullptr, .want = 0, .act = ACTIVITY_IDLE, .tgt = nullptr };
|
||
|
struct texai_tile_state state
|
||
|
= { .uw_max = 0, .uw_max_base = 0, .worst_worked = FC_INFINITY,
|
||
|
.orig_worst_worked = 0, .old_worst_worked = FC_INFINITY };
|
||
|
struct unit_list *units = nullptr;
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
|
switch (limit) {
|
||
|
case TWTL_CURRENT_UNITS:
|
||
|
units = texai_player_units(pplayer);
|
||
|
state.wants = NULL;
|
||
|
state.wants = nullptr;
|
||
|
break;
|
||
|
case TWTL_BUILDABLE_UNITS:
|
||
|
units = unit_list_new();
|
||
| ... | ... | |
|
&worked, &unworked, &state, limit);
|
||
|
} city_tile_iterate_end;
|
||
|
if (worked.ptile == NULL
|
||
|
if (worked.ptile == nullptr
|
||
|
|| (state.old_worst_worked < state.uw_max
|
||
|
&& (state.uw_max - state.orig_worst_worked) * TWMP > worked.want)
|
||
|
|| (state.uw_max - state.uw_max_base * TWMP > worked.want)) {
|
||
| ... | ... | |
|
unit_list_destroy(units);
|
||
|
}
|
||
|
if (selected->ptile != NULL) {
|
||
|
struct extra_type *target = NULL;
|
||
|
if (selected->ptile != nullptr) {
|
||
|
struct extra_type *target = nullptr;
|
||
|
if (selected->tgt == NULL) {
|
||
|
if (selected->tgt == nullptr) {
|
||
|
enum extra_cause cause = activity_to_extra_cause(selected->act);
|
||
|
if (cause != EC_NONE) {
|
||
|
target = next_extra_for_tile(selected->ptile, cause, pplayer, NULL);
|
||
|
target = next_extra_for_tile(selected->ptile, cause, pplayer, nullptr);
|
||
|
} else {
|
||
|
enum extra_rmcause rmcause = activity_to_extra_rmcause(selected->act);
|
||
|
if (rmcause != ERM_NONE) {
|
||
|
target = prev_extra_in_tile(selected->ptile, rmcause, pplayer, NULL);
|
||
|
target = prev_extra_in_tile(selected->ptile, rmcause,
|
||
|
pplayer, nullptr);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
| ... | ... | |
|
pcity = game_city_by_number(data->city_id);
|
||
|
if (pcity != NULL && city_owner(pcity) == req->plr) {
|
||
|
if (pcity != nullptr && city_owner(pcity) == req->plr) {
|
||
|
/* City has not been lost meanwhile */
|
||
|
struct worker_task *ptask = worker_task_list_get(pcity->task_reqs, 0);
|
||
|
if (ptask == NULL) {
|
||
|
if (ptask == nullptr) {
|
||
|
ptask = fc_malloc(sizeof(struct worker_task));
|
||
|
worker_task_init(ptask);
|
||
|
worker_task_list_append(pcity->task_reqs, ptask);
|
||
| ... | ... | |
|
{
|
||
|
struct texai_city *city_data = texai_city_data(ait, pcity);
|
||
|
if (city_data != NULL) {
|
||
|
if (city_data != nullptr) {
|
||
|
adv_deinit_choice(&(city_data->defai.choice));
|
||
|
city_set_ai_data(pcity, ait, NULL);
|
||
|
city_set_ai_data(pcity, ait, nullptr);
|
||
|
FC_FREE(city_data);
|
||
|
}
|
||
|
}
|
||
| ai/tex/texaimsg.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
void texai_first_activities(struct ai_type *ait, struct player *pplayer)
|
||
|
{
|
||
|
texai_send_msg(TEXAI_MSG_FIRST_ACTIVITIES, pplayer, NULL);
|
||
|
texai_send_msg(TEXAI_MSG_FIRST_ACTIVITIES, pplayer, nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
void texai_phase_finished(struct ai_type *ait, struct player *pplayer)
|
||
|
{
|
||
|
texai_send_msg(TEXAI_MSG_PHASE_FINISHED, pplayer, NULL);
|
||
|
texai_send_msg(TEXAI_MSG_PHASE_FINISHED, pplayer, nullptr);
|
||
|
}
|
||
| ai/tex/texaiworld.c | ||
|---|---|---|
|
info->terrain = ptile->terrain;
|
||
|
info->extras = ptile->extras;
|
||
|
texai_send_msg(TEXAI_MSG_TILE_INFO, NULL, info);
|
||
|
texai_send_msg(TEXAI_MSG_TILE_INFO, nullptr, info);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
{
|
||
|
struct texai_tile_info_msg *info = (struct texai_tile_info_msg *)data;
|
||
|
if (texai_world.map.tiles != NULL) {
|
||
|
if (texai_world.map.tiles != nullptr) {
|
||
|
struct tile *ptile;
|
||
|
ptile = index_to_tile(&(texai_world.map), info->index);
|
||
| ... | ... | |
|
info->owner = player_number(city_owner(pcity));
|
||
|
info->tindex = tile_index(city_tile(pcity));
|
||
|
texai_send_msg(msgtype, NULL, info);
|
||
|
texai_send_msg(msgtype, nullptr, info);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
struct tile *ptile;
|
||
|
struct texai_plr *plr_data;
|
||
|
if (idex_lookup_city(&texai_world, info->id) != NULL) {
|
||
|
if (idex_lookup_city(&texai_world, info->id) != nullptr) {
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
} else {
|
||
|
pcity = idex_lookup_city(&texai_world, info->id);
|
||
|
if (pcity != NULL) {
|
||
|
if (pcity != nullptr) {
|
||
|
pcity->owner = pplayer;
|
||
|
} else {
|
||
|
log_error("Tex: requested change on city id %d that's not known.",
|
||
| ... | ... | |
|
info->id = pcity->id;
|
||
|
texai_send_msg(TEXAI_MSG_CITY_DESTROYED, NULL, info);
|
||
|
texai_send_msg(TEXAI_MSG_CITY_DESTROYED, nullptr, info);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
struct texai_id_msg *info = (struct texai_id_msg *)data;
|
||
|
struct city *pcity = idex_lookup_city(&texai_world, info->id);
|
||
|
if (pcity != NULL) {
|
||
|
if (pcity != nullptr) {
|
||
|
struct texai_plr *plr_data;
|
||
|
adv_city_free(pcity);
|
||
|
tile_set_worked(city_tile(pcity), NULL);
|
||
|
tile_set_worked(city_tile(pcity), nullptr);
|
||
|
plr_data = player_ai_data(city_owner(pcity), texai_get_self());
|
||
|
city_list_remove(plr_data->cities, pcity);
|
||
|
idex_unregister_city(&texai_world, pcity);
|
||
| ... | ... | |
|
info->tindex = tile_index(unit_tile(punit));
|
||
|
info->type = utype_number(unit_type_get(punit));
|
||
|
texai_send_msg(msgtype, NULL, info);
|
||
|
texai_send_msg(msgtype, nullptr, info);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
if (msgtype == TEXAI_MSG_UNIT_CREATED) {
|
||
|
struct texai_plr *plr_data;
|
||
|
if (idex_lookup_unit(&texai_world, info->id) != NULL) {
|
||
|
if (idex_lookup_unit(&texai_world, info->id) != nullptr) {
|
||
|
return;
|
||
|
}
|
||
|
plr_data = player_ai_data(pplayer, texai_get_self());
|
||
|
punit = unit_virtual_create(pplayer, NULL, type, 0);
|
||
|
punit = unit_virtual_create(pplayer, nullptr, type, 0);
|
||
|
punit->id = info->id;
|
||
|
idex_register_unit(&texai_world, punit);
|
||
| ... | ... | |
|
info->id = punit->id;
|
||
|
texai_send_msg(TEXAI_MSG_UNIT_DESTROYED, NULL, info);
|
||
|
texai_send_msg(TEXAI_MSG_UNIT_DESTROYED, nullptr, info);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
struct texai_id_msg *info = (struct texai_id_msg *)data;
|
||
|
struct unit *punit = idex_lookup_unit(&texai_world, info->id);
|
||
|
if (punit != NULL) {
|
||
|
if (punit != nullptr) {
|
||
|
struct texai_plr *plr_data = player_ai_data(punit->owner,
|
||
|
texai_get_self());
|
||
| ... | ... | |
|
info->id = punit->id;
|
||
|
info->tindex = tile_index(unit_tile(punit));
|
||
|
texai_send_msg(TEXAI_MSG_UNIT_MOVED, NULL, info);
|
||
|
texai_send_msg(TEXAI_MSG_UNIT_MOVED, nullptr, info);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
struct unit *punit = idex_lookup_unit(&texai_world, info->id);
|
||
|
struct tile *ptile = index_to_tile(&(texai_world.map), info->tindex);
|
||
|
if (punit != NULL) {
|
||
|
if (punit != nullptr) {
|
||
|
unit_list_remove(punit->tile->units, punit);
|
||
|
unit_list_prepend(ptile->units, punit);
|
||