Project

General

Profile

Feature #2123 ยป 0045-packhand.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 08/07/2026 11:37 AM

View differences:

client/packhand.c
struct city_list *cities;
struct player *placeholder;
} invisible = {
.cities = NULL,
.placeholder = NULL
.cities = nullptr,
.placeholder = nullptr
};
static struct {
......
****************************************************************************/
void packhand_free(void)
{
if (NULL != invisible.cities) {
if (invisible.cities != nullptr) {
city_list_iterate(invisible.cities, pcity) {
idex_unregister_city(&wld, pcity);
destroy_city_virtual(pcity);
} city_list_iterate_end;
city_list_destroy(invisible.cities);
invisible.cities = NULL;
invisible.cities = nullptr;
}
if (NULL != invisible.placeholder) {
if (invisible.placeholder != nullptr) {
free(invisible.placeholder);
invisible.placeholder = NULL;
invisible.placeholder = nullptr;
}
}
......
struct city *pcity = game_city_by_number(city_id);
bool need_menus_update;
fc_assert_ret_msg(NULL != pcity, "Bad city %d.", city_id);
fc_assert_ret_msg(pcity != nullptr, "Bad city %d.", city_id);
need_menus_update = (NULL != get_focus_unit_on_tile(city_tile(pcity)));
need_menus_update = (get_focus_unit_on_tile(city_tile(pcity)) != nullptr);
agents_city_remove(pcity);
editgui_notify_object_changed(OBJTYPE_CITY, pcity->id, TRUE);
......
{
struct team_slot *tslot = team_slot_by_number(team_id);
fc_assert_ret(NULL != tslot);
fc_assert_ret(tslot != nullptr);
team_slot_set_defined_name(tslot, team_name);
conn_list_dialog_update();
}
......
audio_play_sound(unit_type_get(punit0)->sound_fight,
unit_type_get(punit0)->sound_fight_alt,
NULL);
nullptr);
audio_play_sound(unit_type_get(punit1)->sound_fight,
unit_type_get(punit1)->sound_fight_alt,
NULL);
nullptr);
if (gui_options.smooth_combat_step_msec > 0) {
decrease_unit_hp_smooth(punit0, hp0, punit1, hp1);
......
punit0->hp = hp0;
punit1->hp = hp1;
set_units_in_combat(NULL, NULL);
set_units_in_combat(nullptr, nullptr);
refresh_unit_mapcanvas(punit0, unit_tile(punit0), TRUE, FALSE);
refresh_unit_mapcanvas(punit1, unit_tile(punit1), TRUE, FALSE);
}
......
bool trade_routes_changed = FALSE;
struct unit_list *pfocus_units = get_units_in_focus();
struct city *pcity = game_city_by_number(packet->id);
struct tile_list *worked_tiles = NULL;
struct tile_list *worked_tiles = nullptr;
struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
struct tile *ptile = NULL;
struct tile *ptile = nullptr;
struct player *powner = player_by_number(packet->owner);
fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
fc_assert_ret_msg(powner != nullptr, "Bad player number %d.", packet->owner);
fc_assert_ret_msg(pcenter != nullptr, "Invalid tile index %d.", packet->tile);
if (!universals_n_is_valid(packet->production_kind)) {
log_error("handle_city_info() bad production_kind %d.",
......
}
}
if (NULL != pcity) {
if (pcity != nullptr) {
ptile = city_tile(pcity);
if (NULL == ptile) {
if (ptile == nullptr) {
/* Invisible worked city */
city_list_remove(invisible.cities, pcity);
city_is_new = TRUE;
......
city_tile_iterate_skip_free_worked(&(wld.map), city_map_radius_sq_get(pcity),
ptile, pworked, _index, _x, _y) {
if (pcity == tile_worked(pworked)) {
if (NULL == worked_tiles) {
if (worked_tiles == nullptr) {
worked_tiles = tile_list_new();
}
tile_list_append(worked_tiles, pworked);
}
} city_tile_iterate_skip_free_worked_end;
client_remove_city(pcity);
pcity = NULL;
pcity = nullptr;
city_has_changed_owner = TRUE;
}
}
if (NULL == pcity) {
if (pcity == nullptr) {
city_is_new = TRUE;
pcity = create_city_virtual(powner, pcenter, packet->name);
pcity->id = packet->id;
......
if (name_changed) {
unit_list_iterate(pfocus_units, pfocus_unit) {
if (pfocus_unit->homecity == pcity->id) {
update_unit_info_label(pfocus_units);
break;
update_unit_info_label(pfocus_units);
break;
}
} unit_list_iterate_end;
}
......
struct city *pcity = game_city_by_number(packet->id);
/* The nationality of the citizens. */
if (pcity != NULL && game.info.citizen_nationality) {
if (pcity != nullptr && game.info.citizen_nationality) {
int i;
citizens_init(pcity);
......
{
struct city *pcity = game_city_by_number(packet->id);
if (pcity != NULL) {
if (pcity != nullptr) {
city_rally_point_receive(packet, pcity);
}
}
......
struct tile_list *worked_tiles,
bool is_new, bool popup, bool investigate)
{
if (NULL != worked_tiles) {
if (worked_tiles != nullptr) {
/* We need to transfer the worked infos because the server will assume
* those infos are kept in our side and won't send to us again. */
tile_list_iterate(worked_tiles, pwork) {
......
players_iterate(pp) {
unit_list_iterate(pp->units, punit) {
if (punit->homecity == pcity->id) {
if (punit->homecity == pcity->id) {
unit_list_prepend(pcity->units_supported, punit);
}
} unit_list_iterate_end;
......
}
if (city_workers_display == pcity) {
city_workers_display = NULL;
city_workers_display = nullptr;
}
if (investigate) {
/* Commit the collected supported and present units. */
if (pcity->client.collecting_info_units_supported != NULL) {
if (pcity->client.collecting_info_units_supported != nullptr) {
/* We got units, let's move the unit lists. */
fc_assert(pcity->client.collecting_info_units_present != NULL);
fc_assert(pcity->client.collecting_info_units_present != nullptr);
unit_list_destroy(pcity->client.info_units_present);
pcity->client.info_units_present =
pcity->client.collecting_info_units_present;
pcity->client.collecting_info_units_present = NULL;
pcity->client.collecting_info_units_present = nullptr;
unit_list_destroy(pcity->client.info_units_supported);
pcity->client.info_units_supported =
pcity->client.collecting_info_units_supported;
pcity->client.collecting_info_units_supported = NULL;
pcity->client.collecting_info_units_supported = nullptr;
} else {
/* We didn't get any unit, let's clear the unit lists. */
fc_assert(pcity->client.collecting_info_units_present == NULL);
fc_assert(pcity->client.collecting_info_units_present == nullptr);
unit_list_clear(pcity->client.info_units_supported);
unit_list_clear(pcity->client.info_units_present);
......
}
if (popup
&& NULL != client.conn.playing
&& client.conn.playing != nullptr
&& is_human(client.conn.playing)
&& can_client_issue_orders()) {
menus_update();
......
struct trade_route *proute;
bool city_changed = FALSE;
if (pcity == NULL) {
if (pcity == nullptr) {
return;
}
proute = trade_route_list_get(pcity->routes, packet->index);
if (proute == NULL) {
if (proute == nullptr) {
fc_assert(trade_route_list_size(pcity->routes) == packet->index);
proute = fc_malloc(sizeof(struct trade_route));
......
bool update_descriptions = FALSE;
struct city *pcity = game_city_by_number(packet->id);
struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
struct tile *ptile = NULL;
struct tile_list *worked_tiles = NULL;
struct tile *ptile = nullptr;
struct tile_list *worked_tiles = nullptr;
struct player *powner = player_by_number(packet->owner);
struct player *original = player_by_number(packet->original);
int radius_sq = game.info.init_city_radius_sq;
fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
fc_assert_ret_msg(powner != nullptr, "Bad player number %d.", packet->owner);
fc_assert_ret_msg(pcenter != nullptr, "Invalid tile index %d.", packet->tile);
if (NULL != pcity) {
if (pcity != nullptr) {
ptile = city_tile(pcity);
if (NULL == ptile) {
if (ptile == nullptr) {
/* Invisible worked city */
city_list_remove(invisible.cities, pcity);
city_is_new = TRUE;
......
city_tile_iterate_skip_free_worked(&(wld.map), city_map_radius_sq_get(pcity), ptile,
pworked, _index, _x, _y) {
if (pcity == tile_worked(pworked)) {
if (NULL == worked_tiles) {
if (worked_tiles == nullptr) {
worked_tiles = tile_list_new();
}
tile_list_append(worked_tiles, pworked);
......
} city_tile_iterate_skip_free_worked_end;
radius_sq = city_map_radius_sq_get(pcity);
client_remove_city(pcity);
pcity = NULL;
pcity = nullptr;
city_has_changed_owner = TRUE;
}
}
if (NULL == pcity) {
if (pcity == nullptr) {
city_is_new = TRUE;
pcity = create_city_virtual(powner, pcenter, packet->name);
pcity->id = packet->id;
......
void handle_worker_task(const struct packet_worker_task *packet)
{
struct city *pcity = game_city_by_number(packet->city_id);
struct worker_task *ptask = NULL;
struct worker_task *ptask = nullptr;
if (pcity == NULL
|| (pcity->owner != client.conn.playing && !client_is_global_observer())) {
if (pcity == nullptr
|| (pcity->owner != client.conn.playing
&& !client_is_global_observer())) {
return;
}
......
}
} worker_task_list_iterate_end;
if (ptask == NULL) {
if (ptask == nullptr) {
if (packet->activity == ACTIVITY_LAST) {
return;
} else {
......
if (packet->activity == ACTIVITY_LAST) {
worker_task_list_remove(pcity->task_reqs, ptask);
free(ptask);
ptask = NULL;
ptask = nullptr;
}
}
if (ptask != NULL) {
if (ptask != nullptr) {
ptask->ptile = index_to_tile(&(wld.map), packet->tile_id);
ptask->act = packet->activity;
if (packet->tgt >= 0) {
ptask->tgt = extra_by_number(packet->tgt);
} else {
ptask->tgt = NULL;
ptask->tgt = nullptr;
}
ptask->want = packet->want;
}
......
log_debug("Bad worker task");
worker_task_list_remove(pcity->task_reqs, ptask);
free(ptask);
ptask = NULL;
ptask = nullptr;
return;
}
......
#if 0
/* This information shouldn't be needed, but if it is this is the only
* way we can get it. */
if (NULL != client.conn.playing) {
turn_gold_difference =
client.conn.playing->economic.gold - last_turn_gold_amount;
if (client.conn.playing != nullptr) {
turn_gold_difference
= client.conn.playing->economic.gold - last_turn_gold_amount;
last_turn_gold_amount = client.conn.playing->economic.gold;
}
#endif
......
link_marks_decrease_turn_counters();
if (gui_options.sound_bell_at_new_turn) {
create_event(NULL, E_TURN_BELL, ftc_client,
create_event(nullptr, E_TURN_BELL, ftc_client,
_("Start of turn %d"), game.info.turn);
}
......
set_server_busy(FALSE);
}
if (NULL != client.conn.playing
if (client.conn.playing != nullptr
&& is_player_phase(client.conn.playing, phase)) {
agents_start_turn();
non_ai_unit_focus = FALSE;
......
const char *sound_tag = get_event_tag(type);
if (sound_tag) {
audio_play_sound(sound_tag, NULL, NULL);
audio_play_sound(sound_tag, nullptr, nullptr);
}
}
......
****************************************************************************/
void handle_page_msg_part(const char *lines)
{
if (page_msg_report.lines != NULL) {
if (page_msg_report.lines != nullptr) {
/* We have already decided to show the message at the time we got
* the header packet. */
fc_strlcat(page_msg_report.lines, lines, page_msg_report.len + 1);
......
free(page_msg_report.caption);
free(page_msg_report.headline);
free(page_msg_report.lines);
page_msg_report.lines = NULL;
page_msg_report.lines = nullptr;
}
}
}
......
bool need_economy_report_update = FALSE;
bool need_units_report_update = FALSE;
bool repaint_unit = FALSE;
bool repaint_city = FALSE; /* regards unit's homecity */
bool repaint_city = FALSE; /* Regards unit's homecity */
struct tile *old_tile = nullptr;
bool check_focus = FALSE; /* conservative focus change */
bool check_focus = FALSE; /* Conservative focus change */
bool moved = FALSE;
bool ret = FALSE;
struct player *owner = unit_owner(packet_unit);
......
|| punit->activity_target == packet_unit->activity_target
|| punit->client.transported_by != packet_unit->client.transported_by
|| punit->client.occupied != packet_unit->client.occupied
|| punit->has_orders != packet_unit->has_orders
|| punit->orders.repeat != packet_unit->orders.repeat
|| punit->orders.vigilant != packet_unit->orders.vigilant
|| punit->orders.index != packet_unit->orders.index) {
|| punit->has_orders != packet_unit->has_orders
|| punit->orders.repeat != packet_unit->orders.repeat
|| punit->orders.vigilant != packet_unit->orders.vigilant
|| punit->orders.index != packet_unit->orders.index) {
/*** Change in activity or activity's target. ***/
......
* But if new activity is Idle, it means user specifically selected
* the unit */
if (unit_is_in_focus(punit)
&& (packet_unit->activity != ACTIVITY_IDLE
|| packet_unit->has_orders)) {
&& (packet_unit->activity != ACTIVITY_IDLE
|| packet_unit->has_orders)) {
check_focus = TRUE;
}
......
/* We cheat by just stealing the packet unit's list. */
if (punit->orders.list) {
free(punit->orders.list);
free(punit->orders.list);
}
punit->orders.list = packet_unit->orders.list;
packet_unit->orders.list = nullptr;
......
struct city *hcity;
if ((hcity = game_city_by_number(punit->homecity))) {
unit_list_remove(hcity->units_supported, punit);
refresh_city_dialog(hcity);
unit_list_remove(hcity->units_supported, punit);
refresh_city_dialog(hcity);
}
punit->homecity = packet_unit->homecity;
if ((hcity = game_city_by_number(punit->homecity))) {
unit_list_prepend(hcity->units_supported, punit);
repaint_city = TRUE;
unit_list_prepend(hcity->units_supported, punit);
repaint_city = TRUE;
}
/* This can change total upkeep figures */
......
punit->utype = unit_type_get(packet_unit);
repaint_unit = TRUE;
repaint_city = TRUE;
if (ccity != NULL && (ccity->id != punit->homecity)) {
refresh_city_dialog(ccity);
if (ccity != nullptr && (ccity->id != punit->homecity)) {
refresh_city_dialog(ccity);
}
if (unit_is_in_focus(punit)) {
/* Update the orders menu -- the unit might have new abilities */
......
do_move_unit(punit, packet_unit);
if (ccity != nullptr) {
if (can_player_see_units_in_city(plr, ccity)) {
/* Unit moved out of a city - update the occupied status. */
bool new_occupied =
(unit_list_size(ccity->tile->units) > 0);
if (can_player_see_units_in_city(plr, ccity)) {
/* Unit moved out of a city - update the occupied status. */
bool new_occupied
= (unit_list_size(ccity->tile->units) > 0);
if (ccity->client.occupied != new_occupied) {
ccity->client.occupied = new_occupied;
......
/* We repaint the city if the unit itself needs repainting or if
* there is a special city-only redrawing to be done. */
if ((pcity = game_city_by_number(punit->homecity))) {
refresh_city_dialog(pcity);
refresh_city_dialog(pcity);
}
if (repaint_unit && tile_city(unit_tile(punit))
&& tile_city(unit_tile(punit)) != pcity) {
......
if (punit->client.occupied) {
unit_list_iterate(unit_tile(punit)->units, aunit) {
if (aunit->client.transported_by == punit->id) {
fc_assert(aunit->transporter == NULL);
fc_assert(aunit->transporter == nullptr);
unit_transport_load(aunit, punit, TRUE);
}
} unit_list_iterate_end;
......
need_units_report_update = TRUE;
} /*** End of Create new unit ***/
fc_assert_ret_val(punit != NULL, ret);
fc_assert_ret_val(punit != nullptr, ret);
/* Check if we have to load the unit on a transporter. */
if (punit->client.transported_by != -1) {
......
/* Start collecting supported and present units. */
/* Ensure we are not already in an investigate cycle. */
fc_assert(pcity->client.collecting_info_units_supported == NULL);
fc_assert(pcity->client.collecting_info_units_present == NULL);
pcity->client.collecting_info_units_supported =
unit_list_new_full(unit_virtual_destroy);
pcity->client.collecting_info_units_present =
unit_list_new_full(unit_virtual_destroy);
fc_assert(pcity->client.collecting_info_units_supported == nullptr);
fc_assert(pcity->client.collecting_info_units_present == nullptr);
pcity->client.collecting_info_units_supported
= unit_list_new_full(unit_virtual_destroy);
pcity->client.collecting_info_units_present
= unit_list_new_full(unit_virtual_destroy);
}
/************************************************************************//**
......
punit = unpackage_short_unit(packet);
if (punit != nullptr) {
if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
fc_assert(pcity->client.collecting_info_units_supported != NULL);
fc_assert(pcity->client.collecting_info_units_supported != nullptr);
unit_list_append(pcity->client.collecting_info_units_supported, punit);
} else {
fc_assert(packet->packet_use == UNIT_INFO_CITY_PRESENT);
fc_assert(pcity->client.collecting_info_units_present != NULL);
fc_assert(pcity->client.collecting_info_units_present != nullptr);
unit_list_append(pcity->client.collecting_info_units_present, punit);
}
}
......
wld.map.wrap_id = wrap_id;
if (forced_tileset_name[0] == '\0'
&& (tileset_map_topo_compatible(topology_id, tileset, NULL)
&& (tileset_map_topo_compatible(topology_id, tileset, nullptr)
== TOPO_INCOMP_HARD
|| strcmp(tileset_basename(tileset), game.control.preferred_tileset))) {
const char *ts_to_load;
ts_to_load = tileset_name_for_topology(topology_id);
if (ts_to_load != NULL && ts_to_load[0] != '\0' && strcmp(tileset_basename(tileset), ts_to_load)) {
if (ts_to_load != nullptr && ts_to_load[0] != '\0'
&& strcmp(tileset_basename(tileset), ts_to_load)) {
tilespec_reread_frozen_refresh(ts_to_load);
}
}
......
game.info._count = _maximum; \
}
VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
#undef VALIDATE
game.default_government =
......
government_by_number(game.info.government_during_revolution_id);
boot_help = (can_client_change_view()
&& game.info.victory_conditions != pinfo->victory_conditions);
&& game.info.victory_conditions != pinfo->victory_conditions);
if (boot_help) {
boot_help_texts(); /* reboot, after setting game.spacerace */
boot_help_texts(); /* Reboot, after setting game.spacerace */
}
unit_focus_update();
menus_update();
......
****************************************************************************/
void set_government_choice(struct government *government)
{
if (NULL != client.conn.playing
if (client.conn.playing != nullptr
&& can_client_issue_orders()
&& government != government_of_player(client.conn.playing)) {
dsend_packet_player_change_government(&client.conn, government_number(government));
dsend_packet_player_change_government(&client.conn,
government_number(government));
}
}
......
pslot = player_slot_by_number(playerno);
if (NULL == pslot || !player_slot_is_used(pslot)) {
if (pslot == nullptr || !player_slot_is_used(pslot)) {
/* Ok, just ignore. */
return;
}
......
/* Update the connection information. */
if (client_player() == pplayer) {
client.conn.playing = NULL;
client.conn.playing = nullptr;
}
conn_list_iterate(pplayer->connections, pconn) {
pconn->playing = NULL;
pconn->playing = nullptr;
} conn_list_iterate_end;
conn_list_clear(pplayer->connections);
......
/* Player. */
pslot = player_slot_by_number(pinfo->playerno);
fc_assert(NULL != pslot);
fc_assert(pslot != nullptr);
new_player = !player_slot_is_used(pslot);
pplayer = player_new(pslot);
if ((pplayer->rgb == NULL) != !pinfo->color_valid
if ((pplayer->rgb == nullptr) != !pinfo->color_valid
|| (pinfo->color_valid
&& (pplayer->rgb->r != pinfo->color_red
|| pplayer->rgb->g != pinfo->color_green
......
prgbcolor = rgbcolor_new(pinfo->color_red,
pinfo->color_green,
pinfo->color_blue);
fc_assert_ret(prgbcolor != NULL);
fc_assert_ret(prgbcolor != nullptr);
} else {
prgbcolor = NULL;
prgbcolor = nullptr;
}
player_set_color(pplayer, prgbcolor);
......
/* Team. */
tslot = team_slot_by_number(pinfo->team);
fc_assert(NULL != tslot);
fc_assert(tslot != nullptr);
/* Should never fail when slot given is not nullptr */
team_add_player(pplayer, team_new(tslot));
......
pplayer->economic.luxury = pinfo->luxury;
pplayer->client.tech_upkeep = pinfo->tech_upkeep;
gov_change = (!new_player && pgov != pplayer->government
&& pplayer->government != NULL);
&& pplayer->government != nullptr);
pplayer->government = pgov;
pplayer->target_government = ptarget_gov;
pplayer->real_embassy = pinfo->real_embassy;
......
log_verbose("Research nb %d inventions: %s",
packet->id,
packet->inventions);
#endif
#endif /* FREECIV_DEBUG */
presearch = research_by_number(packet->id);
fc_assert_ret(NULL != presearch);
fc_assert_ret(presearch != nullptr);
poptechup = (presearch->researching != packet->researching
|| presearch->tech_goal != packet->tech_goal);
......
* worker on a river, the road menu item needs updating. */
menus_update();
script_client_signal_emit("new_tech");
script_client_signal_emit("new_tech");
/* If we got a new tech the tech tree news an update. */
science_report_dialog_redraw();
......
{
struct research *presearch = research_by_number(id);
if (presearch == NULL) {
if (presearch == nullptr) {
log_error("Received unknown research for clearing: %d.", id);
return;
}
......
struct player_diplstate *ds = player_diplstate_get(plr1, plr2);
bool need_players_dialog_update = FALSE;
fc_assert_ret(ds != NULL);
fc_assert_ret(ds != nullptr);
if (client_has_player() && my_player == plr2) {
if (ds->type != packet->type) {
......
/* An action selection dialog is open and our diplomatic state just
* changed. Find out if the relationship that changed was to a
* potential target. */
struct tile *tgt_tile = NULL;
struct tile *tgt_tile = nullptr;
/* Is a refresh needed because of a unit target? */
if (action_selection_target_unit() != IDENTITY_NUMBER_ZERO) {
......
tgt_unit = game_unit_by_number(action_selection_target_unit());
if (tgt_unit != NULL && tgt_unit->owner == plr1) {
if (tgt_unit != nullptr && tgt_unit->owner == plr1) {
/* An update is needed because of this unit target. */
tgt_tile = unit_tile(tgt_unit);
fc_assert(tgt_tile != NULL);
fc_assert(tgt_tile != nullptr);
}
}
......
tgt_city = game_city_by_number(action_selection_target_city());
if (tgt_city != NULL && tgt_city->owner == plr1) {
if (tgt_city != nullptr && tgt_city->owner == plr1) {
/* An update is needed because of this city target.
* Overwrites any target tile from a unit. */
tgt_tile = city_tile(tgt_city);
fc_assert(tgt_tile != NULL);
fc_assert(tgt_tile != nullptr);
}
}
......
return;
}
client_remove_cli_conn(pconn);
pconn = NULL;
pconn = nullptr;
} else {
struct player_slot *pslot = player_slot_by_number(pinfo->player_num);
struct player *pplayer = NULL;
struct player *pplayer = nullptr;
if (NULL != pslot) {
if (pslot != nullptr) {
pplayer = player_slot_get_player(pslot);
}
......
pinfo->id, pinfo->username);
pconn = fc_calloc(1, sizeof(struct connection));
pconn->buffer = NULL;
pconn->send_buffer = NULL;
pconn->buffer = nullptr;
pconn->send_buffer = nullptr;
pconn->ping_time = -1.0;
if (pplayer) {
conn_list_append(pplayer->connections, pconn);
......
log_packet("Server reports updated connection %d %s",
pinfo->id, pinfo->username);
if (pplayer != pconn->playing) {
if (NULL != pconn->playing) {
conn_list_remove(pconn->playing->connections, pconn);
}
if (pplayer) {
conn_list_append(pplayer->connections, pconn);
}
if (pconn->playing != nullptr) {
conn_list_remove(pconn->playing->connections, pconn);
}
if (pplayer) {
conn_list_append(pplayer->connections, pconn);
}
}
}
......
struct player_spaceship *ship;
struct player *pplayer = player_by_number(p->player_num);
fc_assert_ret_msg(NULL != pplayer, "Invalid player number %d.",
fc_assert_ret_msg(pplayer != nullptr, "Invalid player number %d.",
p->player_num);
ship = &pplayer->spaceship;
......
bool tile_changed = FALSE;
struct player *powner = player_by_number(packet->owner);
struct player *eowner = player_by_number(packet->extras_owner);
struct extra_type *presource = NULL;
struct extra_type *presource = nullptr;
struct terrain *pterrain = terrain_by_number(packet->terrain);
struct tile *ptile = index_to_tile(&(wld.map), packet->tile);
fc_assert_ret_msg(NULL != ptile, "Invalid tile index %d.", packet->tile);
fc_assert_ret_msg(ptile != nullptr, "Invalid tile index %d.", packet->tile);
old_known = client_tile_get_known(ptile);
if (packet->resource != MAX_EXTRA_TYPES) {
presource = extra_by_number(packet->resource);
}
if (NULL == tile_terrain(ptile) || pterrain != tile_terrain(ptile)) {
if (tile_terrain(ptile) == nullptr || pterrain != tile_terrain(ptile)) {
tile_changed = TRUE;
switch (old_known) {
case TILE_UNKNOWN:
......
break;
case TILE_KNOWN_UNSEEN:
case TILE_KNOWN_SEEN:
if (NULL != pterrain || TILE_UNKNOWN == packet->known) {
if (pterrain != nullptr || TILE_UNKNOWN == packet->known) {
tile_set_terrain(ptile, pterrain);
} else {
tile_changed = FALSE;
......
tile_set_resource(ptile, presource);
if (tile_owner(ptile) != powner) {
tile_set_owner(ptile, powner, NULL);
tile_set_owner(ptile, powner, nullptr);
tile_changed = TRUE;
}
if (extra_owner(ptile) != eowner) {
......
ptile->altitude = packet->altitude;
if (packet->placing < 0) {
if (ptile->placing != NULL) {
if (ptile->placing != nullptr) {
tile_changed = TRUE;
ptile->placing = NULL;
ptile->placing = nullptr;
ptile->infra_turns = 0;
}
} else {
......
ptile->infra_turns = packet->place_turn - game.info.turn;
}
if (NULL == tile_worked(ptile)
if (tile_worked(ptile) == nullptr
|| tile_worked(ptile)->id != packet->worked) {
if (IDENTITY_NUMBER_ZERO != packet->worked) {
struct city *pwork = game_city_by_number(packet->worked);
if (NULL == pwork) {
if (pwork == nullptr) {
char named[MAX_LEN_CITYNAME];
/* New unseen ("invisible") city, or before city_info */
fc_snprintf(named, sizeof(named), "%06u", packet->worked);
pwork = create_city_virtual(invisible.placeholder, NULL, named);
pwork = create_city_virtual(invisible.placeholder, nullptr, named);
pwork->id = packet->worked;
idex_register_city(&wld, pwork);
......
log_debug("(%d,%d) invisible city %d, %s",
TILE_XY(ptile), pwork->id, city_name_get(pwork));
} else if (NULL == city_tile(pwork)) {
} else if (city_tile(pwork) == nullptr) {
/* Old unseen ("invisible") city, or before city_info */
if (NULL != powner && city_owner(pwork) != powner) {
if (powner != nullptr && city_owner(pwork) != powner) {
/* Update placeholder with current owner */
pwork->owner = powner;
pwork->original = NULL;
pwork->original = nullptr;
}
} else {
/* We have a real (not invisible) city record for this ID, but
......
* change anything else about the city such as output.) */
{
struct city *oldwork = tile_worked(ptile);
if (oldwork && NULL != city_tile(oldwork)) {
if (oldwork && city_tile(oldwork) != nullptr) {
/* Refresh previous city too if it's real and different */
refresh_city_dialog(oldwork);
}
......
/* This marks tile worked by (possibly invisible) city. Other
* parts of the code have to handle invisible cities correctly
* (ptile->worked->tile == NULL) */
* (ptile->worked->tile == nullptr) */
tile_set_worked(ptile, pwork);
} else {
/* Tile is no longer being worked by a city.
* (Again, this might be our only prompt to refresh the worked tiles
* display for the previous working city.) */
if (tile_worked(ptile) && NULL != city_tile(tile_worked(ptile))) {
if (tile_worked(ptile) && city_tile(tile_worked(ptile)) != nullptr) {
refresh_city_dialog(tile_worked(ptile));
}
tile_set_worked(ptile, NULL);
tile_set_worked(ptile, nullptr);
}
tile_changed = TRUE;
......
known_changed = TRUE;
}
if (NULL != client.conn.playing) {
if (client.conn.playing != nullptr) {
dbv_clr(&client.conn.playing->tile_known, tile_index(ptile));
vision_layer_iterate(v) {
dbv_clr(&client.conn.playing->client.tile_vision[v], tile_index(ptile));
......
if (packet->spec_sprite[0] != '\0') {
if (!ptile->spec_sprite
|| strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
|| strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
if (ptile->spec_sprite) {
free(ptile->spec_sprite);
free(ptile->spec_sprite);
}
ptile->spec_sprite = fc_strdup(packet->spec_sprite);
tile_changed = TRUE;
......
} else {
if (ptile->spec_sprite) {
free(ptile->spec_sprite);
ptile->spec_sprite = NULL;
ptile->spec_sprite = nullptr;
tile_changed = TRUE;
}
}
......
ptile->continent = packet->continent;
if (packet->label[0] == '\0') {
if (ptile->label != NULL) {
if (ptile->label != nullptr) {
FC_FREE(ptile->label);
ptile->label = NULL;
ptile->label = nullptr;
tile_changed = TRUE;
}
} else if (ptile->label == NULL || strcmp(packet->label, ptile->label)) {
} else if (ptile->label == nullptr || strcmp(packet->label, ptile->label)) {
tile_set_label(ptile, packet->label);
tile_changed = TRUE;
}
......
* game.control.num_city_styles are allocated dynamically, and do
* not need a size check. See the allocation below. */
VALIDATE(terrain_count, MAX_NUM_TERRAINS, "terrains");
VALIDATE(terrain_count, MAX_NUM_TERRAINS, "terrains");
VALIDATE(num_specialist_types, SP_MAX, "specialists");
VALIDATE(num_specialist_types, SP_MAX, "specialists");
#undef VALIDATE
governments_alloc(game.control.government_count);
......
{
int len;
if (game.ruleset_summary != NULL) {
if (game.ruleset_summary != nullptr) {
free(game.ruleset_summary);
}
......
{
struct unit_class *c = uclass_by_number(p->id);
fc_assert_ret_msg(NULL != c, "Bad unit_class %d.", p->id);
fc_assert_ret_msg(c != nullptr, "Bad unit_class %d.", p->id);
names_set(&c->name, NULL, p->name, p->rule_name);
names_set(&c->name, nullptr, p->name, p->rule_name);
c->min_speed = p->min_speed;
c->hp_loss_pct = p->hp_loss_pct;
c->non_native_def_pct = p->non_native_def_pct;
......
int i;
struct unit_type *u = utype_by_number(p->id);
fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->id);
fc_assert_ret_msg(u != nullptr, "Bad unit_type %d.", p->id);
names_set(&u->name, NULL, p->name, p->rule_name);
names_set(&u->name, nullptr, p->name, p->rule_name);
sz_strlcpy(u->graphic_str, p->graphic_str);
sz_strlcpy(u->graphic_alt, p->graphic_alt);
sz_strlcpy(u->graphic_alt2, p->graphic_alt2);
......
u->vlayer = p->vlayer;
if (p->veteran_levels == 0) {
u->veteran = NULL;
u->veteran = nullptr;
} else {
u->veteran = veteran_system_new(p->veteran_levels);
......
struct unit_type *u = utype_by_number(p->unit);
struct combat_bonus *bonus;
fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->unit);
fc_assert_ret_msg(u != nullptr, "Bad unit_type %d.", p->unit);
bonus = malloc(sizeof(*bonus));
......
const char *flagname;
const char *helptxt;
fc_assert_ret_msg(p->id >= UTYF_USER_FLAG_1 && p->id <= UTYF_LAST_USER_FLAG, "Bad user flag %d.", p->id);
fc_assert_ret_msg(p->id >= UTYF_USER_FLAG_1 && p->id <= UTYF_LAST_USER_FLAG,
"Bad user flag %d.", p->id);
if (p->name[0] == '\0') {
flagname = NULL;
flagname = nullptr;
} else {
flagname = p->name;
}
if (p->helptxt[0] == '\0') {
helptxt = NULL;
helptxt = nullptr;
} else {
helptxt = p->helptxt;
}
......
"Bad user flag %d.", p->id);
if (p->name[0] == '\0') {
flagname = NULL;
flagname = nullptr;
} else {
flagname = p->name;
}
if (p->helptxt[0] == '\0') {
helptxt = NULL;
helptxt = nullptr;
} else {
helptxt = p->helptxt;
}
......
int i;
struct advance *a = advance_by_number(p->id);
fc_assert_ret_msg(NULL != a, "Bad advance %d.", p->id);
fc_assert_ret_msg(a != nullptr, "Bad advance %d.", p->id);
names_set(&a->name, NULL, p->name, p->rule_name);
names_set(&a->name, nullptr, p->name, p->rule_name);
sz_strlcpy(a->graphic_str, p->graphic_str);
sz_strlcpy(a->graphic_alt, p->graphic_alt);
i = 0;
fc_assert(game.control.num_tech_classes == 0 || p->tclass < game.control.num_tech_classes);
fc_assert(game.control.num_tech_classes == 0
|| p->tclass < game.control.num_tech_classes);
if (p->tclass >= 0) {
a->tclass = tech_class_by_number(p->tclass);
} else {
a->tclass = NULL;
a->tclass = nullptr;
}
/* The tech requirements req1 and req2 are send inside research_reqs
......
{
struct tech_class *ptclass = tech_class_by_number(p->id);
fc_assert_ret_msg(NULL != ptclass, "Bad tech_class %d.", p->id);
fc_assert_ret_msg(ptclass != nullptr, "Bad tech_class %d.", p->id);
names_set(&ptclass->name, NULL, p->name, p->rule_name);
names_set(&ptclass->name, nullptr, p->name, p->rule_name);
ptclass->cost_pct = p->cost_pct;
}
......
const char *flagname;
const char *helptxt;
fc_assert_ret_msg(p->id >= TECH_USER_1 && p->id <= TECH_USER_LAST, "Bad user flag %d.", p->id);
fc_assert_ret_msg(p->id >= TECH_USER_1 && p->id <= TECH_USER_LAST,
"Bad user flag %d.", p->id);
if (p->name[0] == '\0') {
flagname = NULL;
flagname = nullptr;
} else {
flagname = p->name;
}
if (p->helptxt[0] == '\0') {
helptxt = NULL;
helptxt = nullptr;
} else {
helptxt = p->helptxt;
}
......
{
struct impr_type *b = improvement_by_number(p->id);
fc_assert_ret_msg(NULL != b, "Bad improvement %d.", p->id);
fc_assert_ret_msg(b != nullptr, "Bad improvement %d.", p->id);
b->genus = p->genus;
names_set(&b->name, NULL, p->name, p->rule_name);
names_set(&b->name, nullptr, p->name, p->rule_name);
sz_strlcpy(b->graphic_str, p->graphic_str);
sz_strlcpy(b->graphic_alt, p->graphic_alt);
sz_strlcpy(b->graphic_alt2, p->graphic_alt2);
......
log_debug(" build_cost %3d", bdbg->build_cost);
log_debug(" upkeep %2d", bdbg->upkeep);
log_debug(" sabotage %3d", bdbg->sabotage);
if (NULL != bdbg->helptext) {
if (bdbg->helptext != nullptr) {
strvec_iterate(bdbg->helptext, text) {
log_debug(" helptext %s", text);
} strvec_iterate_end;
......
"Bad user flag %d.", p->id);
if (p->name[0] == '\0') {
flagname = NULL;
flagname = nullptr;
} else {
flagname = p->name;
}
if (p->helptxt[0] == '\0') {
helptxt = NULL;
helptxt = nullptr;
} else {
helptxt = p->helptxt;
}
......
{
struct multiplier *pmul = multiplier_by_number(p->id);
fc_assert_ret_msg(NULL != pmul, "Bad multiplier %d.", p->id);
fc_assert_ret_msg(pmul != nullptr, "Bad multiplier %d.", p->id);
pmul->start = p->start;
pmul->stop = p->stop;
......
pmul->factor = p->factor;
pmul->minimum_turns = p->minimum_turns;
names_set(&pmul->name, NULL, p->name, p->rule_name);
names_set(&pmul->name, nullptr, p->name, p->rule_name);
requirement_vector_copy(&pmul->reqs, &p->reqs);
PACKET_STRVEC_EXTRACT(pmul->helptext, p->helptext);
}
......
{
struct government *gov = government_by_number(p->id);
fc_assert_ret_msg(NULL != gov, "Bad government %d.", p->id);
fc_assert_ret_msg(gov != nullptr, "Bad government %d.", p->id);
gov->item_number = p->id;
requirement_vector_copy(&gov->reqs, &p->reqs);
names_set(&gov->name, NULL, p->name, p->rule_name);
names_set(&gov->name, nullptr, p->name, p->rule_name);
sz_strlcpy(gov->graphic_str, p->graphic_str);
sz_strlcpy(gov->graphic_alt, p->graphic_alt);
sz_strlcpy(gov->sound_str, p->sound_str);
......
{
struct government *gov = government_by_number(packet->gov);
fc_assert_ret_msg(NULL != gov, "Bad government %d.", packet->gov);
fc_assert_ret_msg(gov != nullptr, "Bad government %d.", packet->gov);
(void) government_ruler_title_new(gov, nation_by_number(packet->nation),
packet->male_title,
......
int j;
struct terrain *pterrain = terrain_by_number(p->id);
fc_assert_ret_msg(NULL != pterrain, "Bad terrain %d.", p->id);
fc_assert_ret_msg(pterrain != nullptr, "Bad terrain %d.", p->id);
pterrain->tclass = p->tclass;
pterrain->native_to = p->native_to;
names_set(&pterrain->name, NULL, p->name, p->rule_name);
names_set(&pterrain->name, nullptr, p->name, p->rule_name);
sz_strlcpy(pterrain->graphic_str, p->graphic_str);
sz_strlcpy(pterrain->graphic_alt, p->graphic_alt);
sz_strlcpy(pterrain->graphic_alt2, p->graphic_alt2);
......
pterrain->output[o] = p->output[o];
} output_type_iterate_end;
if (pterrain->resources != NULL) {
if (pterrain->resources != nullptr) {
free(pterrain->resources);
}
pterrain->resources = fc_calloc(p->num_resources + 1,
sizeof(*pterrain->resources));
if (pterrain->resource_freq != NULL) {
if (pterrain->resource_freq != nullptr) {
free(pterrain->resource_freq);
}
pterrain->resource_freq = fc_calloc(p->num_resources + 1,
......
}
pterrain->resource_freq[j] = p->resource_freq[j];
}
pterrain->resources[p->num_resources] = NULL;
pterrain->resources[p->num_resources] = nullptr;
pterrain->resource_freq[p->num_resources] = 0;
output_type_iterate(o) {
......
pterrain->flags = p->flags;
fc_assert_ret(pterrain->rgb == NULL);
fc_assert_ret(pterrain->rgb == nullptr);
pterrain->rgb = rgbcolor_new(p->color_red, p->color_green, p->color_blue);
PACKET_STRVEC_EXTRACT(pterrain->helptext, p->helptext);
......
const char *flagname;
const char *helptxt;
fc_assert_ret_msg(p->id >= TER_USER_1 && p->id <= TER_USER_LAST, "Bad user flag %d.", p->id);
fc_assert_ret_msg(p->id >= TER_USER_1 && p->id <= TER_USER_LAST,
"Bad user flag %d.", p->id);
if (p->name[0] == '\0') {
flagname = NULL;
flagname = nullptr;
} else {
flagname = p->name;
}
if (p->helptxt[0] == '\0') {
helptxt = NULL;
helptxt = nullptr;
} else {
helptxt = p->helptxt;
}
......
bool croad;
bool cres;
fc_assert_ret_msg(NULL != pextra, "Bad extra %d.", p->id);
fc_assert_ret_msg(pextra != nullptr, "Bad extra %d.", p->id);
names_set(&pextra->name, NULL, p->name, p->rule_name);
names_set(&pextra->name, nullptr, p->name, p->rule_name);
pextra->category = p->category;
......
"Bad user flag %d.", p->id);
if (p->name[0] == '\0') {
flagname = NULL;
flagname = nullptr;
} else {
flagname = p->name;
}
if (p->helptxt[0] == '\0') {
helptxt = NULL;
helptxt = nullptr;
} else {
helptxt = p->helptxt;
}
......
{
struct base_type *pbase = base_by_number(p->id);
fc_assert_ret_msg(NULL != pbase, "Bad base %d.", p->id);
fc_assert_ret_msg(pbase != nullptr, "Bad base %d.", p->id);
pbase->gui_type = p->gui_type;
pbase->border_sq = p->border_sq;
......
{
struct road_type *proad = road_by_number(p->id);
fc_assert_ret_msg(NULL != proad, "Bad road %d.", p->id);
fc_assert_ret_msg(proad != nullptr, "Bad road %d.", p->id);
proad->gui_type = p->gui_type;
......
{
struct goods_type *pgood = goods_by_number(p->id);
fc_assert_ret_msg(NULL != pgood, "Bad goods %d.", p->id);
fc_assert_ret_msg(pgood != nullptr, "Bad goods %d.", p->id);
names_set(&pgood->name, NULL, p->name, p->rule_name);
names_set(&pgood->name, nullptr, p->name, p->rule_name);
requirement_vector_copy(&pgood->reqs, &p->reqs);
......
{
struct disaster_type *pdis = disaster_by_number(p->id);
fc_assert_ret_msg(NULL != pdis, "Bad disaster %d.", p->id);
fc_assert_ret_msg(pdis != nullptr, "Bad disaster %d.", p->id);
names_set(&pdis->name, NULL, p->name, p->rule_name);
names_set(&pdis->name, nullptr, p->name, p->rule_name);
requirement_vector_copy(&pdis->reqs, &p->reqs);
......
{
struct achievement *pach = achievement_by_number(p->id);
fc_assert_ret_msg(NULL != pach, "Bad achievement %d.", p->id);
fc_assert_ret_msg(pach != nullptr, "Bad achievement %d.", p->id);
names_set(&pach->name, NULL, p->name, p->rule_name);
names_set(&pach->name, nullptr, p->name, p->rule_name);
pach->type = p->type;
pach->unique = p->unique;
......
{
struct trade_route_settings *pset = trade_route_settings_by_type(p->id);
if (pset != NULL) {
if (pset != nullptr) {
pset->trade_pct = p->trade_pct;
pset->cancelling = p->cancelling;
pset->bonus_type = p->bonus_type;
......
nation_set_new(packet->names[i], packet->rule_names[i],
packet->descriptions[i]);
if (pset == NULL) {
if (pset == nullptr) {
break;
} else {
fc_assert(i == nation_set_index(pset));
......
pgroup = nation_group_new(packet->groups[i]);
if (pgroup != NULL) {
if (pgroup != nullptr) {
fc_assert(i == nation_group_index(pgroup));
pgroup->hidden = packet->hidden[i];
} else {
......
struct nation_type *pnation = nation_by_number(packet->id);
int i;
fc_assert_ret_msg(NULL != pnation, "Bad nation %d.", packet->id);
fc_assert_ret_msg(pnation != nullptr, "Bad nation %d.", packet->id);
if (packet->translation_domain[0] != '\0') {
size_t len = strlen(packet->translation_domain) + 1;
pnation->translation_domain = fc_malloc(len);
fc_strlcpy(pnation->translation_domain, packet->translation_domain, len);
} else {
pnation->translation_domain = NULL;
pnation->translation_domain = nullptr;
}
names_set(&pnation->adjective, pnation->translation_domain,
packet->adjective, packet->rule_name);
......
for (i = 0; i < packet->nsets; i++) {
struct nation_set *pset = nation_set_by_number(packet->sets[i]);
if (NULL != pset) {
if (pset != nullptr) {
nation_set_list_append(pnation->sets, pset);
} else {
log_error("handle_ruleset_nation() \"%s\" have unknown set %d.",
......
for (i = 0; i < packet->ngroups; i++) {
struct nation_group *pgroup = nation_group_by_number(packet->groups[i]);
if (NULL != pgroup) {
if (pgroup != nullptr) {
nation_group_list_append(pnation->groups, pgroup);
} else {
log_error("handle_ruleset_nation() \"%s\" have unknown group %d.",
......
}
}
/* init_government may be NULL */
/* init_government may be nullptr */
pnation->init_government = government_by_number(packet->init_government_id);
for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
if (i < packet->init_techs_count) {
......
{
struct nation_style *pstyle = style_by_number(p->id);
fc_assert_ret_msg(NULL != pstyle, "Bad style %d.", p->id);
fc_assert_ret_msg(pstyle != nullptr, "Bad style %d.", p->id);
names_set(&pstyle->name, NULL, p->name, p->rule_name);
names_set(&pstyle->name, nullptr, p->name, p->rule_name);
}
/************************************************************************//**
......
{
struct clause_info *info = clause_info_get(p->type);
fc_assert_ret_msg(NULL != info, "Bad clause %d.", p->type);
fc_assert_ret_msg(info != nullptr, "Bad clause %d.", p->type);
info->enabled = p->enabled;
......
struct citystyle *cs;
id = packet->style_id;
fc_assert_ret_msg(0 <= id && game.control.num_city_styles > id,
"Bad citystyle %d.", id);
cs = &city_styles[id];
requirement_vector_copy(&cs->reqs, &packet->reqs);
names_set(&cs->name, NULL, packet->name, packet->rule_name);
names_set(&cs->name, nullptr, packet->name, packet->rule_name);
sz_strlcpy(cs->graphic, packet->graphic);
sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
sz_strlcpy(cs->citizens_graphic, packet->citizens_graphic);
......
packet->work_raise_chance[i]);
}
fc_assert(game.plr_bg_color == NULL);
fc_assert(game.plr_bg_color == nullptr);
game.plr_bg_color = rgbcolor_new(packet->background_red,
packet->background_green,
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)