Project

General

Profile

Feature #2309 ยป 0075-server-city-.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 10/02/2026 05:56 PM

View differences:

server/cityhand.c
struct unit *punit = player_unit_by_number(pplayer, unit_id);
const struct civ_map *nmap = &(wld.map);
if (NULL == punit) {
if (punit == nullptr) {
/* Probably died or bribed. */
log_verbose("handle_city_name_suggestion_req() invalid unit %d",
unit_id);
......
}
if (action_prob_possible(action_prob_vs_tile(nmap, punit, ACTION_FOUND_CITY,
unit_tile(punit), NULL))) {
unit_tile(punit), nullptr))) {
log_verbose("handle_city_name_suggest_req(unit_pos (%d, %d))",
TILE_XY(unit_tile(punit)));
dlsend_packet_city_name_suggestion_info(pplayer->connections, unit_id,
......
"cannot build there.", TILE_XY(unit_tile(punit)));
illegal_action_msg(pplayer, E_BAD_COMMAND, punit, ACTION_FOUND_CITY,
unit_tile(punit), NULL, NULL);
unit_tile(punit), nullptr, nullptr);
}
/**********************************************************************//**
Handle request to change specialist type
**************************************************************************/
void handle_city_change_specialist(struct player *pplayer, int city_id,
Specialist_type_id from,
Specialist_type_id to)
Specialist_type_id from,
Specialist_type_id to)
{
struct city *pcity = player_city_by_number(pplayer, city_id);
......
struct tile *ptile = index_to_tile(&(wld.map), tile_id);
struct city *pcity = player_city_by_number(pplayer, city_id);
if (NULL == pcity) {
if (pcity == nullptr) {
/* Probably lost. */
log_verbose("handle_city_make_specialist() bad city number %d.",
city_id);
return;
}
if (NULL == ptile) {
if (ptile == nullptr) {
log_error("handle_city_make_specialist() bad tile number %d.", tile_id);
return;
}
......
struct tile *ptile = index_to_tile(&(wld.map), tile_id);
struct city *pcity = player_city_by_number(pplayer, city_id);
if (NULL == pcity) {
if (pcity == nullptr) {
/* Probably lost. */
log_verbose("handle_city_make_worker() bad city number %d.",city_id);
return;
}
if (NULL == ptile) {
if (ptile == nullptr) {
log_error("handle_city_make_worker() bad tile number %d.", tile_id);
return;
}
......
input before passing to this function if it comes from untrusted source.
**************************************************************************/
void really_handle_city_sell(struct player *pplayer, struct city *pcity,
struct impr_type *pimprove)
struct impr_type *pimprove)
{
enum test_result sell_result;
int price;
......
if (sell_result == TR_ALREADY_SOLD) {
notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
_("You have already sold something here this turn."));
_("You have already sold something here this turn."));
return;
}
......
city_refresh(pcity);
/* If we sold the walls the other players should see it */
send_city_info(NULL, pcity);
send_city_info(nullptr, pcity);
send_player_info_c(pplayer, pplayer->connections);
}
......
if (pcity->did_buy) {
notify_player(pplayer, pcity->tile, E_BAD_COMMAND, ftc_server,
_("You have already bought this turn."));
_("You have already bought this turn."));
return;
}
......
* fully well add the missing shields there. */
pcity->disbanded_shields += total - pcity->shield_stock;
pcity->shield_stock = total; /* AI wants this -- Syela */
pcity->did_buy = TRUE; /* !PS: no need to set buy flag otherwise */
pcity->did_buy = TRUE; /* !PS: No need to set buy flag otherwise */
}
city_refresh(pcity);
......
struct city *pcity = player_city_by_number(pplayer, city_id);
char message[1024];
if (pcity == NULL) {
if (pcity == nullptr) {
return;
}
......
city_name_set(pcity, name);
city_refresh(pcity);
send_city_info(NULL, pcity);
send_city_info(nullptr, pcity);
}
/**********************************************************************//**
......
given city be changed.
**************************************************************************/
void handle_city_options_req(struct player *pplayer, int city_id,
bv_city_options options,
bv_city_options options,
enum city_wl_cancel_behavior wlcb)
{
struct city *pcity = player_city_by_number(pplayer, city_id);
if (!pcity) {
if (pcity == nullptr) {
return;
}
......
{
struct city *pcity = player_city_by_number(pplayer, packet->id);
if (NULL != pcity) {
if (pcity != nullptr) {
city_rally_point_receive(packet, pcity);
send_city_info(pplayer, pcity);
}
......
#ifdef FREECIV_WEB
struct city *pcity = player_city_by_number(pplayer, id);
if (pcity != NULL) {
if (pcity->cm_parameter == NULL) {
if (pcity != nullptr) {
if (pcity->cm_parameter == nullptr) {
pcity->cm_parameter = fc_calloc(1, sizeof(struct cm_parameter));
}
......
{
struct city *pcity = player_city_by_number(pplayer, id);
if (pcity != NULL && pcity->cm_parameter != NULL) {
if (pcity != nullptr && pcity->cm_parameter != nullptr) {
free(pcity->cm_parameter);
pcity->cm_parameter = NULL;
pcity->cm_parameter = nullptr;
send_city_info(pplayer, pcity);
}
}
server/citytools.c
}
} conn_list_iterate_end;
if (old_vision != NULL) {
if (old_vision != nullptr) {
vision_clear_sight(old_vision);
vision_free(old_vision);
}
......
packet->id = pdcity->identity;
packet->owner = player_number(vision_site_owner(pdcity));
if (pdcity->original != NULL) {
if (pdcity->original != nullptr) {
packet->original = player_number(pdcity->original);
} else {
packet->original = MAX_NUM_PLAYER_SLOTS;
server/cityturn.c
}
}
punit = city_create_unit(pcity, utype, NULL);
punit = city_create_unit(pcity, utype, nullptr);
/* "unit_built" script handler may have destroyed city. If so, we
* assume something sensible happened to its units, and that the
......
city_tile_link(pcity), utype_name_translation(utype));
}
script_server_signal_emit("city_destroyed", pcity, pcity->owner, NULL);
script_server_signal_emit("city_destroyed", pcity, pcity->owner, nullptr);
if (!city_exist(saved_id)) {
/* Already removed during the script */
    (1-1/1)