Feature #2489 ยป 0076-climisc.c-Replace-NULL-with-nullptr.patch
| client/climisc.c | ||
|---|---|---|
|
punit->id, nation_rule_name(nation_of_unit(punit)),
|
||
|
unit_rule_name(punit), TILE_XY(unit_tile(punit)), hc);
|
||
|
update = (get_focus_unit_on_tile(unit_tile(punit)) != NULL);
|
||
|
update = (get_focus_unit_on_tile(unit_tile(punit)) != nullptr);
|
||
|
/* Check transport status. */
|
||
|
unit_transport_unload(punit);
|
||
| ... | ... | |
|
control_unit_killed(punit);
|
||
|
game_remove_unit(&wld, punit);
|
||
|
punit = NULL;
|
||
|
punit = nullptr;
|
||
|
if (old > 0 && get_num_units_in_focus() == 0) {
|
||
|
unit_focus_advance(TRUE);
|
||
|
} else if (update) {
|
||
| ... | ... | |
|
}
|
||
|
pcity = tile_city(ptile);
|
||
|
if (NULL != pcity) {
|
||
|
if (pcity != nullptr) {
|
||
|
if (can_player_see_units_in_city(client_player(), pcity)) {
|
||
|
pcity->client.occupied = (0 < unit_list_size(pcity->tile->units));
|
||
|
refresh_city_dialog(pcity);
|
||
| ... | ... | |
|
if (!client_has_player() || unit_owner(&old_unit) == client_player()) {
|
||
|
pcity = game_city_by_number(hc);
|
||
|
if (NULL != pcity) {
|
||
|
if (pcity != nullptr) {
|
||
|
refresh_city_dialog(pcity);
|
||
|
log_debug("home city %s, %s, (%d %d)",
|
||
|
city_name_get(pcity), nation_rule_name(nation_of_city(pcity)),
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
Change all cities building X to building Y, if possible. X and Y
|
||
|
Change all cities building X to building Y, if possible. X and Y
|
||
|
could be improvements or units. X and Y are compound ids.
|
||
|
**************************************************************************/
|
||
|
void client_change_all(struct universal *from, struct universal *to)
|
||
| ... | ... | |
|
return;
|
||
|
}
|
||
|
create_event(NULL, E_CITY_PRODUCTION_CHANGED, ftc_client,
|
||
|
create_event(nullptr, E_CITY_PRODUCTION_CHANGED, ftc_client,
|
||
|
_("Changing production of every %s into %s."),
|
||
|
VUT_UTYPE == from->kind
|
||
|
? utype_name_translation(from->value.utype)
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
struct sprite *client_research_sprite(void)
|
||
|
{
|
||
|
if (NULL != client.conn.playing && can_client_change_view()) {
|
||
|
if (client.conn.playing != nullptr && can_client_change_view()) {
|
||
|
const struct research *presearch = research_get(client_player());
|
||
|
int idx = 0;
|
||
| ... | ... | |
|
if (can_client_change_view()) {
|
||
|
/* Highest sprite kicks in at about 25% risk */
|
||
|
global_warming_scaled(&idx, NULL, (NUM_TILES_PROGRESS-1)*4);
|
||
|
global_warming_scaled(&idx, nullptr, (NUM_TILES_PROGRESS-1)*4);
|
||
|
idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
|
||
|
} else {
|
||
|
idx = 0;
|
||
| ... | ... | |
|
if (can_client_change_view()) {
|
||
|
/* Highest sprite kicks in at about 25% risk */
|
||
|
nuclear_winter_scaled(&idx, NULL, (NUM_TILES_PROGRESS-1)*4);
|
||
|
nuclear_winter_scaled(&idx, nullptr, (NUM_TILES_PROGRESS-1)*4);
|
||
|
idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
|
||
|
} else {
|
||
|
idx = 0;
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
struct sprite *client_government_sprite(void)
|
||
|
{
|
||
|
if (NULL != client.conn.playing && can_client_change_view()
|
||
|
if (client.conn.playing != nullptr && can_client_change_view()
|
||
|
&& government_count() > 0) {
|
||
|
struct government *gov = government_of_player(client.conn.playing);
|
||
|
return get_government_sprite(tileset, gov);
|
||
|
} else {
|
||
|
/* HACK: the UNHAPPY citizen is used for the government
|
||
|
/* HACK: The UNHAPPY citizen is used for the government
|
||
|
* when we don't know any better. */
|
||
|
return get_citizen_sprite(tileset, CITIZEN_UNHAPPY, 0, NULL);
|
||
|
return get_citizen_sprite(tileset, CITIZEN_UNHAPPY, 0, nullptr);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
if (get_num_units_in_focus() > 0) {
|
||
|
center_tile_mapcanvas(unit_tile(head_of_units_in_focus()));
|
||
|
} else if (client_has_player()
|
||
|
&& NULL != (pcity = player_primary_capital(client_player()))) {
|
||
|
&& (pcity = player_primary_capital(client_player())) != nullptr) {
|
||
|
/* Else focus on the capital. */
|
||
|
center_tile_mapcanvas(pcity->tile);
|
||
|
} else if (NULL != client.conn.playing
|
||
|
} else if (client.conn.playing != nullptr
|
||
|
&& 0 < city_list_size(client.conn.playing->cities)) {
|
||
|
/* Just focus on any city. */
|
||
|
pcity = city_list_get(client.conn.playing->cities, 0);
|
||
|
fc_assert_ret(pcity != NULL);
|
||
|
fc_assert_ret(pcity != nullptr);
|
||
|
center_tile_mapcanvas(pcity->tile);
|
||
|
} else if (NULL != client.conn.playing
|
||
|
} else if (client.conn.playing != nullptr
|
||
|
&& 0 < unit_list_size(client.conn.playing->units)) {
|
||
|
/* Just focus on any unit. */
|
||
|
punit = unit_list_get(client.conn.playing->units, 0);
|
||
|
fc_assert_ret(punit != NULL);
|
||
|
fc_assert_ret(punit != nullptr);
|
||
|
center_tile_mapcanvas(unit_tile(punit));
|
||
|
} else {
|
||
|
struct tile *ctile = native_pos_to_tile(nmap, MAP_NATIVE_WIDTH / 2,
|
||
| ... | ... | |
|
if (is_convert_improvement(target.value.building)) {
|
||
|
cost = -1;
|
||
|
} else {
|
||
|
if (pcity != NULL) {
|
||
|
if (pcity != nullptr) {
|
||
|
cost = impr_build_shield_cost(pcity, target.value.building);
|
||
|
} else {
|
||
|
cost = MAX(target.value.building->build_cost * game.info.shieldbox / 100, 1);
|
||
|
cost = MAX(target.value.building->build_cost * game.info.shieldbox
|
||
|
/ 100, 1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
Collect the cids of all targets (improvements and units) which are
|
||
|
currently built in a city.
|
||
|
FIXME: this should probably take a pplayer argument.
|
||
|
FIXME: This should probably take a pplayer argument.
|
||
|
**************************************************************************/
|
||
|
int collect_currently_building_targets(struct universal *targets)
|
||
|
{
|
||
| ... | ... | |
|
int cids_used = 0;
|
||
|
cid id;
|
||
|
if (NULL == client.conn.playing) {
|
||
|
if (client.conn.playing == nullptr) {
|
||
|
return 0;
|
||
|
}
|
||
| ... | ... | |
|
Collect the cids of all targets (improvements and units) which can
|
||
|
be build in a city.
|
||
|
FIXME: this should probably take a pplayer argument.
|
||
|
FIXME: This should probably take a pplayer argument.
|
||
|
**************************************************************************/
|
||
|
int collect_buildable_targets(struct universal *targets)
|
||
|
{
|
||
|
int cids_used = 0;
|
||
|
if (NULL == client.conn.playing) {
|
||
|
if (client.conn.playing == nullptr) {
|
||
|
return 0;
|
||
|
}
|
||
| ... | ... | |
|
bool can_build;
|
||
|
bool can_eventually_build;
|
||
|
if (NULL != pcity) {
|
||
|
if (pcity != nullptr) {
|
||
|
/* Can the city build? */
|
||
|
can_build = can_city_build_improvement_now(pcity, pimprove,
|
||
|
RPT_CERTAIN);
|
||
|
can_eventually_build = can_city_build_improvement_later(pcity,
|
||
|
pimprove);
|
||
|
} else if (NULL != pplayer) {
|
||
|
} else if (pplayer != nullptr) {
|
||
|
/* Can our player build? */
|
||
|
can_build = can_player_build_improvement_now(pplayer, pimprove,
|
||
|
RPT_CERTAIN);
|
||
| ... | ... | |
|
bool can_build;
|
||
|
bool can_eventually_build;
|
||
|
if (NULL != pcity) {
|
||
|
if (pcity != nullptr) {
|
||
|
/* Can the city build? */
|
||
|
can_build = can_city_build_unit_now(nmap, pcity, punittype, RPT_CERTAIN);
|
||
|
can_eventually_build = can_city_build_unit_later(nmap, pcity, punittype);
|
||
|
} else if (NULL != pplayer) {
|
||
|
} else if (pplayer != nullptr) {
|
||
|
/* Can our player build? */
|
||
|
can_build = can_player_build_unit_now(pplayer, punittype, RPT_CERTAIN);
|
||
|
can_eventually_build = can_player_build_unit_later(pplayer, punittype);
|
||
| ... | ... | |
|
{
|
||
|
int cids_used = 0;
|
||
|
fc_assert_ret_val(pcity != NULL, 0);
|
||
|
fc_assert_ret_val(pcity != nullptr, 0);
|
||
|
city_built_iterate(pcity, pimprove) {
|
||
|
targets[cids_used].kind = VUT_IMPROVEMENT;
|
||
| ... | ... | |
|
{
|
||
|
char plain_text[MAX_LEN_MSG];
|
||
|
struct text_tag_list *tags;
|
||
|
int where = MW_OUTPUT; /* where to display the message */
|
||
|
bool fallback_needed = FALSE; /* we want fallback if actual 'where' is not
|
||
|
int where = MW_OUTPUT; /* Where to display the message */
|
||
|
bool fallback_needed = FALSE; /* We want fallback if actual 'where' is not
|
||
|
* usable */
|
||
|
bool shown = FALSE; /* Message displayed somewhere at least */
|
||
| ... | ... | |
|
const char *username = client.conn.username;
|
||
|
size_t userlen = strlen(username);
|
||
|
const char *playername = ((client_player() && !client_is_observer())
|
||
|
? player_name(client_player()) : NULL);
|
||
|
? player_name(client_player()) : nullptr);
|
||
|
size_t playerlen = playername ? strlen(playername) : 0;
|
||
|
const char *p;
|
||
|
if (playername && playername[0] == '\0') {
|
||
|
playername = NULL;
|
||
|
playername = nullptr;
|
||
|
}
|
||
|
if (username && username[0] == '\0') {
|
||
|
username = NULL;
|
||
|
username = nullptr;
|
||
|
}
|
||
|
for (p = plain_text; *p != '\0'; p++) {
|
||
|
if (NULL != username
|
||
|
if (username != nullptr
|
||
|
&& 0 == fc_strncasecmp(p, username, userlen)) {
|
||
|
struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
|
||
|
p - plain_text + userlen,
|
||
|
gui_options.highlight_our_names);
|
||
|
fc_assert(ptag != NULL);
|
||
|
fc_assert(ptag != nullptr);
|
||
|
if (ptag != NULL) {
|
||
|
if (ptag != nullptr) {
|
||
|
/* Appends to be sure it will be applied at last. */
|
||
|
text_tag_list_append(tags, ptag);
|
||
|
}
|
||
|
} else if (NULL != playername
|
||
|
} else if (playername != nullptr
|
||
|
&& 0 == fc_strncasecmp(p, playername, playerlen)) {
|
||
|
struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
|
||
|
p - plain_text + playerlen,
|
||
|
gui_options.highlight_our_names);
|
||
|
fc_assert(ptag != NULL);
|
||
|
fc_assert(ptag != nullptr);
|
||
|
if (ptag != NULL) {
|
||
|
if (ptag != nullptr) {
|
||
|
/* Appends to be sure it will be applied at last. */
|
||
|
text_tag_list_append(tags, ptag);
|
||
|
}
|
||
| ... | ... | |
|
if (BOOL_VAL(where & MW_POPUP)) {
|
||
|
/* Popups are usually not shown if player is under AI control.
|
||
|
* Server operator messages are shown always. */
|
||
|
if (NULL == client.conn.playing
|
||
|
if (client.conn.playing == nullptr
|
||
|
|| is_human(client.conn.playing)
|
||
|
|| event == E_MESSAGE_WALL) {
|
||
|
popup_notify_goto_dialog(_("Popup Request"), plain_text, tags, ptile);
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Find city nearest to given unit and optionally return squared city
|
||
|
distance Parameter sq_dist may be NULL. Returns NULL only if no city is
|
||
|
known. Favors punit owner's cities over other cities if equally distant.
|
||
|
distance Parameter sq_dist may be nullptr. Returns nullptr only if
|
||
|
no city is known. Favors punit owner's cities over other cities
|
||
|
if equally distant.
|
||
|
**************************************************************************/
|
||
|
struct city *get_nearest_city(const struct unit *punit, int *sq_dist)
|
||
|
{
|
||
| ... | ... | |
|
if ((pcity_near = tile_city(unit_tile(punit)))) {
|
||
|
pcity_near_dist = 0;
|
||
|
} else {
|
||
|
pcity_near = NULL;
|
||
|
pcity_near = nullptr;
|
||
|
pcity_near_dist = -1;
|
||
|
players_iterate(pplayer) {
|
||
|
city_list_iterate(pplayer->cities, pcity_current) {
|
||
| ... | ... | |
|
"%s costs %d gold", value),
|
||
|
city_production_name_translation(pcity),
|
||
|
value);
|
||
|
create_event(NULL, E_BAD_COMMAND, ftc_client,
|
||
|
create_event(nullptr, E_BAD_COMMAND, ftc_client,
|
||
|
/* TRANS: %s is a pre-pluralised sentence fragment:
|
||
|
* "%s costs %d gold" */
|
||
|
PL_("%s and you only have %d gold.",
|
||
| ... | ... | |
|
void client_unit_init_act_prob_cache(struct unit *punit)
|
||
|
{
|
||
|
/* A double init would cause a leak. */
|
||
|
fc_assert_ret(punit->client.act_prob_cache == NULL);
|
||
|
fc_assert_ret(punit->client.act_prob_cache == nullptr);
|
||
|
punit->client.act_prob_cache = (struct act_prob*)fc_malloc(
|
||
|
NUM_ACTIONS * sizeof(*punit->client.act_prob_cache));
|
||
| ... | ... | |
|
void client_player_init(struct player *pplayer)
|
||
|
{
|
||
|
vision_layer_iterate(v) {
|
||
|
pplayer->client.tile_vision[v].vec = NULL;
|
||
|
pplayer->client.tile_vision[v].vec = nullptr;
|
||
|
pplayer->client.tile_vision[v].bits = 0;
|
||
|
} vision_layer_iterate_end;
|
||
|
}
|
||
| ... | ... | |
|
struct mapdef *pmapdef;
|
||
|
char mapimgfile[512];
|
||
|
if (NULL == filename || '\0' == filename[0]) {
|
||
|
if (filename == nullptr || '\0' == filename[0]) {
|
||
|
sz_strlcpy(mapimgfile, gui_options.mapimg_filename);
|
||
|
} else {
|
||
|
sz_strlcpy(mapimgfile, filename);
|
||
| ... | ... | |
|
return FALSE;
|
||
|
}
|
||
|
return mapimg_create(pmapdef, TRUE, mapimgfile, NULL);
|
||
|
return mapimg_create(pmapdef, TRUE, mapimgfile, nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
struct option *poption = optset_option_by_name(server_optset, "nationset");
|
||
|
const char *setting_str;
|
||
|
if (poption == NULL
|
||
|
if (poption == nullptr
|
||
|
|| option_type(poption) != OT_STRING
|
||
|
|| (setting_str = option_str_get(poption)) == NULL) {
|
||
|
|| (setting_str = option_str_get(poption)) == nullptr) {
|
||
|
setting_str = "";
|
||
|
}
|
||