Feature #2264 ยป 0068-diplomats.c-Replace-NULL-with-nullptr.patch
| server/diplomats.c | ||
|---|---|---|
|
/* Check if the Diplomat/Spy succeeds against defending Diplomats/Spies. */
|
||
|
if (!diplomat_infiltrate_tile(pplayer, cplayer, paction,
|
||
|
pdiplomat, NULL, ctile, NULL)) {
|
||
|
pdiplomat, nullptr, ctile, nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
/* Update clients. */
|
||
|
city_refresh (pcity);
|
||
|
send_city_info(NULL, pcity);
|
||
|
send_city_info(nullptr, pcity);
|
||
|
} else {
|
||
|
/* Notify everybody involved. */
|
||
|
notify_player(pplayer, ctile, E_MY_DIPLOMAT_POISON, ftc_server,
|
||
| ... | ... | |
|
/* Battle all units capable of diplomatic defense. */
|
||
|
if (!diplomat_infiltrate_tile(act_player, tgt_player,
|
||
|
paction,
|
||
|
act_unit, NULL, tgt_tile, NULL)) {
|
||
|
act_unit, nullptr, tgt_tile, nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
if (city_illness_strike(tgt_city)) {
|
||
|
/* Update the clients. */
|
||
|
city_refresh(tgt_city);
|
||
|
send_city_info(NULL, tgt_city);
|
||
|
send_city_info(nullptr, tgt_city);
|
||
|
}
|
||
|
/* Notify everyone involved. */
|
||
| ... | ... | |
|
if (any_web_conns()) {
|
||
|
webp_ptr = &web_packet;
|
||
|
} else {
|
||
|
webp_ptr = NULL;
|
||
|
webp_ptr = nullptr;
|
||
|
}
|
||
|
routes = trade_route_packet_list_new();
|
||
| ... | ... | |
|
if (!utype_is_consumed_by_action(paction, unit_type_get(pdiplomat))) {
|
||
|
/* This unit isn't about to be consumed. Send updated unit information
|
||
|
* to the clients. */
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
}
|
||
|
dlsend_packet_investigate_finished(pplayer->connections, pcity->id);
|
||
| ... | ... | |
|
if (!utype_is_consumed_by_action(paction, unit_type_get(pdiplomat))) {
|
||
|
/* This unit isn't about to be consumed. Send updated unit information
|
||
|
* to the clients. */
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
}
|
||
|
return TRUE;
|
||
| ... | ... | |
|
paction,
|
||
|
pdiplomat, pvictim,
|
||
|
unit_tile(pvictim),
|
||
|
NULL)) {
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
} else {
|
||
|
/* Sabotage the unit by removing half its remaining hit points. */
|
||
|
pvictim->hp /= 2;
|
||
|
send_unit_info(NULL, pvictim);
|
||
|
send_unit_info(nullptr, pvictim);
|
||
|
/* Notify everybody involved. */
|
||
|
notify_player(pplayer, unit_tile(pvictim),
|
||
| ... | ... | |
|
unit_tile(pvictim), victim_link);
|
||
|
/* Now lets see if the spy survives. */
|
||
|
diplomat_escape(pplayer, pdiplomat, NULL, paction);
|
||
|
diplomat_escape(pplayer, pdiplomat, nullptr, paction);
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
paction,
|
||
|
pdiplomat, pvictim,
|
||
|
pvictim->tile,
|
||
|
NULL)) {
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
if (!unit_is_alive(diplomat_id)) {
|
||
|
/* Destroyed by a script */
|
||
|
pdiplomat = NULL;
|
||
|
pdiplomat = nullptr;
|
||
|
}
|
||
|
/* Notify everybody involved. */
|
||
| ... | ... | |
|
/* The unit may have been on a tile shared with a city or a unit
|
||
|
* it no longer can share a tile with. */
|
||
|
pcity = tile_city(unit_tile(pvictim));
|
||
|
bounce = ((NULL != pcity
|
||
|
bounce = ((pcity != nullptr
|
||
|
&& !pplayers_allied(city_owner(pcity), unit_owner(pvictim)))
|
||
|
/* Keep the old behavior (insto check is_non_allied_unit_tile) */
|
||
|
|| 1 < unit_list_size(unit_tile(pvictim)->units));
|
||
| ... | ... | |
|
* been bounced because it couldn't share tile with a unit or city. */
|
||
|
if (!bounce
|
||
|
/* Try to perform post move forced actions. */
|
||
|
&& (NULL == action_auto_perf_unit_do(AAPC_POST_ACTION, pdiplomat,
|
||
|
uplayer, NULL, paction,
|
||
|
victim_tile, tile_city(victim_tile),
|
||
|
pvictim, NULL))
|
||
|
&& (action_auto_perf_unit_do(AAPC_POST_ACTION, pdiplomat,
|
||
|
uplayer, nullptr, paction,
|
||
|
victim_tile, tile_city(victim_tile),
|
||
|
pvictim, nullptr) == nullptr)
|
||
|
/* May have died while trying to do forced actions. */
|
||
|
&& unit_is_alive(diplomat_id)) {
|
||
|
pdiplomat->moves_left = 0;
|
||
|
}
|
||
|
if (NULL != player_unit_by_number(pplayer, diplomat_id)) {
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
if (player_unit_by_number(pplayer, diplomat_id) != nullptr) {
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
}
|
||
|
/* Update clients. */
|
||
|
send_player_all_c(pplayer, NULL);
|
||
|
send_player_all_c(pplayer, nullptr);
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
pcity = tile_city(pvictim);
|
||
|
if (pcity != NULL && !pplayers_allied(city_owner(pcity), pplayer)) {
|
||
|
if (pcity != nullptr && !pplayers_allied(city_owner(pcity), pplayer)) {
|
||
|
bounce = TRUE;
|
||
|
}
|
||
| ... | ... | |
|
if (!unit_is_alive(diplomat_id)) {
|
||
|
/* Destroyed by a script */
|
||
|
pdiplomat = NULL;
|
||
|
pdiplomat = nullptr;
|
||
|
}
|
||
|
act_utype = unit_type_get(pdiplomat);
|
||
| ... | ... | |
|
* been bounced because it couldn't share tile with a unit or city. */
|
||
|
if (!bounce
|
||
|
/* Try to perform post move forced actions. */
|
||
|
&& (NULL == action_auto_perf_unit_do(AAPC_POST_ACTION, pdiplomat,
|
||
|
NULL, NULL, paction,
|
||
|
pvictim, pcity,
|
||
|
NULL, NULL))
|
||
|
&& (action_auto_perf_unit_do(AAPC_POST_ACTION, pdiplomat,
|
||
|
nullptr, nullptr, paction,
|
||
|
pvictim, pcity,
|
||
|
nullptr, nullptr) == nullptr)
|
||
|
/* May have died while trying to do forced actions. */
|
||
|
&& unit_is_alive(diplomat_id)) {
|
||
|
pdiplomat->moves_left = 0;
|
||
|
}
|
||
|
if (NULL != player_unit_by_number(pplayer, diplomat_id)) {
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
if (player_unit_by_number(pplayer, diplomat_id) != nullptr) {
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
}
|
||
|
/* Update clients. */
|
||
|
send_player_all_c(pplayer, NULL);
|
||
|
send_player_all_c(pplayer, nullptr);
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
struct tile *tgt_tile, const struct action *paction)
|
||
|
{
|
||
|
int act_unit_id;
|
||
|
struct player *tgt_player = NULL;
|
||
|
struct player *tgt_player = nullptr;
|
||
|
const struct unit_type *act_utype;
|
||
|
/* Sanity check: The actor still exists. */
|
||
| ... | ... | |
|
act_unit_id = act_unit->id;
|
||
|
/* Do the diplomatic battle against a diplomatic defender. */
|
||
|
diplomat_infiltrate_tile(act_player, NULL,
|
||
|
diplomat_infiltrate_tile(act_player, nullptr,
|
||
|
paction,
|
||
|
act_unit, NULL, tgt_tile,
|
||
|
act_unit, nullptr, tgt_tile,
|
||
|
&tgt_player);
|
||
|
/* Sanity check: the defender had an owner. */
|
||
|
fc_assert_ret_val(tgt_player != NULL, TRUE);
|
||
|
fc_assert_ret_val(tgt_player != nullptr, TRUE);
|
||
|
if (!unit_is_alive(act_unit_id)) {
|
||
|
/* action_consequence_caught() is handled in
|
||
| ... | ... | |
|
/* Check if the Diplomat/Spy succeeds against defending Diplomats/Spies. */
|
||
|
if (!diplomat_infiltrate_tile(pplayer, cplayer,
|
||
|
paction,
|
||
|
pdiplomat, NULL,
|
||
|
pdiplomat, nullptr,
|
||
|
pcity->tile,
|
||
|
NULL)) {
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
_("No new technology found in %s."),
|
||
|
city_link(pcity));
|
||
|
diplomat_charge_movement (pdiplomat, pcity->tile);
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
return FALSE;
|
||
|
}
|
||
|
/* Update stealing player's science progress and research fields */
|
||
|
send_player_all_c(pplayer, NULL);
|
||
|
send_player_all_c(pplayer, nullptr);
|
||
|
/* Record the theft. */
|
||
|
(pcity->steal)++;
|
||
| ... | ... | |
|
/* Roll the dice. */
|
||
|
if (fc_rand(100) < game.server.incite_gold_loss_chance) {
|
||
|
notify_player(dec_player, NULL, E_MY_DIPLOMAT_FAILED, ftc_server,
|
||
|
notify_player(dec_player, nullptr, E_MY_DIPLOMAT_FAILED, ftc_server,
|
||
|
PL_("Your %d gold prepared to incite the revolt was lost!",
|
||
|
"Your %d gold prepared to incite the revolt was lost!",
|
||
|
revolt_gold), revolt_gold);
|
||
| ... | ... | |
|
* Roll the dice twice. */
|
||
|
if (fc_rand(100) < game.server.incite_gold_capt_chance) {
|
||
|
inc_player->economic.gold += revolt_gold;
|
||
|
notify_player(inc_player, NULL, E_ENEMY_DIPLOMAT_FAILED,
|
||
|
notify_player(inc_player, nullptr, E_ENEMY_DIPLOMAT_FAILED,
|
||
|
ftc_server,
|
||
|
PL_("Your security service captured %d gold prepared "
|
||
|
"to incite your town!",
|
||
| ... | ... | |
|
"to incite your town!", revolt_gold), revolt_gold);
|
||
|
}
|
||
|
/* Update clients. */
|
||
|
send_player_all_c(dec_player, NULL);
|
||
|
send_player_all_c(inc_player, NULL);
|
||
|
send_player_all_c(dec_player, nullptr);
|
||
|
send_player_all_c(inc_player, nullptr);
|
||
|
return TRUE;
|
||
|
} else {
|
||
| ... | ... | |
|
/* Check if the Diplomat/Spy succeeds against defending Diplomats/Spies. */
|
||
|
if (!diplomat_infiltrate_tile(pplayer, cplayer,
|
||
|
paction,
|
||
|
pdiplomat, NULL,
|
||
|
pdiplomat, nullptr,
|
||
|
pcity->tile,
|
||
|
NULL)) {
|
||
|
nullptr)) {
|
||
|
diplomat_may_lose_gold(pplayer, cplayer, revolt_cost / 2 );
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
/* Check if the Diplomat/Spy succeeds against defending Diplomats/Spies. */
|
||
|
if (!diplomat_infiltrate_tile(pplayer, cplayer,
|
||
|
paction,
|
||
|
pdiplomat, NULL,
|
||
|
pdiplomat, nullptr,
|
||
|
pcity->tile,
|
||
|
NULL)) {
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
unit_link(pdiplomat),
|
||
|
city_link(pcity));
|
||
|
diplomat_charge_movement(pdiplomat, pcity->tile);
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
log_debug("sabotage: random: nothing to do");
|
||
|
return FALSE;
|
||
|
}
|
||
|
if (count == 0 || fc_rand (2) == 1) {
|
||
|
ptarget = NULL;
|
||
|
ptarget = nullptr;
|
||
|
log_debug("sabotage: random: targeted production");
|
||
|
} else {
|
||
|
ptarget = NULL;
|
||
|
ptarget = nullptr;
|
||
|
which = fc_rand (count);
|
||
|
city_built_iterate(pcity, pimprove) {
|
||
|
if (pimprove->sabotage > 0) {
|
||
|
if (which > 0) {
|
||
|
which--;
|
||
|
} else {
|
||
|
ptarget = pimprove;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (pimprove->sabotage > 0) {
|
||
|
if (which > 0) {
|
||
|
which--;
|
||
|
} else {
|
||
|
ptarget = pimprove;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
} city_built_iterate_end;
|
||
|
if (NULL != ptarget) {
|
||
|
if (ptarget != nullptr) {
|
||
|
log_debug("sabotage: random: targeted improvement: %d (%s)",
|
||
|
improvement_number(ptarget),
|
||
|
improvement_rule_name(ptarget));
|
||
| ... | ... | |
|
}
|
||
|
} else if (improvement < 0) {
|
||
|
/* If told to sabotage production, do so. */
|
||
|
ptarget = NULL;
|
||
|
ptarget = nullptr;
|
||
|
log_debug("sabotage: specified target production");
|
||
|
} else {
|
||
|
struct impr_type *pimprove = improvement_by_number(improvement);
|
||
|
if (pimprove == NULL) {
|
||
|
if (pimprove == nullptr) {
|
||
|
log_error("sabotage: requested for invalid improvement %d", improvement);
|
||
|
return FALSE;
|
||
|
}
|
||
|
/*
|
||
|
* Told which improvement to pick:
|
||
|
* If try for wonder or palace, complain, deduct movement cost and return.
|
||
| ... | ... | |
|
*/
|
||
|
if (city_has_building(pcity, pimprove)) {
|
||
|
if (pimprove->sabotage > 0) {
|
||
|
ptarget = pimprove;
|
||
|
ptarget = pimprove;
|
||
|
log_debug("sabotage: specified target improvement: %d (%s)",
|
||
|
improvement, improvement_rule_name(pimprove));
|
||
|
} else {
|
||
| ... | ... | |
|
_("You cannot sabotage a %s!"),
|
||
|
improvement_name_translation(pimprove));
|
||
|
diplomat_charge_movement(pdiplomat, pcity->tile);
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
log_debug("sabotage: disallowed target improvement: %d (%s)",
|
||
|
improvement, improvement_rule_name(pimprove));
|
||
|
return FALSE;
|
||
| ... | ... | |
|
improvement_name_translation(pimprove),
|
||
|
city_link(pcity));
|
||
|
diplomat_charge_movement(pdiplomat, pcity->tile);
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
log_debug("sabotage: target improvement not found: %d (%s)",
|
||
|
improvement, improvement_rule_name(pimprove));
|
||
|
return FALSE;
|
||
| ... | ... | |
|
}
|
||
|
/* Now, the fun stuff! Do the sabotage! */
|
||
|
if (NULL == ptarget) {
|
||
|
if (ptarget == nullptr) {
|
||
|
char prod[256];
|
||
|
/* Do it. */
|
||
| ... | ... | |
|
}
|
||
|
/* Update clients. */
|
||
|
send_city_info(NULL, pcity);
|
||
|
send_city_info(nullptr, pcity);
|
||
|
/* this may cause a diplomatic incident */
|
||
|
/* This may cause a diplomatic incident */
|
||
|
action_consequence_success(paction, pplayer, act_utype, cplayer,
|
||
|
city_tile(pcity), city_link(pcity));
|
||
| ... | ... | |
|
/* Battle all units capable of diplomatic defense. */
|
||
|
if (!diplomat_infiltrate_tile(act_player, tgt_player,
|
||
|
paction,
|
||
|
act_unit, NULL, tgt_tile,
|
||
|
NULL)) {
|
||
|
act_unit, nullptr, tgt_tile,
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
/* Battle all units capable of diplomatic defense. */
|
||
|
if (!diplomat_infiltrate_tile(act_player, tgt_player,
|
||
|
paction,
|
||
|
act_unit, NULL, tgt_tile,
|
||
|
NULL)) {
|
||
|
act_unit, nullptr, tgt_tile,
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
/* Steal it. */
|
||
|
normal_tile_prob = 100
|
||
|
+ get_target_bonus_effects(NULL,
|
||
|
+ get_target_bonus_effects(nullptr,
|
||
|
&(const struct req_context) {
|
||
|
.player = act_player,
|
||
|
/* City: Decide once requests from ruleset
|
||
| ... | ... | |
|
/* Battle all units capable of diplomatic defense. */
|
||
|
if (!diplomat_infiltrate_tile(act_player, tgt_player,
|
||
|
paction,
|
||
|
act_unit, NULL, tgt_tile,
|
||
|
NULL)) {
|
||
|
act_unit, nullptr, tgt_tile,
|
||
|
nullptr)) {
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
if (utype_is_consumed_by_action(paction, unit_type_get(act_unit))) {
|
||
|
/* The unit must be wiped here so it won't be seen as a victim of the
|
||
|
* detonation of its own nuke. */
|
||
|
wipe_unit(act_unit, ULR_USED, NULL);
|
||
|
wipe_unit(act_unit, ULR_USED, nullptr);
|
||
|
}
|
||
|
/* Detonate the nuke. */
|
||
| ... | ... | |
|
const struct veteran_level
|
||
|
*vdef = utype_veteran_level(unit_type_get(pdefender), pdefender->veteran);
|
||
|
fc_assert_ret_val(vatt != NULL && vdef != NULL, FALSE);
|
||
|
fc_assert_ret_val(vatt != nullptr && vdef != nullptr, FALSE);
|
||
|
chance += vatt->power_fact - vdef->power_fact;
|
||
|
}
|
||
|
/* Reduce the chance of an attack by EFT_SPY_RESISTANT percent. */
|
||
|
chance -= chance * get_target_bonus_effects(
|
||
|
NULL,
|
||
|
nullptr,
|
||
|
&(const struct req_context) {
|
||
|
.player = tile_owner(pdefender_tile),
|
||
|
.city = tile_city(pdefender_tile),
|
||
|
.tile = pdefender_tile,
|
||
|
},
|
||
|
NULL,
|
||
|
nullptr,
|
||
|
EFT_SPY_RESISTANT
|
||
|
) / 100;
|
||
| ... | ... | |
|
This determines if a diplomat/spy succeeds in infiltrating a tile.
|
||
|
- The infiltrator must go up against each defender.
|
||
|
- The victim unit won't defend. (NULL if everyone should defend)
|
||
|
- The victim unit won't defend. (nullptr if everyone should defend)
|
||
|
- One or the other is eliminated in each contest.
|
||
|
- Return TRUE if the infiltrator succeeds.
|
||
|
'pplayer' is the player who tries to do a spy/diplomat action on 'ptile'
|
||
|
with the unit 'pdiplomat' against 'cplayer'. If 'cplayer' is NULL the
|
||
|
with the unit 'pdiplomat' against 'cplayer'. If 'cplayer' is nullptr the
|
||
|
owner of the chosen defender, if a defender can be chosen, gets its
|
||
|
role.
|
||
|
'defender_owner' is, if non NULL, set to the owner of the unit that
|
||
|
'defender_owner' is, if non nullptr, set to the owner of the unit that
|
||
|
defended.
|
||
|
****************************************************************************/
|
||
|
static bool diplomat_infiltrate_tile(struct player *pplayer,
|
||
| ... | ... | |
|
paction))) {
|
||
|
struct player *uplayer = unit_owner(punit);
|
||
|
if (defender_owner != NULL) {
|
||
|
if (defender_owner != nullptr) {
|
||
|
/* Some action performers may want to know defender player. */
|
||
|
*defender_owner = uplayer;
|
||
|
}
|
||
| ... | ... | |
|
link_unit, link_diplomat);
|
||
|
if (pcity) {
|
||
|
if (uplayer == cplayer || cplayer == NULL) {
|
||
|
if (uplayer == cplayer || cplayer == nullptr) {
|
||
|
notify_player(uplayer, ptile, E_MY_DIPLOMAT_FAILED, ftc_server,
|
||
|
/* TRANS: <unit> ... <city> ... <diplomat> */
|
||
|
_("Your %s has been eliminated defending %s"
|
||
| ... | ... | |
|
link_city, link_diplomat);
|
||
|
}
|
||
|
} else {
|
||
|
if (uplayer == cplayer || cplayer == NULL) {
|
||
|
if (uplayer == cplayer || cplayer == nullptr) {
|
||
|
notify_player(uplayer, ptile, E_MY_DIPLOMAT_FAILED, ftc_server,
|
||
|
/* TRANS: <unit> ... <diplomat> */
|
||
|
_("Your %s has been eliminated defending "
|
||
| ... | ... | |
|
game.info.combat_odds_scaled_veterancy ? att_vet : 100)) {
|
||
|
notify_unit_experience(pdiplomat);
|
||
|
}
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
wipe_unit(punit, ULR_ELIMINATED, pplayer);
|
||
|
return FALSE;
|
||
|
} else {
|
||
| ... | ... | |
|
link_diplomat, link_unit);
|
||
|
if (pcity) {
|
||
|
if (uplayer == cplayer || cplayer == NULL) {
|
||
|
if (uplayer == cplayer || cplayer == nullptr) {
|
||
|
notify_player(uplayer, ptile, E_ENEMY_DIPLOMAT_FAILED, ftc_server,
|
||
|
_("Eliminated a %s %s while infiltrating %s."),
|
||
|
nation_adjective_for_player(pplayer),
|
||
| ... | ... | |
|
link_diplomat, link_city);
|
||
|
}
|
||
|
} else {
|
||
|
if (uplayer == cplayer || cplayer == NULL) {
|
||
|
if (uplayer == cplayer || cplayer == nullptr) {
|
||
|
notify_player(uplayer, ptile, E_ENEMY_DIPLOMAT_FAILED, ftc_server,
|
||
|
_("Eliminated a %s %s while infiltrating our troops."),
|
||
|
nation_adjective_for_player(pplayer),
|
||
| ... | ... | |
|
notify_unit_experience(punit);
|
||
|
}
|
||
|
victim_link = NULL;
|
||
|
victim_link = nullptr;
|
||
|
switch (action_get_target_kind(paction)) {
|
||
|
case ATK_CITY:
|
||
| ... | ... | |
|
break;
|
||
|
}
|
||
|
fc_assert(victim_link != NULL);
|
||
|
fc_assert(victim_link != nullptr);
|
||
|
action_consequence_caught(paction, pplayer, act_utype, uplayer,
|
||
|
ptile, victim_link);
|
||
| ... | ... | |
|
/************************************************************************//**
|
||
|
This determines if a diplomat/spy survives and escapes.
|
||
|
If "pcity" is NULL, assume action was in the field.
|
||
|
If "pcity" is nullptr, assume action was in the field.
|
||
|
Spies have a game.server.diplchance specified chance of survival (better
|
||
|
if veteran):
|
||
| ... | ... | |
|
vlink = city_link(pcity);
|
||
|
} else {
|
||
|
ptile = unit_tile(pdiplomat);
|
||
|
vlink = NULL;
|
||
|
vlink = nullptr;
|
||
|
}
|
||
|
return diplomat_escape_full(pplayer, pdiplomat, pcity != NULL,
|
||
|
return diplomat_escape_full(pplayer, pdiplomat, pcity != nullptr,
|
||
|
ptile, vlink, paction);
|
||
|
}
|
||
| ... | ... | |
|
+ (vunit->power_fact - vbase->power_fact);
|
||
|
}
|
||
|
/* find closest city for escape target */
|
||
|
spyhome = find_closest_city(ptile, NULL, unit_owner(pdiplomat), FALSE,
|
||
|
FALSE, FALSE, TRUE, FALSE, NULL);
|
||
|
/* Find closest city for escape target */
|
||
|
spyhome = find_closest_city(ptile, nullptr, unit_owner(pdiplomat), FALSE,
|
||
|
FALSE, FALSE, TRUE, FALSE, nullptr);
|
||
|
if (spyhome
|
||
|
&& !utype_is_consumed_by_action(paction, dipltype)
|
||
| ... | ... | |
|
/* Handled by the ruleset. */
|
||
|
0,
|
||
|
FALSE)) {
|
||
|
send_unit_info(NULL, pdiplomat);
|
||
|
send_unit_info(nullptr, pdiplomat);
|
||
|
log_error("Bug in diplomat_escape: Spy can't teleport.");
|
||
|
return;
|
||
|
}
|
||
| ... | ... | |
|
if (!utype_is_consumed_by_action(paction, dipltype)) {
|
||
|
/* The unit was caught, not spent. It must therefore be deleted by
|
||
|
* hand. */
|
||
|
wipe_unit(pdiplomat, ULR_CAUGHT, NULL);
|
||
|
wipe_unit(pdiplomat, ULR_CAUGHT, nullptr);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
const char *vlink;
|
||
|
const struct unit_type *act_utype = unit_type_get(actor_unit);
|
||
|
if (target_city != NULL) {
|
||
|
if (target_city != nullptr) {
|
||
|
fc_assert(city_tile(target_city) == target_tile);
|
||
|
vlink = city_link(target_city);
|
||
|
} else {
|
||
| ... | ... | |
|
target_tile, vlink);
|
||
|
/* Try to escape. */
|
||
|
diplomat_escape_full(pplayer, actor_unit, target_city != NULL,
|
||
|
diplomat_escape_full(pplayer, actor_unit, target_city != nullptr,
|
||
|
target_tile, vlink, paction);
|
||
|
return TRUE;
|
||