Project

General

Profile

Feature #1829 ยป 0048-style.-ch-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 12/20/2025 12:10 PM

View differences:

common/style.c
#include "style.h"
static struct nation_style *styles = NULL;
static struct nation_style *styles = nullptr;
static struct music_style *music_styles = NULL;
static struct music_style *music_styles = nullptr;
/**********************************************************************//**
Initialise styles structures.
......
**************************************************************************/
void styles_free(void)
{
FC_FREE(styles);
styles = NULL;
free(styles);
styles = nullptr;
}
/**********************************************************************//**
......
**************************************************************************/
int style_number(const struct nation_style *pstyle)
{
fc_assert_ret_val(NULL != pstyle, -1);
fc_assert_ret_val(pstyle != nullptr, -1);
return pstyle->id;
}
......
**************************************************************************/
int style_index(const struct nation_style *pstyle)
{
fc_assert_ret_val(NULL != pstyle, -1);
fc_assert_ret_val(pstyle != nullptr, -1);
return pstyle - styles;
}
......
**************************************************************************/
struct nation_style *style_by_number(int id)
{
fc_assert_ret_val(id >= 0 && id < game.control.num_styles, NULL);
fc_assert_ret_val(id >= 0 && id < game.control.num_styles, nullptr);
return &styles[id];
}
......
}
/**********************************************************************//**
Returns style matching rule name or NULL if there is no style
Returns style matching rule name or nullptr if there is no style
with such name.
**************************************************************************/
struct nation_style *style_by_rule_name(const char *name)
......
}
} styles_iterate_end;
return NULL;
return nullptr;
}
/**********************************************************************//**
......
requirement_vector_free(&(pmus->reqs));
} music_styles_iterate_end;
FC_FREE(music_styles);
music_styles = NULL;
free(music_styles);
music_styles = nullptr;
}
/**********************************************************************//**
......
**************************************************************************/
int music_style_number(const struct music_style *pms)
{
fc_assert_ret_val(NULL != pms, -1);
fc_assert_ret_val(pms != nullptr, -1);
return pms->id;
}
......
**************************************************************************/
struct music_style *music_style_by_number(int id)
{
fc_assert_ret_val(id >= 0 && id < game.control.num_music_styles, NULL);
fc_assert_ret_val(id >= 0 && id < game.control.num_music_styles, nullptr);
if (music_styles == NULL) {
return NULL;
if (music_styles == nullptr) {
return nullptr;
}
return &music_styles[id];
......
**************************************************************************/
struct music_style *player_music_style(struct player *plr)
{
struct music_style *best = NULL;
struct music_style *best = nullptr;
const struct req_context plr_context = { .player = plr };
music_styles_iterate(pms) {
if (are_reqs_active(&plr_context, NULL, &pms->reqs, RPT_CERTAIN)) {
if (are_reqs_active(&plr_context, nullptr, &pms->reqs, RPT_CERTAIN)) {
best = pms;
}
} music_styles_iterate_end;
......
};
for (i = game.control.num_city_styles - 1; i >= 0; i--) {
if (are_reqs_active(&context, NULL,
if (are_reqs_active(&context, nullptr,
&city_styles[i].reqs, RPT_CERTAIN)) {
return i;
}
common/style.h
int _i_; \
for (_i_ = 0; _i_ < game.control.num_music_styles; _i_++) { \
struct music_style *_p = music_style_by_number(_i_); \
if (_p != NULL) {
if (_p != nullptr) {
#define music_styles_iterate_end \
} \
    (1-1/1)