Project

General

Profile

Feature #2515 ยป 0052-text.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 12/02/2026 04:22 AM

View differences:

client/text.c
for (i = 0; i < O_LAST; i++) {
int before_penalty = 0;
int x = city_tile_output(NULL, ptile, FALSE, i);
int x = city_tile_output(nullptr, ptile, FALSE, i);
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
before_penalty = get_player_output_bonus(client.conn.playing,
get_output_type(i),
EFT_OUTPUT_PENALTY_TILE);
......
unit_activity_astr(punit, &str);
if (pcity) {
/* TRANS: on own line immediately following \n, ... <city> */
/* TRANS: On own line immediately following \n, ... <city> */
astr_add_line(&str, _("from %s"), city_name_get(pcity));
} else {
astr_add(&str, "\n");
}
if (game.info.citizen_nationality) {
if (nationality != NULL && owner != nationality) {
if (nationality != nullptr && owner != nationality) {
/* TRANS: Nationality of the people comprising a unit, if
* different from owner. */
astr_add_line(&str, _("%s people"),
......
/************************************************************************//**
Describe the airlift capacity of a city for the given units (from their
current positions).
If pdest is non-NULL, describe its capacity as a destination, otherwise
If pdest is non-nullptr, describe its capacity as a destination, otherwise
describe the capacity of the city the unit's currently in (if any) as a
source. (If the units in the list are in different cities, this will
probably not give a useful result in this case.)
If not all of the listed units can be airlifted, return the description
for those that can.
Returns NULL if an airlift is not possible for any of the units.
Returns nullptr if an airlift is not possible for any of the units.
Not re-entrant
****************************************************************************/
......
const struct city *pdest)
{
static struct astring str = ASTRING_INIT;
bool src = (pdest == NULL);
bool src = (pdest == nullptr);
enum texttype { AL_IMPOSSIBLE, AL_UNKNOWN, AL_FINITE, AL_INFINITE }
best = AL_IMPOSSIBLE;
int cur = 0, max = 0;
......
enum texttype this = AL_IMPOSSIBLE;
enum unit_airlift_result result;
/* NULL will tell us about the capability of airlifting from source */
/* nullptr will tell us about the capability of airlifting from source */
result = test_unit_can_airlift_to(&(wld.map), client_player(), punit, pdest);
switch (result) {
......
{
const struct city *pcity = src ? tile_city(unit_tile(punit)) : pdest;
fc_assert_ret_val(pcity != NULL, fc_strdup("-"));
fc_assert_ret_val(pcity != nullptr, fc_strdup("-"));
if (!src && ((game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)
&& game.info.airlift_to_always_enabled)) {
/* No restrictions on destination (and we can infer this even for
......
switch (best) {
case AL_IMPOSSIBLE:
return NULL;
return nullptr;
case AL_UNKNOWN:
astr_set(&str, "?");
break;
......
research = research_get(client_player());
upkeep = client_player()->client.tech_upkeep;
if (NULL == client.conn.playing || (ours == 0 && theirs == 0
&& upkeep == 0)) {
if (client.conn.playing == nullptr || (ours == 0 && theirs == 0
&& upkeep == 0)) {
return _("Progress: no research");
}
......
} else {
int total = research->client.researching_cost;
int done = research->bulbs_researched;
int perturn = get_bulbs_per_turn(NULL, NULL, NULL);
int perturn = get_bulbs_per_turn(nullptr, nullptr, nullptr);
int turns;
if ((turns = turns_to_research_done(research, perturn)) >= 0) {
......
int steps = research_goal_unknown_techs(research, goal);
int bulbs_needed = research_goal_bulbs_required(research, goal);
int turns;
int perturn = get_bulbs_per_turn(NULL, NULL, NULL);
int perturn = get_bulbs_per_turn(nullptr, nullptr, nullptr);
static struct astring str = ASTRING_INIT;
struct astring buf1 = ASTRING_INIT,
buf2 = ASTRING_INIT,
......
astr_clear(&str);
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
astr_add_line(&str, _("Population: %s"),
population_to_text(civ_population(client.conn.playing)));
}
astr_add_line(&str, _("Year: %s (T%d)"),
calendar_text(), game.info.turn);
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
astr_add_line(&str, _("Gold: %d (%+d)"),
client.conn.playing->economic.gold,
player_get_expected_income(client.conn.playing));
......
astr_clear(&str);
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
astr_add_line(&str, _("%s People"),
population_to_text(civ_population(client.conn.playing)));
}
astr_add_line(&str, _("Year: %s"), calendar_text());
astr_add_line(&str, _("Turn: %d"), game.info.turn);
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
const struct research *presearch = research_get(client_player());
int perturn = get_bulbs_per_turn(NULL, NULL, NULL);
int perturn = get_bulbs_per_turn(nullptr, nullptr, nullptr);
int upkeep = client_player()->client.tech_upkeep;
astr_add_line(&str, _("Gold: %d"),
......
astr_add_line(&str, _("Researching %s: %s"),
research_advance_name_translation(presearch,
presearch->researching),
get_science_target_text(NULL));
get_science_target_text(nullptr));
/* perturn is defined as: (bulbs produced) - upkeep */
if (game.info.tech_upkeep_style != TECH_UPKEEP_NONE) {
astr_add_line(&str, _("Bulbs per turn: %d - %d = %d"), perturn + upkeep,
......
astr_add_line(&str, _("Nuclear winter deactivated."));
}
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
astr_add_line(&str, _("Government: %s"),
government_name_for_player(client.conn.playing));
}
......
if (game.info.citizen_nationality) {
struct player *nationality = unit_nationality(punit);
/* Line 5, nationality text */
if (nationality != NULL && owner != nationality) {
/* Line 5, Nationality text */
if (nationality != nullptr && owner != nationality) {
/* TRANS: Nationality of the people comprising a unit, if
* different from owner. */
astr_add_line(&str, _("%s people"),
......
types_count[utype_index(unit_type_get(punit))]++;
} unit_list_iterate_end;
top[0] = top[1] = top[2] = NULL;
top[0] = top[1] = top[2] = nullptr;
unit_type_iterate(utype) {
if (!top[2]
|| types_count[utype_index(top[2])] < types_count[utype_index(utype)]) {
......
astr_add_line(&str, _("Shows your progress in "
"researching the current technology."));
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
struct research *research = research_get(client_player());
if (research->researching == A_UNSET) {
astr_add_line(&str, _("No research target."));
} else {
int turns;
int perturn = get_bulbs_per_turn(NULL, NULL, NULL);
int perturn = get_bulbs_per_turn(nullptr, nullptr, nullptr);
struct astring buf1 = ASTRING_INIT, buf2 = ASTRING_INIT;
if ((turns = turns_to_research_done(research, perturn)) >= 0) {
......
astr_add_line(&str, _("Shows your current government:"));
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
astr_add_line(&str, "%s",
government_name_for_player(client.conn.playing));
}
......
/************************************************************************//**
Returns a description of the given spaceship. If there is no spaceship
(pship is NULL) then text with dummy values is returned.
(pship is nullptr) then text with dummy values is returned.
Not re-entrant
****************************************************************************/
......
astr_add_line(&str, "%s", report_name);
if (pplayer != NULL) {
if (pplayer != nullptr) {
char buf[4 * MAX_LEN_NAME];
/* TRANS: <nation adjective> <government name>.
......
if (!action_prob_possible(prob)) {
/* No info since impossible. */
return NULL;
return nullptr;
}
fc_assert_ret_val((action_get_target_kind(paction) != ATK_CITY
|| target_city != NULL),
NULL);
|| target_city != nullptr),
nullptr);
if (action_has_result(paction, ACTRES_TRADE_ROUTE)) {
bool estimated = FALSE;
......
}
} else {
/* No info to add. */
return NULL;
return nullptr;
}
} else if ((action_has_result(paction, ACTRES_HELP_WONDER)
|| action_has_result(paction, ACTRES_DISBAND_UNIT_RECOVER))
......
astr_set(&custom, _("%d remaining"), cost - target_city->shield_stock);
} else {
/* No info to add. */
return NULL;
return nullptr;
}
return astr_str(&custom);
......
struct effect_list *plist = effect_list_new();
static struct astring str = ASTRING_INIT;
get_city_bonus_effects(plist, pcity, NULL, EFT_MAKE_CONTENT);
get_city_bonus_effects(plist, pcity, nullptr, EFT_MAKE_CONTENT);
if (0 < effect_list_size(plist)) {
struct astring effects = ASTRING_INIT;
......
struct effect_list *plist = effect_list_new();
static struct astring str = ASTRING_INIT;
get_city_bonus_effects(plist, pcity, NULL, EFT_MAKE_HAPPY);
get_city_bonus_effects(plist, pcity, NULL, EFT_FORCE_CONTENT);
get_city_bonus_effects(plist, pcity, NULL, EFT_NO_UNHAPPY);
get_city_bonus_effects(plist, pcity, nullptr, EFT_MAKE_HAPPY);
get_city_bonus_effects(plist, pcity, nullptr, EFT_FORCE_CONTENT);
get_city_bonus_effects(plist, pcity, nullptr, EFT_NO_UNHAPPY);
if (0 < effect_list_size(plist)) {
struct astring effects = ASTRING_INIT;
......
int segments = 0;
if (uni->kind == VUT_UTYPE) {
if (uni->value.utype->helptext != NULL) {
if (uni->value.utype->helptext != nullptr) {
strvec_iterate(uni->value.utype->helptext, text) {
if (segments++) {
cat_snprintf(buf, bufsize, "\n\n");
......
} else {
fc_assert(uni->kind == VUT_IMPROVEMENT);
if (uni->value.building->helptext != NULL) {
if (uni->value.building->helptext != nullptr) {
strvec_iterate(uni->value.building->helptext, text) {
if (segments++) {
cat_snprintf(buf, bufsize, "\n\n");
......
static char buf[1024];
char *relation;
if (client.conn.playing != NULL) {
if (client.conn.playing != nullptr) {
if (pplayer == client.conn.playing) {
relation = _(" (us)");
} else if (pplayers_allied(pplayer, client.conn.playing)) {
    (1-1/1)