Project

General

Profile

Feature #2349 ยป 0077-client-_common.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 10/10/2026 07:24 AM

View differences:

client/chatline_common.c
text_tag_list_prepend(tags, ptag);
} else {
log_error("Failed to create a color text tag (fg = %s, bg = %s).",
(NULL != color.foreground ? color.foreground : "NULL"),
(NULL != color.background ? color.background : "NULL"));
(color.foreground != nullptr ? color.foreground : "nullptr"),
(color.background != nullptr ? color.background : "nullptr"));
}
}
......
}
/**********************************************************************//**
Add a line of text to the output ("chatline") window. The text is
Add a line of text to the output ("chatline") window. The text is
constructed in printf style.
**************************************************************************/
void output_window_vprintf(const struct ft_color color,
......
/**********************************************************************//**
Add a line of text to the output ("chatline") window. The text is
Add a line of text to the output ("chatline") window. The text is
constructed in printf style.
**************************************************************************/
void output_window_printf(const struct ft_color color,
client/citydlg_common.c
{
struct tileset *tmp;
tmp = NULL;
tmp = nullptr;
if (unscaled_tileset) {
tmp = tileset;
tileset = unscaled_tileset;
......
mapview_layer_iterate(layer) {
citydlg_iterate(pcity, ptile, pedge, pcorner, canvas_x, canvas_y) {
struct unit *punit
= ptile ? get_drawable_unit(tileset, ptile, pcity) : NULL;
struct city *pcity_draw = ptile ? tile_city(ptile) : NULL;
= ptile ? get_drawable_unit(tileset, ptile, pcity) : nullptr;
struct city *pcity_draw = ptile ? tile_city(ptile) : nullptr;
put_one_element(pcanvas, 1.0, layer, ptile, pedge, pcorner,
punit, pcity_draw, canvas_x, canvas_y, pcity, NULL);
punit, pcity_draw, canvas_x, canvas_y, pcity, nullptr);
} citydlg_iterate_end;
} mapview_layer_iterate_end;
if (tmp != NULL) {
if (tmp != nullptr) {
tileset = tmp;
}
}
......
/**********************************************************************//**
Find the city dialog city production text for the given city, and
place it into the buffer. This will check the
concise_city_production option. pcity may be NULL; in this case a
concise_city_production option. pcity may be nullptr; in this case a
filler string is returned.
**************************************************************************/
void get_city_dialog_production(struct city *pcity,
......
char time_str[50], *cost_str;
int turns, stock;
if (pcity == NULL) {
if (pcity == nullptr) {
/*
* Some GUIs use this to build a "filler string" so that they can
* properly size the widget to hold the string. This has some
......
/**********************************************************************//**
Pretty sprints the info about a production in 4 columns (name, info,
cost, turns to build). The columns must each have a size of
column_size bytes. City may be NULL.
column_size bytes. City may be nullptr.
**************************************************************************/
void get_city_dialog_production_row(char *buf[], size_t column_size,
struct universal *target,
......
if (pcity && is_improvement_redundant(pcity, pimprove)) {
fc_snprintf(buf[1], column_size, "%d*", upkeep);
} else {
const char *state = NULL;
const char *state = nullptr;
if (is_great_wonder(pimprove)) {
if (improvement_obsolete(pplayer, pimprove, pcity)) {
......
}
}
if (pcity != NULL) {
if (pcity != nullptr) {
fc_snprintf(buf[2], column_size, "%d",
impr_build_shield_cost(pcity, pimprove));
} else {
fc_snprintf(buf[2], column_size, "%d",
impr_estimate_build_shield_cost(pplayer, NULL, pimprove));
impr_estimate_build_shield_cost(pplayer, nullptr, pimprove));
}
}
break;
......
sum->format = format;
sum->n = 0;
sum->sums = NULL;
sum->sums = nullptr;
return sum;
}
......
/* Likely to lead to quadratic behavior, but who cares: */
for (i = 0; i < sum->n; i++) {
fc_assert(sum->sums != NULL);
fc_assert(sum->sums != nullptr);
if ((strcmp(sum->sums[i].posdesc, posdesc) == 0)
&& (strcmp(sum->sums[i].negdesc, negdesc) == 0)
&& ((sum->sums[i].auxfmt == auxfmt)
|| (auxfmt != NULL && !strcmp(sum->sums[i].auxfmt, auxfmt)))
|| (auxfmt != nullptr && !strcmp(sum->sums[i].auxfmt, auxfmt)))
&& sum->sums[i].suppress_if_zero == suppress_if_zero) {
/* Looks like we already have an entry like this. Accumulate values. */
sum->sums[i].value += value;
......
va_end(args);
/* Descriptions will be freed individually, so need to fc_strdup() */
city_sum_add_real(sum, value, FALSE, NULL, 0, desc, fc_strdup(desc));
city_sum_add_real(sum, value, FALSE, nullptr, 0, desc, fc_strdup(desc));
}
/**********************************************************************//**
......
va_end(args);
/* Descriptions will be freed individually, so need to fc_strdup() */
city_sum_add_real(sum, value, TRUE, NULL, 0, desc, fc_strdup(desc));
city_sum_add_real(sum, value, TRUE, nullptr, 0, desc, fc_strdup(desc));
}
/**********************************************************************//**
......
if (eft[priority] == EFT_OUTPUT_BONUS_ABSOLUTE) {
new_total = bonus * base / 100 + delta;
city_sum_add_full(sum, new_total - city_sum_total(sum), TRUE,
NULL, 0,
nullptr, 0,
Q_("?city_surplus:Bonus from %s"),
Q_("?city_surplus:Loss from %s"), buf2);
} else {
......
plist = effect_list_new();
(void) get_city_bonus_effects(plist, pcity, NULL, EFT_HEALTH_PCT);
(void) get_city_bonus_effects(plist, pcity, nullptr, EFT_HEALTH_PCT);
effect_list_iterate(plist, peffect) {
char buf2[512];
......
buf[0] = '\0';
/* XXX: no way to check whether client's idea of gain/turn is accurate */
/* XXX: No way to check whether client's idea of gain/turn is accurate */
city_sum_add(sum, pcity->history, Q_("?city_culture:History (%+d/turn)"),
city_history_gain(pcity));
plist = effect_list_new();
(void) get_city_bonus_effects(plist, pcity, NULL, EFT_PERFORMANCE);
(void) get_city_bonus_effects(plist, pcity, nullptr, EFT_PERFORMANCE);
effect_list_iterate(plist, peffect) {
char buf2[512];
......
void activate_all_units(struct tile *ptile)
{
struct unit_list *punit_list = ptile->units;
struct unit *pmyunit = NULL;
struct unit *pmyunit = nullptr;
unit_list_iterate(punit_list, punit) {
if (unit_owner(punit) == client.conn.playing) {
......
* doesn't allow for error messages. It doesn't check the cost of
* buying; that's handled separately (and with an error message). */
return (can_client_issue_orders()
&& NULL != pcity
&& pcity != nullptr
&& city_owner(pcity) == client.conn.playing
&& pcity->turn_founded != game.info.turn
&& !pcity->did_buy
......
fc_assert(is_valid_city_coords(city_radius_sq, city_x, city_y));
ptile = city_map_to_tile(&(wld.map), city_tile(pcity), city_radius_sq,
city_x, city_y);
if (NULL == ptile) {
if (ptile == nullptr) {
return 0;
}
if (NULL != tile_worked(ptile) && tile_worked(ptile) == pcity) {
if (tile_worked(ptile) != nullptr && tile_worked(ptile) == pcity) {
return dsend_packet_city_make_specialist(&client.conn,
pcity->id, ptile->index);
} else if (city_can_work_tile(pcity, ptile)) {
client/colors_common.c
/************************************************************************//**
Called when the client first starts to allocate the default colors.
Currently this must be called in ui_main, generally after UI
Currently this must be called in ui_main(), generally after UI
initialization.
****************************************************************************/
struct color_system *color_system_read(struct section_file *file)
......
for (stdcolor = color_std_begin(); stdcolor != color_std_end();
stdcolor = color_std_next(stdcolor)) {
struct rgbcolor *prgbcolor = NULL;
struct rgbcolor *prgbcolor = nullptr;
if (rgbcolor_load(file, &prgbcolor, "colors.%s0",
color_std_name(stdcolor))) {
......
****************************************************************************/
struct color *ensure_color(struct rgbcolor *rgb)
{
fc_assert_ret_val(rgb != NULL, NULL);
fc_assert_ret_val(rgb != nullptr, nullptr);
if (!rgb->color) {
rgb->color = color_alloc(rgb->r, rgb->g, rgb->b);
}
return rgb->color;
}
......
{
struct color_system *colors = get_color_system(t);
fc_assert_ret_val(colors != NULL, NULL);
fc_assert_ret_val(colors != nullptr, nullptr);
return ensure_color(*(colors->stdcolors + stdcolor));
}
......
****************************************************************************/
bool player_has_color(const struct player *pplayer)
{
fc_assert_ret_val(pplayer != NULL, FALSE);
fc_assert_ret_val(pplayer != nullptr, FALSE);
return pplayer->rgb != NULL;
return pplayer->rgb != nullptr;
}
/************************************************************************//**
......
struct color *get_player_color(const struct tileset *t,
const struct player *pplayer)
{
fc_assert_ret_val(pplayer != NULL, NULL);
fc_assert_ret_val(pplayer->rgb != NULL, NULL);
fc_assert_ret_val(pplayer != nullptr, nullptr);
fc_assert_ret_val(pplayer->rgb != nullptr, nullptr);
return ensure_color(pplayer->rgb);
}
......
struct color *get_terrain_color(const struct tileset *t,
const struct terrain *pterrain)
{
fc_assert_ret_val(pterrain != NULL, NULL);
fc_assert_ret_val(pterrain->rgb != NULL, NULL);
fc_assert_ret_val(pterrain != nullptr, nullptr);
fc_assert_ret_val(pterrain->rgb != nullptr, nullptr);
return ensure_color(pterrain->rgb);
}
......
{
int sbright = color_brightness_score(subject), bestdiff = 0;
int i;
struct color *best = NULL;
struct color *best = nullptr;
fc_assert_ret_val(candidates != NULL, NULL);
fc_assert_ret_val(ncandidates > 0, NULL);
fc_assert_ret_val(candidates != nullptr, nullptr);
fc_assert_ret_val(ncandidates > 0, nullptr);
for (i = 0; i < ncandidates; i++) {
int cbright = color_brightness_score(candidates[i]);
int diff = ABS(sbright - cbright);
if (best == NULL || diff > bestdiff) {
if (best == nullptr || diff > bestdiff) {
best = candidates[i];
bestdiff = diff;
}
client/connectdlg_common.c
if (server_quitting && server_pid > 0) {
/* Already asked to /quit.
* If it didn't do that, kill it. */
if (waitpid(server_pid, NULL, WUNTRACED) <= 0) {
if (waitpid(server_pid, nullptr, WUNTRACED) <= 0) {
kill(server_pid, SIGTERM);
waitpid(server_pid, NULL, WUNTRACED);
waitpid(server_pid, nullptr, WUNTRACED);
}
server_pid = -1;
server_quitting = FALSE;
......
* the server. */
#ifdef HAVE_USABLE_FORK
kill(server_pid, SIGTERM);
waitpid(server_pid, NULL, WUNTRACED);
waitpid(server_pid, nullptr, WUNTRACED);
server_pid = -1;
#elif FREECIV_MSWINDOWS
TerminateProcess(server_process, 0);
......
}
storage = freeciv_storage_dir();
if (storage == NULL) {
if (storage == nullptr) {
output_window_append(ftc_client, _("Cannot find freeciv storage directory"));
output_window_append(ftc_client,
_("You'll have to start server manually. Sorry..."));
......
if (are_deprecation_warnings_enabled()) {
argv[argc++] = "--warnings";
}
if (ruleset != NULL) {
if (ruleset != nullptr) {
argv[argc++] = "--ruleset";
argv[argc++] = ruleset;
}
argv[argc] = NULL;
argv[argc] = nullptr;
fc_assert(argc <= max_nargs);
{
......
if (logfile) {
loghandle = CreateFile(logfile, GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS, 0, NULL);
nullptr,
OPEN_ALWAYS, 0, nullptr);
}
ZeroMemory(&si, sizeof(si));
......
} else {
depr = "";
}
if (ruleset != NULL) {
if (ruleset != nullptr) {
fc_snprintf(rsparam, sizeof(rsparam), " --ruleset %s", ruleset);
} else {
rsparam[0] = '\0';
......
if (
#ifdef FREECIV_DEBUG
!CreateProcess(NULL, cmdline1, NULL, NULL, TRUE,
!CreateProcess(nullptr, cmdline1, nullptr, nullptr, TRUE,
DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi)
nullptr, nullptr, &si, &pi)
#ifndef FREECIV_WEB
&& !CreateProcess(NULL, cmdline2, NULL, NULL, TRUE,
&& !CreateProcess(nullptr, cmdline2, nullptr, nullptr, TRUE,
DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi)
nullptr, nullptr, &si, &pi)
#endif /* FREECIV_WEB */
&&
#endif /* FREECIV_DEBUG */
!CreateProcess(NULL, cmdline3, NULL, NULL, TRUE,
!CreateProcess(nullptr, cmdline3, nullptr, nullptr, TRUE,
DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi)
&& !CreateProcess(NULL, cmdline4, NULL, NULL, TRUE,
nullptr, nullptr, &si, &pi)
&& !CreateProcess(nullptr, cmdline4, nullptr, nullptr, TRUE,
DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi)) {
nullptr, nullptr, &si, &pi)) {
log_error("Failed to start server process.");
#ifdef FREECIV_DEBUG
log_verbose("Tried with commandline: '%s'", cmdline1);
......
fc_usleep(WAIT_BETWEEN_TRIES);
#ifdef HAVE_USABLE_FORK
#ifndef FREECIV_MSWINDOWS
if (waitpid(server_pid, NULL, WNOHANG) != 0) {
if (waitpid(server_pid, nullptr, WNOHANG) != 0) {
break;
}
#endif /* FREECIV_MSWINDOWS */
......
struct section_file *file;
const char *sdir = freeciv_storage_dir();
if (sdir == NULL) {
if (sdir == nullptr) {
return;
}
client/luaconsole_common.c
text_tag_list_prepend(tags, ptag);
} else {
log_error("Failed to create a color text tag (fg = %s, bg = %s).",
(NULL != color.foreground ? color.foreground : "NULL"),
(NULL != color.background ? color.background : "NULL"));
(color.foreground != nullptr ? color.foreground : "nullptr"),
(color.background != nullptr ? color.background : "nullptr"));
}
}
......
}
/*************************************************************************//**
Add a line of text to the output ("chatline") window. The text is
Add a line of text to the output ("chatline") window. The text is
constructed in printf style.
*****************************************************************************/
void luaconsole_vprintf(const struct ft_color color,
......
/*************************************************************************//**
Add a line of text to the output ("chatline") window. The text is
Add a line of text to the output ("chatline") window. The text is
constructed in printf style.
*****************************************************************************/
void luaconsole_printf(const struct ft_color color,
client/mapctrl_common.c
#include <fc_config.h>
#endif
#include <stdlib.h> /* qsort */
#include <stdlib.h> /* qsort */
/* utility */
#include "fcintl.h"
......
/* The mapcanvas clipboard */
struct universal clipboard =
{ .kind = VUT_NONE,
.value = {.building = NULL}
.value = {.building = nullptr}
};
/* Goto with drag and drop. */
......
struct tile *keyboardless_goto_start_tile;
/* Update the workers for a city on the map, when the update is received */
struct city *city_workers_display = NULL;
struct city *city_workers_display = nullptr;
/*************************************************************************/
......
/* For diamond shaped tiles, every other row is indented.
*/
if ((yy % 2 ^ xx % 2) != 0) {
continue;
continue;
}
ptile = canvas_pos_to_tile(x, y, map_zoom);
if (!ptile) {
continue;
continue;
}
/* "Half-tile" indentation must match, or we'll process
......
tile_to_canvas_pos(&x2, &y2, map_zoom, ptile);
if ((yy % 2) != 0 && ((rec_corner_x % W) ^ abs((int)x2 % W)) != 0) {
continue;
continue;
}
/* Tile passed all tests; process it.
*/
pcity = tile_city(ptile);
if (pcity != NULL && city_owner(pcity) == client_player()) {
if (pcity != nullptr && city_owner(pcity) == client_player()) {
mapdeco_set_highlight(ptile, TRUE);
found_any_cities = tiles_hilited_cities = TRUE;
}
......
{
const int W = tileset_tile_width(tileset), half_W = W / 2;
const int H = tileset_tile_height(tileset), half_H = H / 2;
static struct tile *rec_tile = NULL;
static struct tile *rec_tile = nullptr;
int diff_x, diff_y;
struct tile *center_tile;
struct tile *ptile;
......
toggle_city_hilite(pcity, FALSE); /* cityrep.c */
}
}
else if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
else if (pcity != nullptr && city_owner(pcity) == client.conn.playing) {
mapdeco_set_highlight(ptile, TRUE);
tiles_hilited_cities = TRUE;
toggle_city_hilite(pcity, TRUE);
......
if (!can_client_issue_orders()) {
return;
}
if (NULL == clipboard.value.building) {
if (clipboard.value.building == nullptr) {
create_event(city_tile(pcity), E_BAD_COMMAND, ftc_client,
_("Clipboard is empty."));
return;
}
if (!tiles_hilited_cities) {
if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
if (pcity != nullptr && city_owner(pcity) == client.conn.playing) {
clipboard_send_production_packet(pcity);
}
return;
......
}
keyboardless_goto_active = FALSE;
keyboardless_goto_button_down = FALSE;
keyboardless_goto_start_tile = NULL;
keyboardless_goto_start_tile = nullptr;
}
/**********************************************************************//**
......
struct option *opt;
opt = optset_option_by_name(server_optset, "fixedlength");
if (opt != NULL && option_bool_get(opt)) {
if (opt != nullptr && option_bool_get(opt)) {
return FALSE;
}
......
{
struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
if (NULL != ptile && can_client_issue_orders()) {
if (ptile != nullptr && can_client_issue_orders()) {
struct city *pcity = find_city_near_tile(ptile);
if (pcity && !cma_is_city_under_agent(pcity, NULL)) {
if (pcity && !cma_is_city_under_agent(pcity, nullptr)) {
#ifndef FREECIV_NDEBUG
int city_x, city_y;
#endif
fc_assert_ret(city_base_to_city_map(&city_x, &city_y, pcity, ptile));
if (NULL != tile_worked(ptile) && tile_worked(ptile) == pcity) {
if (tile_worked(ptile) != nullptr && tile_worked(ptile) == pcity) {
dsend_packet_city_make_specialist(&client.conn,
pcity->id, ptile->index);
} else if (city_can_work_tile(pcity, ptile)) {
dsend_packet_city_make_worker(&client.conn,
pcity->id, ptile->index);
} else {
return;
return;
}
/* When the city info packet is received, update the workers on the
* map. This is a bad hack used to selectively update the mapview
* map. This is a bad hack used to selectively update the mapview
* when we receive the corresponding city packet. */
city_workers_display = pcity;
}
......
}
/**********************************************************************//**
Recenter the map on the canvas location, on user request. Usually this
Recenter the map on the canvas location, on user request. Usually this
is done with a right-click.
**************************************************************************/
void recenter_button_pressed(int canvas_x, int canvas_y)
client/messagewin_common.c
#include "messagewin_common.h"
static struct message **messages = NULL;
static struct message **messages = nullptr;
static int messages_total = 0;
static int messages_alloc = 0;
......
}
if (meswin_dialog_is_open()) {
update_queue_add(real_meswin_dialog_update, NULL);
update_queue_add(real_meswin_dialog_update, nullptr);
} else if (0 < messages_total
&& (!client_has_player()
|| is_human(client.conn.playing))) {
......
text_tag_list_destroy(messages[i]->tags);
free(messages[i]);
messages[i] = NULL;
messages[i] = nullptr;
}
if (i != 0) {
for (; i < messages_total; i++, j++) {
messages[j] = messages[i];
messages[i] = NULL;
messages[i] = nullptr;
}
messages_total = j;
}
......
msg->event = event;
msg->descr = s;
msg->tags = text_tag_list_copy(tags);
msg->location_ok = (ptile != NULL);
msg->location_ok = (ptile != nullptr);
msg->visited = FALSE;
msg->turn = turn;
msg->phase = phase;
......
}
/************************************************************************//**
Returns the pointer to a message. Returns NULL on error.
Returns the pointer to a message. Returns nullptr on error.
****************************************************************************/
const struct message *meswin_get_message(int message_index)
{
......
return messages[message_index];
} else {
/* Can happen in turn change... */
return NULL;
return nullptr;
}
}
......
}
if (pcity && can_player_see_units_in_city(client.conn.playing, pcity)) {
/* If the event was the city being destroyed, pcity will be NULL
* and we'd better not try to pop it up. It's also possible that
/* If the event was the city being destroyed, pcity will be nullptr
* and we'd better not try to pop it up. It's also possible that
* events will happen on enemy cities; we generally don't want to pop
* those dialogs up either (although it's hard to be certain).
*
client/overview_common.c
int OVERVIEW_TILE_SIZE = 2;
#if 0
struct overview overview = {
/* These are the default values. All others are zeroed automatically. */
/* These are the default values. All others are zeroed automatically. */
.fog = TRUE,
.layers = {[OLAYER_BACKGROUND] = TRUE,
[OLAYER_UNITS] = TRUE,
[OLAYER_CITIES] = TRUE,
[OLAYER_BORDERS_ON_OCEAN] = TRUE}
[OLAYER_UNITS] = TRUE,
[OLAYER_CITIES] = TRUE,
[OLAYER_BORDERS_ON_OCEAN] = TRUE}
};
#endif
......
static bool overview_dirty = FALSE;
/************************************************************************//**
Translate from gui to natural coordinate systems. This provides natural
Translate from gui to natural coordinate systems. This provides natural
coordinates as a floating-point value so there is no loss of information
in the resulting values.
****************************************************************************/
static void gui_to_natural_pos(const struct tileset *t,
double *ntl_x, double *ntl_y,
int gui_x, int gui_y)
double *ntl_x, double *ntl_y,
int gui_x, int gui_y)
{
const double gui_xd = gui_x, gui_yd = gui_y;
const double W = tileset_tile_width(t) * map_zoom;
const double H = tileset_tile_height(t) * map_zoom;
double map_x, map_y;
/* First convert to map positions. This ignores hex conversions; we're
/* First convert to map positions. This ignores hex conversions; we're
* not looking for an exact tile. */
if (tileset_is_isometric(t)) {
/* Includes hex cases. */
......
struct city *pcity = tile_city(ptile);
if (pcity) {
if (NULL == client.conn.playing
if (client.conn.playing == nullptr
|| city_owner(pcity) == client.conn.playing) {
return get_color(tileset, COLOR_OVERVIEW_MY_CITY);
return get_color(tileset, COLOR_OVERVIEW_MY_CITY);
} else if (pplayers_allied(city_owner(pcity), client.conn.playing)) {
/* Includes teams. */
return get_color(tileset, COLOR_OVERVIEW_ALLIED_CITY);
/* Includes teams. */
return get_color(tileset, COLOR_OVERVIEW_ALLIED_CITY);
} else {
return get_color(tileset, COLOR_OVERVIEW_ENEMY_CITY);
return get_color(tileset, COLOR_OVERVIEW_ENEMY_CITY);
}
}
}
......
struct unit *punit = find_visible_unit(ptile);
if (punit) {
if (NULL == client.conn.playing
if (client.conn.playing == nullptr
|| unit_owner(punit) == client.conn.playing) {
return get_color(tileset, COLOR_OVERVIEW_MY_UNIT);
return get_color(tileset, COLOR_OVERVIEW_MY_UNIT);
} else if (pplayers_allied(unit_owner(punit), client.conn.playing)) {
/* Includes teams. */
return get_color(tileset, COLOR_OVERVIEW_ALLIED_UNIT);
/* Includes teams. */
return get_color(tileset, COLOR_OVERVIEW_ALLIED_UNIT);
} else {
return get_color(tileset, COLOR_OVERVIEW_ENEMY_UNIT);
return get_color(tileset, COLOR_OVERVIEW_ENEMY_UNIT);
}
}
}
......
}
gui_to_overview_pos(tileset, &x[0], &y[0],
mapview.gui_x0, mapview.gui_y0);
mapview.gui_x0, mapview.gui_y0);
gui_to_overview_pos(tileset, &x[1], &y[1],
mapview.gui_x0 + mapview.width, mapview.gui_y0);
mapview.gui_x0 + mapview.width, mapview.gui_y0);
gui_to_overview_pos(tileset, &x[2], &y[2],
mapview.gui_x0 + mapview.width,
mapview.gui_y0 + mapview.height);
mapview.gui_x0 + mapview.width,
mapview.gui_y0 + mapview.height);
gui_to_overview_pos(tileset, &x[3], &y[3],
mapview.gui_x0, mapview.gui_y0 + mapview.height);
mapview.gui_x0, mapview.gui_y0 + mapview.height);
for (i = 0; i < 4; i++) {
int src_x = x[i];
......
redraw_overview();
gui_to_overview_pos(tileset, &ox, &oy,
mapview.gui_x0, mapview.gui_y0);
mapview.gui_x0, mapview.gui_y0);
update_overview_scroll_window_pos(ox, oy);
}
......
/* The map position may not be normal, for instance when the mapview
* origin is not a normal position.
*
* NOTE: this embeds the map wrapping in the overview code. */
* NOTE: This embeds the map wrapping in the overview code. */
do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
int ovr_x = ntl_x - gui_options.overview.map_x0;
int ovr_y = ntl_y - gui_options.overview.map_y0;
......
if (gui_options.overview.map) {
canvas_free(gui_options.overview.map);
canvas_free(gui_options.overview.window);
gui_options.overview.map = NULL;
gui_options.overview.window = NULL;
gui_options.overview.map = nullptr;
gui_options.overview.window = nullptr;
}
}
......
void overview_redraw_callback(struct option *option)
{
/* This is called once for each option changed so it is slower than
* necessary. If this becomes a problem it could be switched to use a
* necessary. If this becomes a problem it could be switched to use a
* queue system like the mapview drawing code does. */
refresh_overview_canvas();
}
client/plrdlg_common.c
static char buf[100];
const struct player_diplstate *pds;
if (NULL == client.conn.playing || player == client.conn.playing) {
if (client.conn.playing == nullptr || player == client.conn.playing) {
return "-";
} else {
pds = player_diplstate_get(client.conn.playing, player);
......
****************************************************************************/
static int diplstate_value(const struct player *plr)
{
/* these values are scaled so that adding/subtracting
/* These values are scaled so that adding/subtracting
the number of turns left makes sense */
static const int diplstate_cmp_lookup[DS_LAST] = {
[DS_TEAM] = 1 << 16,
......
const struct player_diplstate *pds;
int ds_value;
if (NULL == client.conn.playing || plr == client.conn.playing) {
/* current global player is as close as players get
if (client.conn.playing == nullptr || plr == client.conn.playing) {
/* Current global player is as close as players get
-> return value smaller than for DS_TEAM */
return 0;
}
......
****************************************************************************/
static const char *col_love(const struct player *player)
{
if (NULL == client.conn.playing || player == client.conn.playing
if (client.conn.playing == nullptr || player == client.conn.playing
|| is_human(player)) {
return "-";
} else {
......
{
int love1, love2;
if (NULL == client.conn.playing) {
if (client.conn.playing == nullptr) {
return player_number(player1) - player_number(player2);
}
......
}
opt = optset_option_by_name(server_optset, "turnblock");
if (opt != NULL) {
if (opt != nullptr) {
consider_tb = option_bool_get(opt);
}
......
const struct player *me = client_player();
bool gobs = client_is_global_observer();
if (them == NULL || !them->is_alive) {
if (them == nullptr || !them->is_alive) {
fc_snprintf(buf, sizeof(buf), "-");
} else if (gobs
|| (me != NULL
|| (me != nullptr
&& (me == them || team_has_embassy(me->team, them)))) {
fc_snprintf(buf, sizeof(buf), "%d", them->client.culture);
} else {
......
const struct player *me = client_player();
bool gobs = client_is_global_observer();
if (them == NULL || !them->is_alive) {
if (them == nullptr || !them->is_alive) {
fc_snprintf(buf, sizeof(buf), "-");
} else if (gobs
|| (me != NULL
|| (me != nullptr
&& (me == them || team_has_embassy(me->team, them)
|| player_diplstate_get(me, them)->contact_turns_left > 0))) {
fc_snprintf(buf, sizeof(buf), "%d", them->economic.gold);
......
const struct player *me = client_player();
bool gobs = client_is_global_observer();
if (them == NULL || !them->is_alive) {
if (them == nullptr || !them->is_alive) {
fc_snprintf(buf, sizeof(buf), "-");
} else if (gobs
|| (me != NULL
|| (me != nullptr
&& (me == them || team_has_embassy(me->team, them)))) {
fc_snprintf(buf, sizeof(buf), "%d %%", them->economic.tax);
} else {
......
const struct player *me = client_player();
bool gobs = client_is_global_observer();
if (them == NULL || !them->is_alive) {
if (them == nullptr || !them->is_alive) {
fc_snprintf(buf, sizeof(buf), "-");
} else if (gobs
|| (me != NULL
|| (me != nullptr
&& (me == them || team_has_embassy(me->team, them)))) {
fc_snprintf(buf, sizeof(buf), "%d %%", them->economic.science);
} else {
......
const struct player *me = client_player();
bool gobs = client_is_global_observer();
if (them == NULL || !them->is_alive) {
if (them == nullptr || !them->is_alive) {
fc_snprintf(buf, sizeof(buf), "-");
} else if (gobs
|| (me != NULL
|| (me != nullptr
&& (me == them || team_has_embassy(me->team, them)))) {
fc_snprintf(buf, sizeof(buf), "%d %%", them->economic.luxury);
} else {
......
const struct player *me = client_player();
bool gobs = client_is_global_observer();
if (them == NULL || !them->is_alive) {
if (them == nullptr || !them->is_alive) {
fc_snprintf(buf, sizeof(buf), "-");
} else if (gobs
|| (me != NULL
|| (me != nullptr
&& (me == them || team_has_embassy(me->team, them)))) {
struct research *research = research_get(them);
......
...
****************************************************************************/
struct player_dlg_column player_dlg_columns[] = {
{TRUE, COL_TEXT, N_("?Player:Name"), col_name, NULL, cmp_name, "name"},
{FALSE, COL_TEXT, N_("Username"), col_username, NULL, NULL, "username"},
{TRUE, COL_FLAG, N_("Flag"), NULL, NULL, NULL, "flag"},
{TRUE, COL_TEXT, N_("Nation"), col_nation, NULL, NULL, "nation"},
{TRUE, COL_COLOR, N_("Border"), NULL, NULL, NULL, "border"},
{TRUE, COL_RIGHT_TEXT, N_("Score"), get_score_text, NULL, cmp_score, "score"},
{TRUE, COL_TEXT, N_("Team"), col_team, NULL, NULL, "team"},
{TRUE, COL_BOOLEAN, N_("AI"), NULL, col_ai, NULL, "ai"},
{TRUE, COL_TEXT, N_("Attitude"), col_love, NULL, cmp_love, "attitude"},
{TRUE, COL_TEXT, N_("Embassy"), col_embassy, NULL, NULL, "embassy"},
{TRUE, COL_TEXT, N_("Dipl.State"), col_diplstate, NULL, cmp_diplstate,
{TRUE, COL_TEXT, N_("?Player:Name"), col_name, nullptr, cmp_name, "name"},
{FALSE, COL_TEXT, N_("Username"), col_username, nullptr, nullptr, "username"},
{TRUE, COL_FLAG, N_("Flag"), nullptr, nullptr, nullptr, "flag"},
{TRUE, COL_TEXT, N_("Nation"), col_nation, nullptr, nullptr, "nation"},
{TRUE, COL_COLOR, N_("Border"), nullptr, nullptr, nullptr, "border"},
{TRUE, COL_RIGHT_TEXT, N_("Score"), get_score_text, nullptr, cmp_score, "score"},
{TRUE, COL_TEXT, N_("Team"), col_team, nullptr, nullptr, "team"},
{TRUE, COL_BOOLEAN, N_("AI"), nullptr, col_ai, nullptr, "ai"},
{TRUE, COL_TEXT, N_("Attitude"), col_love, nullptr, cmp_love, "attitude"},
{TRUE, COL_TEXT, N_("Embassy"), col_embassy, nullptr, nullptr, "embassy"},
{TRUE, COL_TEXT, N_("Dipl.State"), col_diplstate, nullptr, cmp_diplstate,
"diplstate"},
{TRUE, COL_TEXT, N_("Vision"), col_vision, NULL, NULL, "vision"},
{TRUE, COL_TEXT, N_("State"), plrdlg_col_state, NULL, NULL, "state"},
{FALSE, COL_TEXT, N_("?Player_dlg:Host"), col_host, NULL, NULL, "host"},
{FALSE, COL_RIGHT_TEXT, N_("?Player_dlg:Idle"), col_idle, NULL, NULL, "idle"},
{FALSE, COL_RIGHT_TEXT, N_("Ping"), get_ping_time_text, NULL, NULL, "ping"},
{TRUE, COL_TEXT, N_("Government"), col_government, NULL, NULL, "government"},
{TRUE, COL_RIGHT_TEXT, N_("Culture"), col_culture, NULL, cmp_culture, "culture"},
{TRUE, COL_RIGHT_TEXT, N_("Gold"), col_gold, NULL, cmp_gold, "gold"},
{TRUE, COL_RIGHT_TEXT, N_("Tax"), col_tax, NULL, cmp_tax, "tax"},
{TRUE, COL_RIGHT_TEXT, N_("Science"), col_science, NULL, cmp_science, "science"},
{TRUE, COL_RIGHT_TEXT, N_("Luxury"), col_luxury, NULL, cmp_luxury, "luxury"},
{TRUE, COL_TEXT, N_("Research"), col_research, NULL, NULL, "research"}
{TRUE, COL_TEXT, N_("Vision"), col_vision, nullptr, nullptr, "vision"},
{TRUE, COL_TEXT, N_("State"), plrdlg_col_state, nullptr, nullptr, "state"},
{FALSE, COL_TEXT, N_("?Player_dlg:Host"), col_host, nullptr, nullptr, "host"},
{FALSE, COL_RIGHT_TEXT, N_("?Player_dlg:Idle"), col_idle, nullptr, nullptr, "idle"},
{FALSE, COL_RIGHT_TEXT, N_("Ping"), get_ping_time_text, nullptr, nullptr, "ping"},
{TRUE, COL_TEXT, N_("Government"), col_government, nullptr, nullptr, "government"},
{TRUE, COL_RIGHT_TEXT, N_("Culture"), col_culture, nullptr, cmp_culture, "culture"},
{TRUE, COL_RIGHT_TEXT, N_("Gold"), col_gold, nullptr, cmp_gold, "gold"},
{TRUE, COL_RIGHT_TEXT, N_("Tax"), col_tax, nullptr, cmp_tax, "tax"},
{TRUE, COL_RIGHT_TEXT, N_("Science"), col_science, nullptr, cmp_science, "science"},
{TRUE, COL_RIGHT_TEXT, N_("Luxury"), col_luxury, nullptr, cmp_luxury, "luxury"},
{TRUE, COL_TEXT, N_("Research"), col_research, nullptr, nullptr, "research"}
};
const int num_player_dlg_columns = ARRAY_SIZE(player_dlg_columns);
client/repodlgs_common.c
*total_cost = 0;
*total_income = 0;
if (NULL == client.conn.playing) {
if (client.conn.playing == nullptr) {
return;
}
......
*num_entries_used = 0;
*total_cost = 0;
if (NULL == client.conn.playing) {
if (client.conn.playing == nullptr) {
return;
}
......
city_list_iterate(client.conn.playing->cities, pcity) {
unit_list_iterate(pcity->units_supported, punit) {
if (unit_type_get(punit) == unittype) {
if (unit_type_get(punit) == unittype) {
count++;
partial_cost += punit->upkeep[O_GOLD];
}
client/themes_common.c
int i;
/* Get GUI-specific theme directories */
char **gui_directories =
get_gui_specific_themes_directories(&num_directories);
char **gui_directories
= get_gui_specific_themes_directories(&num_directories);
directories =
fc_malloc(sizeof(struct theme_directory) * num_directories);
directories
= fc_malloc(sizeof(struct theme_directory) * num_directories);
for (i = 0; i < num_directories; i++) {
directories[i].path = gui_directories[i];
/* Get usable themes in this directory */
directories[i].themes =
get_usable_themes_in_directory(directories[i].path,
directories[i].themes
= get_usable_themes_in_directory(directories[i].path,
&(directories[i].num_themes));
}
free(gui_directories);
......
****************************************************************************/
const struct strvec *get_themes_list(const struct option *poption)
{
static struct strvec *themes_list = NULL;
static struct strvec *themes_list = nullptr;
if (NULL == themes_list) {
if (themes_list == nullptr) {
int i, j, k;
themes_list = strvec_new();
......
{
const char *theme_name = option_str_get(poption);
fc_assert_ret(NULL != theme_name && theme_name[0] != '\0');
fc_assert_ret(theme_name != nullptr && theme_name[0] != '\0');
load_theme(theme_name);
}
client/unitselect_common.c
struct usdata *data = fc_calloc(1, sizeof(*data));
data->utype = NULL;
data->utype = nullptr;
for (loc = unit_select_location_mode_begin();
loc != unit_select_location_mode_end();
......
*****************************************************************************/
static void usdata_destroy(struct usdata *data)
{
if (data != NULL) {
if (data != nullptr) {
enum unit_select_location_mode loc;
enum unit_activity act;
......
loc != unit_select_location_mode_end();
loc = unit_select_location_mode_next(loc)) {
for (act = 0; act < ACTIVITY_LAST; act++) {
if (data->units[loc][act] != NULL) {
if (data->units[loc][act] != nullptr) {
unit_list_destroy(data->units[loc][act]);
}
}
......
static bool usdlg_check_unit_activity(const struct unit *punit,
enum unit_activity act)
{
fc_assert_ret_val(punit != NULL, FALSE);
fc_assert_ret_val(punit != nullptr, FALSE);
return (punit->activity == act);
}
......
{
struct tile *utile;
fc_assert_ret_val(punit != NULL, FALSE);
fc_assert_ret_val(punit != nullptr, FALSE);
utile = unit_tile(punit);
fc_assert_ret_val(utile != NULL, FALSE);
fc_assert_ret_val(utile != nullptr, FALSE);
switch (loc) {
case SELLOC_UNITS:
......
break;
case SELLOC_LAND:
if (utype_move_type(unit_type_get(punit)) == UMT_LAND
&& (!is_ocean(tile_terrain(utile)) || tile_city(utile) != NULL)) {
&& (!is_ocean(tile_terrain(utile)) || tile_city(utile) != nullptr)) {
return TRUE;
}
break;
case SELLOC_SEA:
if (utype_move_type(unit_type_get(punit)) == UMT_SEA
&& (is_ocean(tile_terrain(utile)) || tile_city(utile) != NULL)) {
&& (is_ocean(tile_terrain(utile)) || tile_city(utile) != nullptr)) {
return TRUE;
}
break;
    (1-1/1)