Project

General

Profile

Feature #2025 ยป 0036-movement.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 05/14/2026 04:23 AM

View differences:

common/movement.c
****************************************************************************/
int unit_move_rate(const struct unit *punit)
{
fc_assert_ret_val(NULL != punit, 0);
fc_assert_ret_val(punit != nullptr, 0);
return utype_move_rate(unit_type_get(punit), unit_tile(punit),
unit_owner(punit), punit->veteran, punit->hp);
......
/* Unit is subject to terrain movement costs. */
move_cost = 1; /* Arbitrary minimum. */
terrain_type_iterate(pterrain) {
if (is_native_to_class(uclass, pterrain, NULL)
if (is_native_to_class(uclass, pterrain, nullptr)
&& pterrain->movement_cost > move_cost) {
/* Exact movement cost matters only if we can enter
* the tile. */
......
* N.B.: We don't take in account terrain no unit can enter here. */
terrain_type_iterate(pterrain) {
if (BV_ISSET_ANY(pterrain->native_to)
&& !is_native_to_class(uclass, pterrain, NULL)) {
&& !is_native_to_class(uclass, pterrain, nullptr)) {
/* Units that may encounter unsuitable terrain explore less. */
move_cost *= 2;
break;
......
{
struct unit *ptrans = unit_transport_get(punit);
if (ptrans == NULL) {
/* FIXME: Redundant check; if unit is in the tile without transport
if (ptrans == nullptr) {
/* FIXME: Redundant check; if unit is in the tile without transport,
* it's known to be able to exist there. */
return can_unit_exist_at_tile(nmap, punit, unit_tile(punit));
}
......
/* Cities are safe havens except for units in the middle of non-native
* terrain. This can happen if adjacent terrain is changed after unit
* arrived to city. */
if (NULL != tile_city(ptile)
if (tile_city(ptile) != nullptr
&& (uclass_has_flag(utype_class(utype), UCF_BUILD_ANYWHERE)
|| is_native_near_tile(nmap, utype_class(utype), ptile)
|| (1 == game.info.citymindist
&& is_city_channel_tile(nmap, utype_class(utype), ptile, NULL)))) {
&& is_city_channel_tile(nmap, utype_class(utype), ptile, nullptr)))) {
return TRUE;
}
......
return TRUE;
}
if (extras != NULL) {
if (extras != nullptr) {
extra_type_list_iterate(punitclass->cache.native_tile_extras, pextra) {
if (BV_ISSET(*extras, extra_index(pextra))) {
return TRUE;
......
{
const struct road_type *proad;
if (is_native_to_class(punitclass, tile_terrain(dst_tile), NULL)) {
if (is_native_to_class(punitclass, tile_terrain(dst_tile), nullptr)) {
/* We aren't using extras to make the destination native. */
return TRUE;
} else if (!is_native_tile_to_class(punitclass, src_tile)) {
/* Disembarking or leaving port, so ignore road connectivity. */
return TRUE;
} else if (is_native_to_class(punitclass, tile_terrain(src_tile), NULL)) {
} else if (is_native_to_class(punitclass, tile_terrain(src_tile), nullptr)) {
/* Native source terrain depends entirely on destination tile nativity. */
return is_native_tile_to_class(punitclass, dst_tile);
}
......
return (MR_OK == unit_move_to_tile_test(nmap, punit,
punit->activity, unit_tile(punit),
dst_tile, igzoc,
enter_transport, NULL,
enter_transport, nullptr,
enter_enemy_city));
}
......
{
return (MR_OK == unit_teleport_to_tile_test(nmap, punit, punit->activity,
unit_tile(punit), dst_tile,
enter_transport, NULL,
enter_transport, nullptr,
enter_enemy_city));
}
......
}
/* 7) */
if (embark_to != NULL) {
if (embark_to != nullptr) {
if (!could_unit_load(punit, embark_to)) {
return MR_NO_TRANSPORTER_CAPACITY;
}
......
}
/* 3) */
if (embark_to != NULL) {
if (embark_to != nullptr) {
if (!could_unit_load(punit, embark_to)) {
return MR_NO_TRANSPORTER_CAPACITY;
}
......
bool can_unit_transport(const struct unit *transporter,
const struct unit *transported)
{
fc_assert_ret_val(transporter != NULL, FALSE);
fc_assert_ret_val(transported != NULL, FALSE);
fc_assert_ret_val(transporter != nullptr, FALSE);
fc_assert_ret_val(transported != nullptr, FALSE);
return can_unit_type_transport(unit_type_get(transporter),
unit_class_get(transported));
......
lowest terms (this might be confusing in some cases).
'prefix' is a string put in front of all numeric output.
'none' is the string to display in place of the integer part if no
movement points (or NULL to just say 0).
movement points (or nullptr to just say 0).
'align' controls whether this is for a fixed-width table, in which case
padding spaces will be included to make all such strings line up when
right-aligned.
......
****************************************************************************/
const char *move_points_text(int mp, bool reduce)
{
return move_points_text_full(mp, reduce, NULL, NULL, FALSE);
return move_points_text_full(mp, reduce, nullptr, nullptr, FALSE);
}
    (1-1/1)