Project

General

Profile

Feature #1749 ยป 0037-tech.-ch-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 11/19/2025 02:28 AM

View differences:

common/tech.c
if (game.control.num_tech_types > 0) {
return &advances[game.control.num_tech_types - 1];
}
return NULL;
return nullptr;
}
/**********************************************************************//**
......
**************************************************************************/
Tech_type_id advance_index(const struct advance *padvance)
{
fc_assert_ret_val(NULL != padvance, -1);
fc_assert_ret_val(padvance != nullptr, -1);
return padvance - advances;
}
......
**************************************************************************/
Tech_type_id advance_number(const struct advance *padvance)
{
fc_assert_ret_val(NULL != padvance, -1);
fc_assert_ret_val(padvance != nullptr, -1);
return padvance->item_number;
}
......
if (atype != A_FUTURE
&& (atype < 0 || atype >= game.control.num_tech_types)) {
/* This isn't an error; some callers depend on it. */
return NULL;
return nullptr;
}
return &advances[atype];
......
struct advance *advance_requires(const struct advance *padvance,
enum tech_req require)
{
fc_assert_ret_val(require >= 0 && require < AR_SIZE, NULL);
fc_assert_ret_val(NULL != padvance, NULL);
fc_assert_ret_val(require >= 0 && require < AR_SIZE, nullptr);
fc_assert_ret_val(padvance != nullptr, nullptr);
return padvance->require[require];
}
/**********************************************************************//**
Returns pointer when the advance "exists" in this game, returns NULL
Returns pointer when the advance "exists" in this game, returns nullptr
otherwise.
A tech doesn't exist if it has been flagged as removed by setting its
require values to A_NEVER. Note that this function returns NULL if either
of req values is A_NEVER, rather than both, to be on the safe side.
require values to A_NEVER. Note that this function returns nullptr
if either of req values is A_NEVER, rather than both, to be on
the safe side.
**************************************************************************/
struct advance *valid_advance(struct advance *padvance)
{
if (padvance == NULL) {
return NULL;
if (padvance == nullptr) {
return nullptr;
}
if (padvance->item_number == A_FUTURE) {
......
if (A_NEVER == padvance->require[AR_ONE]
|| A_NEVER == padvance->require[AR_TWO]) {
return NULL;
return nullptr;
}
return padvance;
......
/**********************************************************************//**
Returns pointer when the advance "exists" in this game,
returns NULL otherwise.
returns nullptr otherwise.
In addition to valid_advance(), tests for id is out of range.
**************************************************************************/
......
/**********************************************************************//**
Does a linear search of advances[].name.translated
Returns NULL when none match.
Returns nullptr when none match.
**************************************************************************/
struct advance *advance_by_translated_name(const char *name)
{
......
}
} advance_iterate_all_end;
return NULL;
return nullptr;
}
/**********************************************************************//**
Does a linear search of advances[].name.vernacular
Returns NULL when none match.
Returns nullptr when none match.
**************************************************************************/
struct advance *advance_by_rule_name(const char *name)
{
......
}
} advance_iterate_all_end;
return NULL;
return nullptr;
}
/**********************************************************************//**
......
}
/* Class cost */
if (padvance->tclass != NULL) {
if (padvance->tclass != nullptr) {
padvance->cost = padvance->cost * padvance->tclass->cost_pct / 100;
}
} advance_iterate_end;
......
struct tech_class *tech_class_by_number(const int idx)
{
if (idx < 0 || idx >= game.control.num_tech_classes) {
return NULL;
return nullptr;
}
return &tech_classes[idx];
......
/**********************************************************************//**
Does a linear search of tech_classes[].name.vernacular
Returns NULL when none match.
Returns nullptr when none match.
**************************************************************************/
struct tech_class *tech_class_by_rule_name(const char *name)
{
......
}
}
return NULL;
return nullptr;
}
/**********************************************************************//**
......
fc_assert_ret(id >= TECH_USER_1 && id <= TECH_USER_LAST);
if (user_tech_flags[tfid].name != NULL) {
if (user_tech_flags[tfid].name != nullptr) {
FC_FREE(user_tech_flags[tfid].name);
user_tech_flags[tfid].name = NULL;
user_tech_flags[tfid].name = nullptr;
}
if (name && name[0] != '\0') {
user_tech_flags[tfid].name = fc_strdup(name);
}
if (user_tech_flags[tfid].helptxt != NULL) {
if (user_tech_flags[tfid].helptxt != nullptr) {
FC_FREE(user_tech_flags[tfid].helptxt);
user_tech_flags[tfid].helptxt = NULL;
user_tech_flags[tfid].helptxt = nullptr;
}
if (helptxt && helptxt[0] != '\0') {
......
const char *tech_flag_id_name_cb(enum tech_flag_id flag)
{
if (flag < TECH_USER_1 || flag > TECH_USER_LAST) {
return NULL;
return nullptr;
}
return user_tech_flags[flag-TECH_USER_1].name;
......
memset(advances, 0, sizeof(advances));
for (i = 0; i < ARRAY_SIZE(advances); i++) {
advances[i].item_number = i;
advances[i].ruledit_dlg = NULL;
advances[i].ruledit_dlg = nullptr;
advances[i].cost = -1;
advances[i].inherited_root_req = FALSE;
advances[i].tclass = 0;
......
/* Initialize dummy tech A_NONE */
/* TRANS: "None" tech */
name_set(&a_none->name, NULL, N_("?tech:None"));
name_set(&a_none->name, nullptr, N_("?tech:None"));
a_none->require[AR_ONE] = a_none;
a_none->require[AR_TWO] = a_none;
a_none->require[AR_ROOT] = A_NEVER;
name_set(&a_future->name, NULL, "Future");
name_set(&a_future->name, nullptr, "Future");
a_future->require[AR_ONE] = A_NEVER;
a_future->require[AR_TWO] = A_NEVER;
a_future->require[AR_ROOT] = A_NEVER;
......
{
struct advance *p = &advances[tech];
if (NULL != p->helptext) {
if (p->helptext != nullptr) {
strvec_destroy(p->helptext);
p->helptext = NULL;
p->helptext = nullptr;
}
if (p->bonus_message) {
free(p->bonus_message);
p->bonus_message = NULL;
p->bonus_message = nullptr;
}
}
......
for (req = AR_ONE; req < AR_SIZE; req++) {
preq = valid_advance(advance_requires(padvance, req));
if (NULL != preq
if (preq != nullptr
&& A_NONE != advance_number(preq)
&& !BV_ISSET(iter->done, advance_number(preq))) {
BV_SET(iter->done, advance_number(preq));
......
const struct advance *preq
= valid_advance(advance_requires(padvance, req));
if (NULL != preq
if (preq != nullptr
&& A_NONE != advance_number(preq)
&& !BV_ISSET(iter->done, advance_number(preq))) {
common/tech.h
#define A_UNSET (A_LAST + 2)
#define A_UNKNOWN (A_LAST + 3)
#define A_NEVER (NULL)
#define A_NEVER (nullptr)
/*
A_NONE is the root tech. All players always know this tech. It is
......
/* Ancillary routines */
Tech_type_id advance_required(const Tech_type_id tech,
enum tech_req require);
enum tech_req require);
struct advance *advance_requires(const struct advance *padvance,
enum tech_req require);
enum tech_req require);
bool techs_have_fixed_costs(void);
......
#define advance_iterate_base(_start, _p) \
{ \
struct advance *_p = advance_by_number(_start); \
if (NULL != _p) { \
if (_p != nullptr) { \
for (; _p <= advance_array_last(); _p++) {
#define advance_iterate_base_end \
    (1-1/1)