Project

General

Profile

Feature #2350 ยป 0082-gui-sdl-action_dialog.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 10/10/2026 01:14 PM

View differences:

client/gui-sdl2/action_dialog.c
void popdown_bribe_dialog(void);
static struct diplomat_dialog *diplomat_dlg = NULL;
static struct diplomat_dialog *diplomat_dlg = nullptr;
static bool is_more_user_input_needed = FALSE;
static bool did_not_decide = FALSE;
......
**************************************************************************/
static int spy_strike_bld_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_STRIKE_BUILDING,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
**************************************************************************/
static int spy_sabotage_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
**************************************************************************/
static int spy_sabotage_esc_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
int steal_advance = MAX_ID - pwidget->id;
int actor_id = diplomat_dlg->actor_unit_id;
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
if (steal_advance == A_UNSET) {
/* This is the untargeted version. */
request_do_action(get_non_targeted_action_id(
......
const struct research *presearch, *vresearch;
struct city *vcity = pwidget->data.city;
int id = diplomat_dlg->actor_unit_id;
struct player *victim = NULL;
struct player *victim = nullptr;
struct container *cont;
struct widget *buf = NULL;
struct widget *buf = nullptr;
struct widget *pwindow;
utf8_str *pstr;
SDL_Surface *surf;
......
FONTO_ATTENTION);
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = spy_steal_dlg_window_callback;
set_wstate(pwindow , FC_WS_NORMAL);
......
}
}
pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
pstr = create_utf8_str_fonto(nullptr, 0, FONTO_DEFAULT);
pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
count = 0;
......
area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + idx));
area.h = count * buf->size.h + adj_size(2);
/* alloca window theme and win background buffer */
/* Allocate window theme and win background buffer */
surf = theme_get_background(active_theme, BACKGROUND_SPYSTEALDLG);
if (resize_window(pwindow, surf, NULL,
if (resize_window(pwindow, surf, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h)) {
FREESURFACE(surf);
......
(main_window_width() - pwindow->size.w) / 2,
(main_window_height() - pwindow->size.h) / 2);
/* exit button */
/* Exit button */
buf = pwindow->prev;
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
......
static int diplomat_incite_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_INCITE_CITY,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
static int spy_incite_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_INCITE_CITY_ESC,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
static int diplomat_bribe_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL !=
game_unit_by_number(diplomat_dlg->target_ids[ATK_UNIT])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_unit_by_number(diplomat_dlg->target_ids[ATK_UNIT]) != nullptr) {
request_action_details(ACTION_SPY_BRIBE_UNIT,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_UNIT]);
......
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit;
if (game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != NULL
if (game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr
&& (punit = game_unit_by_number(diplomat_dlg->actor_unit_id))) {
popup_unit_upgrade_dlg(punit, FALSE);
}
......
/* Actor */
fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
actor_id = diplomat_dlg->actor_unit_id;
if (NULL == game_unit_by_number(actor_id)) {
if (game_unit_by_number(actor_id) == nullptr) {
/* Probably dead. */
failed = TRUE;
}
......
switch (action_get_target_kind(paction)) {
case ATK_CITY:
target_id = diplomat_dlg->target_ids[ATK_CITY];
if (NULL == game_city_by_number(target_id)) {
if (game_city_by_number(target_id) == nullptr) {
/* Probably destroyed. */
failed = TRUE;
}
break;
case ATK_UNIT:
target_id = diplomat_dlg->target_ids[ATK_UNIT];
if (NULL == game_unit_by_number(target_id)) {
if (game_unit_by_number(target_id) == nullptr) {
/* Probably dead. */
failed = TRUE;
}
......
case ATK_TILE:
case ATK_EXTRAS:
target_id = diplomat_dlg->target_ids[ATK_TILE];
if (NULL == index_to_tile(&(wld.map), target_id)) {
if (index_to_tile(&(wld.map), target_id) == nullptr) {
/* TODO: Should this be possible at all? If not: add assertion. */
failed = TRUE;
}
......
switch (action_get_sub_target_kind(paction)) {
case ASTK_BUILDING:
sub_target = diplomat_dlg->sub_target_id[ASTK_BUILDING];
if (NULL == improvement_by_number(sub_target)) {
if (improvement_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
break;
case ASTK_TECH:
sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
if (NULL == valid_advance_by_number(sub_target)) {
if (valid_advance_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
......
case ASTK_EXTRA_NOT_THERE:
/* TODO: validate if the extra is there? */
sub_target = diplomat_dlg->sub_target_id[ASTK_EXTRA];
if (NULL == extra_by_number(sub_target)) {
if (extra_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
break;
case ASTK_SPECIALIST:
sub_target = diplomat_dlg->sub_target_id[ASTK_SPECIALIST];
if (nullptr == specialist_by_number(sub_target)) {
if (specialist_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
......
case ASTK_COUNT:
/* Shouldn't happen. */
fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
failed = TRUE;
break;
}
......
act_unit,
tgt_city);
if (af_map[act] == NULL) {
if (af_map[act] == nullptr) {
/* No special call back function needed for this action. */
cb = simple_action_callback;
} else {
......
struct extra_type *target_extra,
const struct act_prob *act_probs)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
SDL_Rect area;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = diplomat_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_CITY) {
action_entry(act, act_probs,
actor_unit, NULL, target_city, NULL,
actor_unit, nullptr, target_city, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_UNIT) {
action_entry(act, act_probs,
actor_unit, NULL, NULL, target_unit,
actor_unit, nullptr, nullptr, target_unit,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_STACK) {
action_entry(act, act_probs,
actor_unit, target_tile, NULL, NULL,
actor_unit, target_tile, nullptr, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_TILE) {
action_entry(act, act_probs,
actor_unit, target_tile, NULL, NULL,
actor_unit, target_tile, nullptr, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_EXTRAS) {
action_entry(act, act_probs,
actor_unit, target_tile, NULL, NULL,
actor_unit, target_tile, nullptr, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_SELF) {
action_entry(act, act_probs,
actor_unit, NULL, NULL, target_unit,
actor_unit, nullptr, nullptr, target_unit,
pwindow, &area);
}
} action_iterate_end;
......
/* ---------- */
diplomat_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
unit_tile(actor_unit));
/* setup widget size and start position */
/* Setup widget size and start position */
buf = pwindow->prev;
setup_vertical_widgets_position(1,
......
diplomat_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
/* Redraw */
redraw_group(diplomat_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
......
sabotage_improvement = -1;
}
if (NULL != game_unit_by_number(diplomat_id)
&& NULL != game_city_by_number(diplomat_target_id)) {
if (game_unit_by_number(diplomat_id) != nullptr
&& game_city_by_number(diplomat_target_id) != nullptr) {
if (sabotage_improvement == B_LAST) {
/* This is the untargeted version. */
request_do_action(get_non_targeted_action_id(act_id),
......
void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL , *last = NULL;
struct widget *pwindow = nullptr, *buf = nullptr, *last = nullptr;
struct container *cont;
utf8_str *pstr;
SDL_Rect area, area2;
......
}
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = diplomat_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
area.w = MAX(area.w, buf->size.w);
area.h += buf->size.h;
/* separator */
buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
/* Separator */
buf = create_iconlabel(nullptr, pwindow->dst, nullptr, WF_FREE_THEME);
add_to_gui_list(ID_SEPARATOR, buf);
area.h += buf->next->size.h;
......
if (n > 0
&& action_prob_possible(actor->client.act_prob_cache[
get_non_targeted_action_id(paction->id)])) {
/* separator */
buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
/* Separator */
buf = create_iconlabel(nullptr, pwindow->dst, nullptr, WF_FREE_THEME);
add_to_gui_list(ID_SEPARATOR, buf);
area.h += buf->next->size.h;
......
area.h += imp_h;
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
w = area.w;
/* exit button */
/* Exit button */
buf = pwindow->prev;
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
......
/* ====================================================================== */
/* ============================== INCITE DIALOG ========================= */
/* ====================================================================== */
static struct small_diplomat_dialog *incite_dlg = NULL;
static struct small_diplomat_dialog *incite_dlg = nullptr;
/**********************************************************************//**
User interacted with Incite Revolt dialog window.
......
static int diplomat_incite_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(incite_dlg->actor_unit_id)
&& NULL != game_city_by_number(incite_dlg->target_id)) {
if (game_unit_by_number(incite_dlg->actor_unit_id) != nullptr
&& game_city_by_number(incite_dlg->target_id) != nullptr) {
request_do_action(incite_dlg->act_id, incite_dlg->actor_unit_id,
incite_dlg->target_id, 0, "");
}
......
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
char tBuf[255], cbuf[255];
bool exit = FALSE;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = incite_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
city_name_get(pcity));
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL , buf);
......
area.h += buf->size.h;
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("City can't be incited!"), NULL);
_("City can't be incited!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Incite a revolt for %d gold?\n%s",
"Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Inciting a revolt costs %d gold.\n%s",
"Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("Traitors Demand Too Much!"), NULL);
_("Traitors Demand Too Much!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
}
incite_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
pcity->tile);
/* setup widget size and start position */
/* Setup widget size and start position */
buf = pwindow;
if (exit) {
/* exit button */
/* Exit button */
buf = buf->prev;
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
......
incite_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
/* Redraw */
redraw_group(incite_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
......
/* ====================================================================== */
/* ============================ BRIBE DIALOG ========================== */
/* ====================================================================== */
static struct small_diplomat_dialog *bribe_dlg = NULL;
static struct small_diplomat_dialog *bribe_dlg = nullptr;
/**********************************************************************//**
User interacted with bribe dialog window.
......
static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(bribe_dlg->actor_unit_id)
&& NULL != game_unit_by_number(bribe_dlg->target_id)) {
if (game_unit_by_number(bribe_dlg->actor_unit_id) != nullptr
&& game_unit_by_number(bribe_dlg->target_id) != nullptr) {
request_do_action(bribe_dlg->act_id, bribe_dlg->actor_unit_id,
bribe_dlg->target_id, 0, "");
}
......
static int diplomat_bribe_stack_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(bribe_dlg->actor_unit_id)) {
if (game_unit_by_number(bribe_dlg->actor_unit_id) != nullptr) {
request_do_action(bribe_dlg->act_id, bribe_dlg->actor_unit_id,
bribe_dlg->target_id, 0, "");
}
......
void popup_bribe_unit_dialog(struct unit *actor, struct unit *punit, int cost,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
char tBuf[255], cbuf[255];
bool exit = FALSE;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = bribe_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
PL_("Bribe unit for %d gold?\n%s",
"Bribe unit for %d gold?\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Bribing the unit costs %d gold.\n%s",
"Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("Traitors Demand Too Much!"), NULL);
_("Traitors Demand Too Much!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
char tBuf[255], cbuf[255];
bool exit = FALSE;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = bribe_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
PL_("Bribe unit stack for %d gold?\n%s",
"Bribe unit stack for %d gold?\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Bribing the unit stack costs %d gold.\n%s",
"Bribing the unit stack costs %d gold.\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("Traitors Demand Too Much!"), NULL);
_("Traitors Demand Too Much!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
client/gui-sdl3/action_dialog.c
void popdown_bribe_dialog(void);
static struct diplomat_dialog *diplomat_dlg = NULL;
static struct diplomat_dialog *diplomat_dlg = nullptr;
static bool is_more_user_input_needed = FALSE;
static bool did_not_decide = FALSE;
......
**************************************************************************/
static int spy_strike_bld_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_STRIKE_BUILDING,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
**************************************************************************/
static int spy_sabotage_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
**************************************************************************/
static int spy_sabotage_esc_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
int steal_advance = MAX_ID - pwidget->id;
int actor_id = diplomat_dlg->actor_unit_id;
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
if (steal_advance == A_UNSET) {
/* This is the untargeted version. */
request_do_action(get_non_targeted_action_id(
......
const struct research *presearch, *vresearch;
struct city *vcity = pwidget->data.city;
int id = diplomat_dlg->actor_unit_id;
struct player *victim = NULL;
struct player *victim = nullptr;
struct container *cont;
struct widget *buf = NULL;
struct widget *buf = nullptr;
struct widget *pwindow;
utf8_str *pstr;
SDL_Surface *surf;
......
FONTO_ATTENTION);
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = spy_steal_dlg_window_callback;
set_wstate(pwindow , FC_WS_NORMAL);
......
}
}
pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
pstr = create_utf8_str_fonto(nullptr, 0, FONTO_DEFAULT);
pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
count = 0;
......
area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + idx));
area.h = count * buf->size.h + adj_size(2);
/* alloca window theme and win background buffer */
/* Allocate window theme and win background buffer */
surf = theme_get_background(active_theme, BACKGROUND_SPYSTEALDLG);
if (resize_window(pwindow, surf, NULL,
if (resize_window(pwindow, surf, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h)) {
FREESURFACE(surf);
......
(main_window_width() - pwindow->size.w) / 2,
(main_window_height() - pwindow->size.h) / 2);
/* exit button */
/* Exit button */
buf = pwindow->prev;
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
......
static int diplomat_incite_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_INCITE_CITY,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
static int spy_incite_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
diplomat_dlg->target_ids[ATK_CITY])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr) {
request_action_details(ACTION_SPY_INCITE_CITY_ESC,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
......
static int diplomat_bribe_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL !=
game_unit_by_number(diplomat_dlg->target_ids[ATK_UNIT])) {
if (game_unit_by_number(diplomat_dlg->actor_unit_id) != nullptr
&& game_unit_by_number(diplomat_dlg->target_ids[ATK_UNIT]) != nullptr) {
request_action_details(ACTION_SPY_BRIBE_UNIT,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_UNIT]);
......
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit;
if (game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != NULL
if (game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]) != nullptr
&& (punit = game_unit_by_number(diplomat_dlg->actor_unit_id))) {
popup_unit_upgrade_dlg(punit, FALSE);
}
......
/* Actor */
fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
actor_id = diplomat_dlg->actor_unit_id;
if (NULL == game_unit_by_number(actor_id)) {
if (game_unit_by_number(actor_id) == nullptr) {
/* Probably dead. */
failed = TRUE;
}
......
switch (action_get_target_kind(paction)) {
case ATK_CITY:
target_id = diplomat_dlg->target_ids[ATK_CITY];
if (NULL == game_city_by_number(target_id)) {
if (game_city_by_number(target_id) == nullptr) {
/* Probably destroyed. */
failed = TRUE;
}
break;
case ATK_UNIT:
target_id = diplomat_dlg->target_ids[ATK_UNIT];
if (NULL == game_unit_by_number(target_id)) {
if (game_unit_by_number(target_id) == nullptr) {
/* Probably dead. */
failed = TRUE;
}
......
case ATK_TILE:
case ATK_EXTRAS:
target_id = diplomat_dlg->target_ids[ATK_TILE];
if (NULL == index_to_tile(&(wld.map), target_id)) {
if (index_to_tile(&(wld.map), target_id) == nullptr) {
/* TODO: Should this be possible at all? If not: add assertion. */
failed = TRUE;
}
......
switch (action_get_sub_target_kind(paction)) {
case ASTK_BUILDING:
sub_target = diplomat_dlg->sub_target_id[ASTK_BUILDING];
if (NULL == improvement_by_number(sub_target)) {
if (improvement_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
break;
case ASTK_TECH:
sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
if (NULL == valid_advance_by_number(sub_target)) {
if (valid_advance_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
......
case ASTK_EXTRA_NOT_THERE:
/* TODO: validate if the extra is there? */
sub_target = diplomat_dlg->sub_target_id[ASTK_EXTRA];
if (NULL == extra_by_number(sub_target)) {
if (extra_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
break;
case ASTK_SPECIALIST:
sub_target = diplomat_dlg->sub_target_id[ASTK_SPECIALIST];
if (nullptr == specialist_by_number(sub_target)) {
if (specialist_by_number(sub_target) == nullptr) {
/* Did the ruleset change? */
failed = TRUE;
}
......
case ASTK_COUNT:
/* Shouldn't happen. */
fc_assert(action_get_sub_target_kind(paction) != ASTK_NONE);
failed = TRUE;
break;
}
......
act_unit,
tgt_city);
if (af_map[act] == NULL) {
if (af_map[act] == nullptr) {
/* No special call back function needed for this action. */
cb = simple_action_callback;
} else {
......
struct extra_type *target_extra,
const struct act_prob *act_probs)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
SDL_Rect area;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = diplomat_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_CITY) {
action_entry(act, act_probs,
actor_unit, NULL, target_city, NULL,
actor_unit, nullptr, target_city, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_UNIT) {
action_entry(act, act_probs,
actor_unit, NULL, NULL, target_unit,
actor_unit, nullptr, nullptr, target_unit,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_STACK) {
action_entry(act, act_probs,
actor_unit, target_tile, NULL, NULL,
actor_unit, target_tile, nullptr, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_TILE) {
action_entry(act, act_probs,
actor_unit, target_tile, NULL, NULL,
actor_unit, target_tile, nullptr, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_EXTRAS) {
action_entry(act, act_probs,
actor_unit, target_tile, NULL, NULL,
actor_unit, target_tile, nullptr, nullptr,
pwindow, &area);
}
} action_iterate_end;
......
if (action_id_get_actor_kind(act) == AAK_UNIT
&& action_id_get_target_kind(act) == ATK_SELF) {
action_entry(act, act_probs,
actor_unit, NULL, NULL, target_unit,
actor_unit, nullptr, nullptr, target_unit,
pwindow, &area);
}
} action_iterate_end;
......
/* ---------- */
diplomat_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
unit_tile(actor_unit));
/* setup widget size and start position */
/* Setup widget size and start position */
buf = pwindow->prev;
setup_vertical_widgets_position(1,
......
diplomat_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
/* Redraw */
redraw_group(diplomat_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
......
sabotage_improvement = -1;
}
if (NULL != game_unit_by_number(diplomat_id)
&& NULL != game_city_by_number(diplomat_target_id)) {
if (game_unit_by_number(diplomat_id) != nullptr
&& game_city_by_number(diplomat_target_id) != nullptr) {
if (sabotage_improvement == B_LAST) {
/* This is the untargeted version. */
request_do_action(get_non_targeted_action_id(act_id),
......
void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL , *last = NULL;
struct widget *pwindow = nullptr, *buf = nullptr, *last = nullptr;
struct container *cont;
utf8_str *pstr;
SDL_Rect area, area2;
......
}
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = diplomat_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
area.w = MAX(area.w, buf->size.w);
area.h += buf->size.h;
/* separator */
buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
/* Separator */
buf = create_iconlabel(nullptr, pwindow->dst, nullptr, WF_FREE_THEME);
add_to_gui_list(ID_SEPARATOR, buf);
area.h += buf->next->size.h;
......
if (n > 0
&& action_prob_possible(actor->client.act_prob_cache[
get_non_targeted_action_id(paction->id)])) {
/* separator */
buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
/* Separator */
buf = create_iconlabel(nullptr, pwindow->dst, nullptr, WF_FREE_THEME);
add_to_gui_list(ID_SEPARATOR, buf);
area.h += buf->next->size.h;
......
area.h += imp_h;
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
w = area.w;
/* exit button */
/* Exit button */
buf = pwindow->prev;
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
......
/* ====================================================================== */
/* ============================== INCITE DIALOG ========================= */
/* ====================================================================== */
static struct small_diplomat_dialog *incite_dlg = NULL;
static struct small_diplomat_dialog *incite_dlg = nullptr;
/**********************************************************************//**
User interacted with Incite Revolt dialog window.
......
static int diplomat_incite_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(incite_dlg->actor_unit_id)
&& NULL != game_city_by_number(incite_dlg->target_id)) {
if (game_unit_by_number(incite_dlg->actor_unit_id) != nullptr
&& game_city_by_number(incite_dlg->target_id) != nullptr) {
request_do_action(incite_dlg->act_id, incite_dlg->actor_unit_id,
incite_dlg->target_id, 0, "");
}
......
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
char tBuf[255], cbuf[255];
bool exit = FALSE;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = incite_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
fc_snprintf(cbuf, sizeof(cbuf), _("You can't incite a revolt in %s."),
city_name_get(pcity));
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL , buf);
......
area.h += buf->size.h;
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("City can't be incited!"), NULL);
_("City can't be incited!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Incite a revolt for %d gold?\n%s",
"Incite a revolt for %d gold?\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Inciting a revolt costs %d gold.\n%s",
"Inciting a revolt costs %d gold.\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("Traitors Demand Too Much!"), NULL);
_("Traitors Demand Too Much!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
}
incite_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
pcity->tile);
/* setup widget size and start position */
/* Setup widget size and start position */
buf = pwindow;
if (exit) {
/* exit button */
/* Exit button */
buf = buf->prev;
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
......
incite_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
/* Redraw */
redraw_group(incite_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
......
/* ====================================================================== */
/* ============================ BRIBE DIALOG ========================== */
/* ====================================================================== */
static struct small_diplomat_dialog *bribe_dlg = NULL;
static struct small_diplomat_dialog *bribe_dlg = nullptr;
/**********************************************************************//**
User interacted with bribe dialog window.
......
static int diplomat_bribe_unit_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(bribe_dlg->actor_unit_id)
&& NULL != game_unit_by_number(bribe_dlg->target_id)) {
if (game_unit_by_number(bribe_dlg->actor_unit_id) != nullptr
&& game_unit_by_number(bribe_dlg->target_id) != nullptr) {
request_do_action(bribe_dlg->act_id, bribe_dlg->actor_unit_id,
bribe_dlg->target_id, 0, "");
}
......
static int diplomat_bribe_stack_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(bribe_dlg->actor_unit_id)) {
if (game_unit_by_number(bribe_dlg->actor_unit_id) != nullptr) {
request_do_action(bribe_dlg->act_id, bribe_dlg->actor_unit_id,
bribe_dlg->target_id, 0, "");
}
......
void popup_bribe_unit_dialog(struct unit *actor, struct unit *punit, int cost,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
char tBuf[255], cbuf[255];
bool exit = FALSE;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = bribe_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
PL_("Bribe unit for %d gold?\n%s",
"Bribe unit for %d gold?\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Bribing the unit costs %d gold.\n%s",
"Bribing the unit costs %d gold.\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("Traitors Demand Too Much!"), NULL);
_("Traitors Demand Too Much!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
......
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost,
const struct action *paction)
{
struct widget *pwindow = NULL, *buf = NULL;
struct widget *pwindow = nullptr, *buf = nullptr;
utf8_str *pstr;
char tBuf[255], cbuf[255];
bool exit = FALSE;
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pwindow = create_window_skeleton(nullptr, pstr, 0);
pwindow->action = bribe_dlg_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
......
PL_("Bribe unit stack for %d gold?\n%s",
"Bribe unit stack for %d gold?\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
PL_("Bribing the unit stack costs %d gold.\n%s",
"Bribing the unit stack costs %d gold.\n%s", cost), cost, tBuf);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/*------------*/
create_active_iconlabel(buf, pwindow->dst, pstr,
_("Traitors Demand Too Much!"), NULL);
_("Traitors Demand Too Much!"), nullptr);
add_to_gui_list(ID_LABEL, buf);
......
/* Setup window size and start position */
resize_window(pwindow, NULL, NULL,
resize_window(pwindow, nullptr, nullptr,
(pwindow->size.w - pwindow->area.w) + area.w,
(pwindow->size.h - pwindow->area.h) + area.h);
    (1-1/1)