Project

General

Profile

Feature #1981 ยป 0030-traderoutes.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 04/03/2026 08:04 PM

View differences:

common/traderoutes.c
*************************************************************************/
const char *trade_route_type_name(enum trade_route_type type)
{
fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, NULL);
fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, nullptr);
return trade_route_type_names[type];
}
......
*************************************************************************/
const char *trade_route_cancelling_type_name(enum trade_route_illegal_cancelling type)
{
fc_assert_ret_val(type >= TRI_ACTIVE && type < TRI_LAST, NULL);
fc_assert_ret_val(type >= TRI_ACTIVE && type < TRI_LAST, nullptr);
return trade_route_cancelling_type_names[type];
}
......
struct trade_route_settings *
trade_route_settings_by_type(enum trade_route_type type)
{
fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, NULL);
fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, nullptr);
return &trtss[type];
}
......
/* Return values. */
for (i = j = 0; i < num; i++) {
j += sorted[i]->value;
if (NULL != would_remove) {
if (would_remove != nullptr) {
trade_route_list_append(would_remove, sorted[i]);
}
}
......
if (city_num_trade_routes(pc1) >= maxpc1) {
trade = trade_base_between_cities(pc1, pc2);
/* Can we replace trade route? */
if (city_trade_removable(pc1, priority, NULL) >= trade) {
if (city_trade_removable(pc1, priority, nullptr) >= trade) {
return FALSE;
}
}
......
trade = trade_base_between_cities(pc1, pc2);
}
/* Can we replace trade route? */
if (city_trade_removable(pc2, priority, NULL) >= trade) {
if (city_trade_removable(pc2, priority, nullptr) >= trade) {
return FALSE;
}
}
......
}
/*********************************************************************//**
Return the trade that exists between these cities, assuming they have a
trade route.
Return the trade that exists between these cities, assuming they have
a trade route.
*************************************************************************/
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
{
int bonus = 0;
if (NULL == pc1 || NULL == pc1->tile || NULL == pc2 || NULL == pc2->tile) {
if (pc1 == nullptr || pc1->tile == nullptr
|| pc2 == nullptr || pc2->tile == nullptr) {
return 0;
}
......
} else if (game.info.trade_revenue_style == TRS_SIMPLE) {
/* Simple revenue style */
bonus = (pc1->citizen_base[O_TRADE] + pc2->citizen_base[O_TRADE] + 4)
* 3;
* 3;
}
bonus = bonus
......
Get trade income specific to route's good.
*************************************************************************/
int trade_from_route(const struct city *pc1, const struct trade_route *route,
int base)
int base)
{
int val;
......
bool is_celebrating = base_city_celebrating(pcity);
const struct civ_map *nmap = &(wld.map);
if (pcity->tile == NULL) {
if (pcity->tile == nullptr) {
return 0;
}
city_map_iterate(radius_sq, cindex, cx, cy) {
struct tile *ptile = city_map_to_tile(nmap, pcity->tile, radius_sq, cx, cy);
if (ptile == NULL) {
if (ptile == nullptr) {
continue;
}
......
If you change this calculation remember to also update its duplication
in dai_choose_trade_route()
pgood can be NULL for ignoring good's onetime_pct.
pgood can be nullptr for ignoring good's onetime_pct.
*************************************************************************/
int get_caravan_enter_city_trade_bonus(const struct city *pc1,
const struct city *pc2,
......
+ max_trade_prod(pc1) + max_trade_prod(pc2)) * 2, 2);
}
if (pgood != NULL) {
if (pgood != nullptr) {
tb = tb * pgood->onetime_pct / 100;
}
/* Trade_revenue_bonus increases revenue by power of 2 in milimes */
bonus = get_target_bonus_effects(NULL,
bonus = get_target_bonus_effects(nullptr,
&(const struct req_context) {
.player = city_owner(pc1),
.city = pc1,
......
requirement_vector_init(&(goods[i].reqs));
goods[i].ruledit_disabled = FALSE;
goods[i].helptext = NULL;
goods[i].helptext = nullptr;
}
}
......
for (i = 0; i < MAX_GOODS_TYPES; i++) {
requirement_vector_free(&(goods[i].reqs));
if (NULL != goods[i].helptext) {
if (goods[i].helptext != nullptr) {
strvec_destroy(goods[i].helptext);
goods[i].helptext = NULL;
goods[i].helptext = nullptr;
}
}
}
......
*************************************************************************/
Goods_type_id goods_number(const struct goods_type *pgood)
{
fc_assert_ret_val(NULL != pgood, -1);
fc_assert_ret_val(pgood != nullptr, -1);
return pgood->id;
}
......
*************************************************************************/
Goods_type_id goods_index(const struct goods_type *pgood)
{
fc_assert_ret_val(NULL != pgood, -1);
fc_assert_ret_val(pgood != nullptr, -1);
return pgood - goods;
}
......
*************************************************************************/
struct goods_type *goods_by_number(Goods_type_id id)
{
fc_assert_ret_val(id >= 0 && id < game.control.num_goods_types, NULL);
fc_assert_ret_val(id >= 0 && id < game.control.num_goods_types, nullptr);
return &goods[id];
}
......
}
/*********************************************************************//**
Returns goods type matching rule name or NULL if there is no goods type
with such name.
Returns goods type matching rule name or nullptr if there is no
goods type with such name.
*************************************************************************/
struct goods_type *goods_by_rule_name(const char *name)
{
const char *qs;
if (name == NULL) {
return NULL;
if (name == nullptr) {
return nullptr;
}
qs = Qn_(name);
......
}
} goods_type_iterate_end;
return NULL;
return nullptr;
}
/*********************************************************************//**
Returns goods type matching the translated name, or NULL if there is no
goods type with that name.
Returns goods type matching the translated name, or nullptr if there is
no goods type with that name.
*************************************************************************/
struct goods_type *goods_by_translated_name(const char *name)
{
......
}
} goods_type_iterate_end;
return NULL;
return nullptr;
}
/*********************************************************************//**
......
.city = pcity,
.tile = city_tile(pcity),
.unit = punit,
.unittype = punit ? unit_type_get(punit) : NULL,
.unittype = punit ? unit_type_get(punit) : nullptr,
},
NULL,
nullptr,
&pgood->reqs, RPT_CERTAIN);
}
......
} goods_type_iterate_end;
if (i == 0) {
return NULL;
return nullptr;
}
return potential[fc_rand(i)];
    (1-1/1)