Feature #1702 ยป 0010-actions.-ch-Replace-NULL-with-nullptr.patch
| common/actions.c | ||
|---|---|---|
|
for (i = 0; i < ACTRES_LAST; i++) {
|
||
|
action_list_destroy(actlist_by_result[i]);
|
||
|
actlist_by_result[i] = NULL;
|
||
|
actlist_by_result[i] = nullptr;
|
||
|
}
|
||
|
for (i = 0; i < ACTIVITY_LAST; i++) {
|
||
|
action_list_destroy(actlist_by_activity[i]);
|
||
|
actlist_by_activity[i] = NULL;
|
||
|
actlist_by_activity[i] = nullptr;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Return the action with the given name.
|
||
|
Returns NULL if no action with the given name exists.
|
||
|
Returns nullptr if no action with the given name exists.
|
||
|
**************************************************************************/
|
||
|
struct action *action_by_rule_name(const char *name)
|
||
|
{
|
||
| ... | ... | |
|
log_verbose("Asked for non existing action named %s", name);
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
return action_by_number(act_id);
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
bool action_has_complex_target(const struct action *paction)
|
||
|
{
|
||
|
fc_assert_ret_val(paction != NULL, FALSE);
|
||
|
fc_assert_ret_val(paction != nullptr, FALSE);
|
||
|
return paction->target_complexity >= ACT_TGT_COMPL_FLEXIBLE;
|
||
|
}
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
bool action_requires_details(const struct action *paction)
|
||
|
{
|
||
|
fc_assert_ret_val(paction != NULL, FALSE);
|
||
|
fc_assert_ret_val(paction != nullptr, FALSE);
|
||
|
return paction->target_complexity >= ACT_TGT_COMPL_MANDATORY;
|
||
|
}
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
const char *action_id_name_translation(action_id act_id)
|
||
|
{
|
||
|
return action_prepare_ui_name(act_id, "", ACTPROB_NA, NULL);
|
||
|
return action_prepare_ui_name(act_id, "", ACTPROB_NA, nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
const char *action_get_ui_name_mnemonic(action_id act_id,
|
||
|
const char *mnemonic)
|
||
|
{
|
||
|
return action_prepare_ui_name(act_id, mnemonic, ACTPROB_NA, NULL);
|
||
|
return action_prepare_ui_name(act_id, mnemonic, ACTPROB_NA, nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns a text representation of the action probability prob unless it
|
||
|
is a signal. Returns NULL if prob is a signal.
|
||
|
is a signal. Returns nullptr if prob is a signal.
|
||
|
The returned string is in statically allocated astring, and thus this
|
||
|
function is not thread-safe.
|
||
| ... | ... | |
|
|| action_prob_not_relevant(prob));
|
||
|
/* Unknown because of missing server support or should not exits. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
if (prob.min == prob.max) {
|
||
| ... | ... | |
|
"Invalid action %d", act_id);
|
||
|
/* and no custom text will be inserted */
|
||
|
fc_assert(custom == NULL || custom[0] == '\0');
|
||
|
fc_assert(custom == nullptr || custom[0] == '\0');
|
||
|
/* Make the best of what is known */
|
||
|
astr_set(&ui_name_str, _("%s%s (name may be wrong)"),
|
||
| ... | ... | |
|
probtxt = action_prob_to_text(prob);
|
||
|
/* Format the info part of the action's UI name. */
|
||
|
if (probtxt != NULL && custom != NULL) {
|
||
|
if (probtxt != nullptr && custom != nullptr) {
|
||
|
/* TRANS: action UI name's info part with custom info and probability.
|
||
|
* Hint: you can move the paren handling from this string to the action
|
||
|
* names if you need to add extra information (like a mnemonic letter
|
||
| ... | ... | |
|
* to add the extra information to every action name or remove the
|
||
|
* surrounding parens. */
|
||
|
astr_set(&chance, _(" (%s; %s)"), custom, probtxt);
|
||
|
} else if (probtxt != NULL) {
|
||
|
} else if (probtxt != nullptr) {
|
||
|
/* TRANS: action UI name's info part with probability.
|
||
|
* Hint: you can move the paren handling from this string to the action
|
||
|
* names if you need to add extra information (like a mnemonic letter
|
||
| ... | ... | |
|
* to add the extra information to every action name or remove the
|
||
|
* surrounding parens. */
|
||
|
astr_set(&chance, _(" (%s)"), probtxt);
|
||
|
} else if (custom != NULL) {
|
||
|
} else if (custom != nullptr) {
|
||
|
/* TRANS: action UI name's info part with custom info.
|
||
|
* Hint: you can move the paren handling from this string to the action
|
||
|
* names if you need to add extra information (like a mnemonic letter
|
||
| ... | ... | |
|
action_enablers_for_action(action_id action)
|
||
|
{
|
||
|
/* Sanity check: a non existing action doesn't have enablers. */
|
||
|
fc_assert_ret_val(action_id_exists(action), NULL);
|
||
|
fc_assert_ret_val(action_id_exists(action), nullptr);
|
||
|
return action_enablers_by_action[action];
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns a suggestion to add an obligatory hard requirement to an action
|
||
|
enabler or NULL if no hard obligatory reqs were missing. It is the
|
||
|
enabler or nullptr if no hard obligatory reqs were missing. It is the
|
||
|
responsibility of the caller to free the suggestion when it is done with
|
||
|
it.
|
||
|
@param enabler the action enabler to suggest a fix for.
|
||
|
@param oblig hard obligatory requirements to check
|
||
|
@return a problem with fix suggestions or NULL if no obligatory hard
|
||
|
@return a problem with fix suggestions or nullptr if no obligatory hard
|
||
|
requirement problems were detected.
|
||
|
**************************************************************************/
|
||
|
static struct req_vec_problem *
|
||
| ... | ... | |
|
/* Sanity check: a non existing action enabler is missing but it doesn't
|
||
|
* miss any obligatory hard requirements. */
|
||
|
fc_assert_ret_val(enabler, NULL);
|
||
|
fc_assert_ret_val(enabler, nullptr);
|
||
|
/* Sanity check: a non existing action doesn't have any obligatory hard
|
||
|
* requirements. */
|
||
|
fc_assert_ret_val(action_id_exists(enabler_get_action_id(enabler)), NULL);
|
||
|
fc_assert_ret_val(action_id_exists(enabler_get_action_id(enabler)), nullptr);
|
||
|
paction = enabler_get_action(enabler);
|
||
|
/* No obligatory hard requirements. */
|
||
|
fc_assert_ret_val(oblig, NULL);
|
||
|
fc_assert_ret_val(oblig, nullptr);
|
||
|
obligatory_req_vector_iterate(oblig, obreq) {
|
||
|
struct req_vec_problem *out;
|
||
| ... | ... | |
|
} obligatory_req_vector_iterate_end;
|
||
|
/* No obligatory req problems found. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns a suggestion to add an obligatory hard requirement to an action
|
||
|
enabler or NULL if no hard obligatory reqs were missing. It is the
|
||
|
enabler or nullptr if no hard obligatory reqs were missing. It is the
|
||
|
responsibility of the caller to free the suggestion when it is done with
|
||
|
it.
|
||
|
@param enabler the action enabler to suggest a fix for.
|
||
|
@return a problem with fix suggestions or NULL if no obligatory hard
|
||
|
@return a problem with fix suggestions or nullptr if no obligatory hard
|
||
|
requirement problems were detected.
|
||
|
**************************************************************************/
|
||
|
struct req_vec_problem *
|
||
| ... | ... | |
|
/* Sanity check: a non existing action enabler is missing but it doesn't
|
||
|
* miss any obligatory hard requirements. */
|
||
|
fc_assert_ret_val(enabler, NULL);
|
||
|
fc_assert_ret_val(enabler, nullptr);
|
||
|
/* Sanity check: a non existing action doesn't have any obligatory hard
|
||
|
* requirements. */
|
||
|
fc_assert_ret_val(action_id_exists(enabler_get_action_id(enabler)), NULL);
|
||
|
fc_assert_ret_val(action_id_exists(enabler_get_action_id(enabler)), nullptr);
|
||
|
paction = enabler_get_action(enabler);
|
||
|
if (paction->result != ACTRES_NONE) {
|
||
|
/* A hard coded action result may mean obligatory requirements. */
|
||
|
out = ae_suggest_repair_if_no_oblig(enabler, oblig_hard_reqs_get(paction->result));
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
/* The action has this sub result. Check its hard requirements. */
|
||
|
out = ae_suggest_repair_if_no_oblig(enabler,
|
||
|
oblig_hard_reqs_get_sub(sub_res));
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
|
}
|
||
|
/* No obligatory req problems found. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the first local DiplRel requirement in the specified requirement
|
||
|
vector or NULL if it doesn't have a local DiplRel requirement.
|
||
|
vector or nullptr if it doesn't have a local DiplRel requirement.
|
||
|
@param vec the requirement vector to look in
|
||
|
@return the first local DiplRel requirement.
|
||
|
**************************************************************************/
|
||
| ... | ... | |
|
}
|
||
|
} requirement_vector_iterate_end;
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Detects a local DiplRel requirement in a tile targeted action without
|
||
|
an explicit claimed requirement in the target reqs.
|
||
|
@param enabler the enabler to look at
|
||
|
@return the problem or NULL if no problem was found
|
||
|
@return the problem or nullptr if no problem was found
|
||
|
**************************************************************************/
|
||
|
static struct req_vec_problem *
|
||
|
enabler_tile_tgt_local_diplrel_implies_claimed(
|
||
| ... | ... | |
|
if (action_get_target_kind(paction) != ATK_TILE) {
|
||
|
/* Not tile targeted */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
local_diplrel = req_vec_first_local_diplrel(&enabler->actor_reqs);
|
||
|
if (local_diplrel == NULL) {
|
||
|
if (local_diplrel == nullptr) {
|
||
|
/* No local diplrel */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/* Tile is unclaimed as a requirement. */
|
||
| ... | ... | |
|
if (claimed_req) {
|
||
|
/* Already clear */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/* Tile is claimed as a requirement. */
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Returns the first action enabler specific contradiction in the specified
|
||
|
enabler or NULL if no enabler specific contradiction is found.
|
||
|
enabler or nullptr if no enabler specific contradiction is found.
|
||
|
@param enabler the enabler to look at
|
||
|
@return the first problem and maybe a suggested fix
|
||
|
**************************************************************************/
|
||
| ... | ... | |
|
if (action_get_target_kind(paction) != ATK_TILE) {
|
||
|
/* Not tile targeted */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
local_diplrel = req_vec_first_local_diplrel(&enabler->actor_reqs);
|
||
|
if (local_diplrel == NULL) {
|
||
|
if (local_diplrel == nullptr) {
|
||
|
/* No local diplrel */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/* Tile is claimed as a requirement. */
|
||
| ... | ... | |
|
unclaimed_req = req_vec_first_contradiction_in_vec(&tile_is_claimed,
|
||
|
&enabler->target_reqs);
|
||
|
if (unclaimed_req == NULL) {
|
||
|
if (unclaimed_req == nullptr) {
|
||
|
/* No unclaimed req */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
out = req_vec_problem_new(
|
||
| ... | ... | |
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns a suggestion to fix the specified action enabler or NULL if no
|
||
|
Returns a suggestion to fix the specified action enabler or nullptr if no
|
||
|
fix is found to be needed. It is the responsibility of the caller to
|
||
|
free the suggestion with req_vec_problem_free() when it is done with it.
|
||
|
**************************************************************************/
|
||
| ... | ... | |
|
struct req_vec_problem *out;
|
||
|
out = action_enabler_suggest_repair_oblig(enabler);
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
| ... | ... | |
|
out = req_vec_suggest_repair(&enabler->actor_reqs,
|
||
|
action_enabler_vector_number,
|
||
|
enabler);
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
|
out = req_vec_suggest_repair(&enabler->target_reqs,
|
||
|
action_enabler_vector_number,
|
||
|
enabler);
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
|
/* Enabler specific contradictions. */
|
||
|
out = enabler_first_self_contradiction(enabler);
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
|
/* Needed in action not enabled explanation finding. */
|
||
|
out = enabler_tile_tgt_local_diplrel_implies_claimed(enabler);
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
|
/* No problems found. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the first action enabler specific clarification possibility in
|
||
|
the specified enabler or NULL if no enabler specific contradiction is
|
||
|
the specified enabler or nullptr if no enabler specific contradiction is
|
||
|
found.
|
||
|
@param enabler the enabler to look at
|
||
|
@return the first problem and maybe a suggested fix
|
||
| ... | ... | |
|
{
|
||
|
struct req_vec_problem *out;
|
||
|
out = NULL;
|
||
|
out = nullptr;
|
||
|
return out;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns a suggestion to improve the specified action enabler or NULL if
|
||
|
Returns a suggestion to improve the specified action enabler or nullptr if
|
||
|
nothing to improve is found to be needed. It is the responsibility of the
|
||
|
caller to free the suggestion when it is done with it. A possible
|
||
|
improvement isn't always an error.
|
||
| ... | ... | |
|
action_rule_name(paction));
|
||
|
}
|
||
|
}
|
||
|
if (out != NULL) {
|
||
|
if (out != nullptr) {
|
||
|
return out;
|
||
|
}
|
||
| ... | ... | |
|
/********************************************************************//**
|
||
|
Returns a writable pointer to the specified requirement vector in the
|
||
|
action enabler or NULL if the action enabler doesn't have a requirement
|
||
|
action enabler or nullptr if the action enabler doesn't have a requirement
|
||
|
vector with that requirement vector number.
|
||
|
@param enabler the action enabler that may own the vector.
|
||
|
@param number the item's requirement vector number.
|
||
| ... | ... | |
|
{
|
||
|
struct action_enabler *ae = (struct action_enabler *)enabler;
|
||
|
fc_assert_ret_val(number >= 0, NULL);
|
||
|
fc_assert_ret_val(number >= 0, nullptr);
|
||
|
switch (number) {
|
||
|
case 0:
|
||
| ... | ... | |
|
case 1:
|
||
|
return &ae->target_reqs;
|
||
|
default:
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
|
/*********************************************************************//**
|
||
|
Returns the name of the given requirement vector number n in an action
|
||
|
enabler or NULL if enablers don't have a requirement vector with that
|
||
|
enabler or nullptr if enablers don't have a requirement vector with that
|
||
|
number.
|
||
|
@param vec the requirement vector to name
|
||
|
@return the requirement vector name or NULL.
|
||
|
@return the requirement vector name or nullptr.
|
||
|
**************************************************************************/
|
||
|
const char *action_enabler_vector_by_number_name(req_vec_num_in_item vec)
|
||
|
{
|
||
| ... | ... | |
|
/* TRANS: requirement vector in an action enabler (ruledit) */
|
||
|
return _("target_reqs");
|
||
|
default:
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the local building type of a city target.
|
||
|
target_city can't be NULL
|
||
|
target_city can't be nullptr
|
||
|
**************************************************************************/
|
||
|
static const struct impr_type *
|
||
|
tgt_city_local_building(const struct city *target_city)
|
||
|
{
|
||
|
/* Only used with city targets */
|
||
|
fc_assert_ret_val(target_city, NULL);
|
||
|
fc_assert_ret_val(target_city, nullptr);
|
||
|
if (target_city->production.kind == VUT_IMPROVEMENT) {
|
||
|
/* The local building is what the target city currently is building. */
|
||
| ... | ... | |
|
* being built. */
|
||
|
/* TODO: Consider making the local building the target building for
|
||
|
* actions that allows specifying a building target. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the local unit type of a city target.
|
||
|
target_city can't be NULL
|
||
|
target_city can't be nullptr
|
||
|
**************************************************************************/
|
||
|
static const struct unit_type *
|
||
|
tgt_city_local_utype(const struct city *target_city)
|
||
|
{
|
||
|
/* Only used with city targets */
|
||
|
fc_assert_ret_val(target_city, NULL);
|
||
|
fc_assert_ret_val(target_city, nullptr);
|
||
|
if (target_city->production.kind == VUT_UTYPE) {
|
||
|
/* The local unit type is what the target city currently is
|
||
| ... | ... | |
|
} else {
|
||
|
/* In the current semantic the local utype is always the type of the
|
||
|
* unit being built. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
const struct city *target_city,
|
||
|
const struct unit *target_unit)
|
||
|
{
|
||
|
if (target_tile_arg != NULL) {
|
||
|
if (target_tile_arg != nullptr) {
|
||
|
/* Trust the caller. */
|
||
|
return target_tile_arg;
|
||
|
}
|
||
|
/* Action should always be set */
|
||
|
fc_assert_ret_val(act, NULL);
|
||
|
fc_assert_ret_val(act, nullptr);
|
||
|
switch (action_get_target_kind(act)) {
|
||
|
case ATK_CITY:
|
||
|
fc_assert_ret_val(target_city, NULL);
|
||
|
fc_assert_ret_val(target_city, nullptr);
|
||
|
return city_tile(target_city);
|
||
|
case ATK_UNIT:
|
||
|
if (target_unit == NULL) {
|
||
|
fc_assert(target_unit != NULL);
|
||
|
return NULL;
|
||
|
if (target_unit == nullptr) {
|
||
|
fc_assert(target_unit != nullptr);
|
||
|
return nullptr;
|
||
|
}
|
||
|
return unit_tile(target_unit);
|
||
|
case ATK_STACK:
|
||
|
fc_assert_ret_val(target_unit || target_tile_arg, NULL);
|
||
|
fc_assert_ret_val(target_unit || target_tile_arg, nullptr);
|
||
|
if (target_unit) {
|
||
|
return unit_tile(target_unit);
|
||
|
}
|
||
| ... | ... | |
|
fc__fallthrough;
|
||
|
case ATK_TILE:
|
||
|
case ATK_EXTRAS:
|
||
|
fc_assert_ret_val(target_tile_arg, NULL);
|
||
|
fc_assert_ret_val(target_tile_arg, nullptr);
|
||
|
return target_tile_arg;
|
||
|
case ATK_SELF:
|
||
|
if (actor_unit != nullptr) {
|
||
| ... | ... | |
|
const struct city *target_city_arg,
|
||
|
const struct unit *target_unit)
|
||
|
{
|
||
|
if (target_city_arg != NULL) {
|
||
|
if (target_city_arg != nullptr) {
|
||
|
/* Trust the caller. */
|
||
|
return target_city_arg;
|
||
|
}
|
||
|
/* action should always be set */
|
||
|
fc_assert_ret_val(act, NULL);
|
||
|
fc_assert_ret_val(act, nullptr);
|
||
|
switch (action_get_target_kind(act)) {
|
||
|
case ATK_CITY:
|
||
|
fc_assert_ret_val(target_city_arg, NULL);
|
||
|
fc_assert_ret_val(target_city_arg, nullptr);
|
||
|
return target_city_arg;
|
||
|
case ATK_UNIT:
|
||
|
fc_assert_ret_val(target_unit, NULL);
|
||
|
fc_assert_ret_val(unit_tile(target_unit), NULL);
|
||
|
fc_assert_ret_val(target_unit, nullptr);
|
||
|
fc_assert_ret_val(unit_tile(target_unit), nullptr);
|
||
|
return tile_city(unit_tile(target_unit));
|
||
|
case ATK_STACK:
|
||
|
fc_assert_ret_val(target_unit || target_tile, NULL);
|
||
|
fc_assert_ret_val(target_unit || target_tile, nullptr);
|
||
|
if (target_unit) {
|
||
|
fc_assert_ret_val(unit_tile(target_unit), NULL);
|
||
|
fc_assert_ret_val(unit_tile(target_unit), nullptr);
|
||
|
return tile_city(unit_tile(target_unit));
|
||
|
}
|
||
|
fc__fallthrough;
|
||
|
case ATK_TILE:
|
||
|
case ATK_EXTRAS:
|
||
|
fc_assert_ret_val(target_tile, NULL);
|
||
|
fc_assert_ret_val(target_tile, nullptr);
|
||
|
return tile_city(target_tile);
|
||
|
case ATK_SELF:
|
||
|
if (actor_unit != nullptr) {
|
||
| ... | ... | |
|
fc_assert_msg(FALSE, "Bad action target kind %d for action %s",
|
||
|
action_get_target_kind(act), action_rule_name(act));
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Returns the action that blocks the specified action or NULL if the
|
||
|
Returns the action that blocks the specified action or nullptr if the
|
||
|
specified action isn't blocked.
|
||
|
An action that can block another blocks when it is forced and possible.
|
||
| ... | ... | |
|
continue;
|
||
|
}
|
||
|
if (is_action_enabled_unit_on_tile(nmap, blocker->id,
|
||
|
actor_unit, target_tile, NULL)) {
|
||
|
actor_unit, target_tile, nullptr)) {
|
||
|
return blocker;
|
||
|
}
|
||
|
break;
|
||
| ... | ... | |
|
continue;
|
||
|
}
|
||
|
if (is_action_enabled_unit_on_extras(nmap, blocker->id,
|
||
|
actor_unit, target_tile, NULL)) {
|
||
|
actor_unit, target_tile, nullptr)) {
|
||
|
return blocker;
|
||
|
}
|
||
|
break;
|
||
| ... | ... | |
|
} action_iterate_end;
|
||
|
/* Not blocked. */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
struct unit_class *pclass = utype_class(actor_unittype);
|
||
|
/* Use cache when it has been initialized */
|
||
|
if (pclass->cache.native_bases != NULL) {
|
||
|
if (pclass->cache.native_bases != nullptr) {
|
||
|
/* Extra being native one is a hard requirement */
|
||
|
extra_type_list_iterate(pclass->cache.native_bases, pextra) {
|
||
|
if (!territory_claiming_base(pextra->data.base)) {
|
||
| ... | ... | |
|
omniscient.
|
||
|
Passing NULL for actor is equivalent to passing an empty context. This
|
||
|
may or may not be legal depending on the action.
|
||
|
Passing nullptr for actor is equivalent to passing an empty context.
|
||
|
This may or may not be legal depending on the action.
|
||
|
**************************************************************************/
|
||
|
static enum fc_tristate
|
||
|
action_hard_reqs_actor(const struct civ_map *nmap,
|
||
| ... | ... | |
|
{
|
||
|
enum action_result result = paction->result;
|
||
|
if (actor == NULL) {
|
||
|
if (actor == nullptr) {
|
||
|
actor = req_context_empty();
|
||
|
}
|
||
| ... | ... | |
|
/* Obligatory hard requirement. Checked here too since
|
||
|
* action_hard_reqs_actor() may be called before any
|
||
|
* action enablers are checked. */
|
||
|
if (actor->city == NULL) {
|
||
|
if (actor->city == nullptr) {
|
||
|
/* No city to airlift from. */
|
||
|
return TRI_NO;
|
||
|
}
|
||
| ... | ... | |
|
the player don't have access to be used in a test it must check if
|
||
|
the evaluation can see the thing being tested.
|
||
|
Passing NULL for actor or target is equivalent to passing an empty
|
||
|
Passing nullptr for actor or target is equivalent to passing an empty
|
||
|
context. This may or may not be legal depending on the action.
|
||
|
**************************************************************************/
|
||
|
static enum fc_tristate
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Return TRUE iff the action enabler is active
|
||
|
actor may be NULL. This is equivalent to passing an empty context.
|
||
|
target may be NULL. This is equivalent to passing an empty context.
|
||
|
actor may be nullptr. This is equivalent to passing an empty context.
|
||
|
target may be nullptr. This is equivalent to passing an empty context.
|
||
|
**************************************************************************/
|
||
|
static bool is_enabler_active(const struct action_enabler *enabler,
|
||
|
const struct req_context *actor,
|
||
| ... | ... | |
|
Note that the action may disable it self because of hard requirements
|
||
|
even if an action enabler returns TRUE.
|
||
|
Passing NULL for actor or target is equivalent to passing an empty
|
||
|
Passing nullptr for actor or target is equivalent to passing an empty
|
||
|
context. This may or may not be legal depending on the action.
|
||
|
**************************************************************************/
|
||
|
static bool is_action_enabled(const struct civ_map *nmap,
|
||
| ... | ... | |
|
const struct impr_type *target_building;
|
||
|
const struct unit_type *target_utype;
|
||
|
if (actor_unit == NULL || target_city == NULL) {
|
||
|
if (actor_unit == nullptr || target_city == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
.tile = city_tile(target_city),
|
||
|
.unittype = target_utype,
|
||
|
},
|
||
|
NULL,
|
||
|
nullptr,
|
||
|
actor_home);
|
||
|
}
|
||
| ... | ... | |
|
const struct tile *actor_tile,
|
||
|
const struct unit *target_unit)
|
||
|
{
|
||
|
if (actor_unit == NULL || target_unit == NULL) {
|
||
|
if (actor_unit == nullptr || target_unit == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
.unit = target_unit,
|
||
|
.unittype = unit_type_get(target_unit),
|
||
|
},
|
||
|
NULL,
|
||
|
nullptr,
|
||
|
actor_home);
|
||
|
}
|
||
| ... | ... | |
|
{
|
||
|
const struct req_context *actor_ctxt;
|
||
|
if (actor_unit == NULL || target_tile == NULL
|
||
|
if (actor_unit == nullptr || target_tile == nullptr
|
||
|
|| unit_list_size(target_tile->units) == 0) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return FALSE;
|
||
| ... | ... | |
|
.unit = target_unit,
|
||
|
.unittype = unit_type_get(target_unit),
|
||
|
},
|
||
|
NULL, actor_home)) {
|
||
|
nullptr, actor_home)) {
|
||
|
/* One unit makes it impossible for all units. */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
const struct tile *target_tile,
|
||
|
const struct extra_type *target_extra)
|
||
|
{
|
||
|
if (actor_unit == NULL || target_tile == NULL) {
|
||
|
if (actor_unit == nullptr || target_tile == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
const struct tile *target_tile,
|
||
|
const struct extra_type *target_extra)
|
||
|
{
|
||
|
if (actor_unit == NULL || target_tile == NULL) {
|
||
|
if (actor_unit == nullptr || target_tile == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
const struct city *actor_home,
|
||
|
const struct tile *actor_tile)
|
||
|
{
|
||
|
if (actor_unit == NULL) {
|
||
|
if (actor_unit == nullptr) {
|
||
|
/* Can't do an action when the actor is missing. */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
.unit = actor_unit,
|
||
|
.unittype = unit_type_get(actor_unit),
|
||
|
},
|
||
|
NULL, NULL,
|
||
|
nullptr, nullptr,
|
||
|
actor_home);
|
||
|
}
|
||
| ... | ... | |
|
If meta knowledge is missing TRI_MAYBE will be returned.
|
||
|
target may be NULL. This is equivalent to passing an empty context.
|
||
|
target may be nullptr. This is equivalent to passing an empty context.
|
||
|
**************************************************************************/
|
||
|
static enum fc_tristate
|
||
|
action_enabled_local(const action_id wanted_action,
|
||
| ... | ... | |
|
enum fc_tristate current;
|
||
|
enum fc_tristate result;
|
||
|
if (actor == NULL || actor->player == NULL) {
|
||
|
if (actor == nullptr || actor->player == nullptr) {
|
||
|
/* Need actor->player for point of view */
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
if (target == NULL) {
|
||
|
if (target == nullptr) {
|
||
|
target = req_context_empty();
|
||
|
}
|
||
| ... | ... | |
|
If meta knowledge is missing TRI_MAYBE will be returned.
|
||
|
context and other_context may be NULL. This is equivalent to passing
|
||
|
context and other_context may be nullptr. This is equivalent to passing
|
||
|
empty contexts.
|
||
|
**************************************************************************/
|
||
|
static bool is_effect_val_known(enum effect_type effect_type,
|
||
| ... | ... | |
|
};
|
||
|
if (!is_effect_val_known(EFT_SPY_RESISTANT, unit_owner(pattacker),
|
||
|
&defender_ctxt,
|
||
|
NULL)) {
|
||
|
nullptr)) {
|
||
|
return ACTPROB_NOT_KNOWN;
|
||
|
}
|
||
|
/* Reduce the chance of an attack by EFT_SPY_RESISTANT percent. */
|
||
|
chance -= chance * get_target_bonus_effects(
|
||
|
NULL,
|
||
|
nullptr,
|
||
|
&defender_ctxt,
|
||
|
NULL,
|
||
|
nullptr,
|
||
|
EFT_SPY_RESISTANT
|
||
|
) / 100;
|
||
|
}
|
||
| ... | ... | |
|
player has and is willing to spend the money. This is so the player can
|
||
|
figure out what their odds are before deciding to get the extra money.
|
||
|
Passing NULL for actor or target is equivalent to passing an empty
|
||
|
Passing nullptr for actor or target is equivalent to passing an empty
|
||
|
context. This may or may not be legal depending on the action.
|
||
|
**************************************************************************/
|
||
|
static struct act_prob
|
||
| ... | ... | |
|
struct act_prob chance;
|
||
|
const struct action *paction = action_by_number(wanted_action);
|
||
|
if (actor == NULL) {
|
||
|
if (actor == nullptr) {
|
||
|
actor = req_context_empty();
|
||
|
}
|
||
|
if (target == NULL) {
|
||
|
if (target == nullptr) {
|
||
|
target = req_context_empty();
|
||
|
}
|
||
| ... | ... | |
|
break;
|
||
|
case ACTRES_SPY_ATTACK:
|
||
|
/* All uncertainty comes from potential diplomatic battles. */
|
||
|
chance = ap_diplomat_battle(actor->unit, NULL, target->tile,
|
||
|
chance = ap_diplomat_battle(actor->unit, nullptr, target->tile,
|
||
|
paction);
|
||
|
break;
|
||
|
case ACTRES_SPY_SABOTAGE_CITY:
|
||
| ... | ... | |
|
const struct unit_type *target_utype;
|
||
|
const struct action *act = action_by_number(act_id);
|
||
|
if (actor_unit == NULL || target_city == NULL) {
|
||
|
if (actor_unit == nullptr || target_city == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
/* Doesn't leak information since it must be 100% certain from the
|
||
|
* player's perspective that the blocking action is legal. */
|
||
|
if (action_is_blocked_by(nmap, act, actor_unit,
|
||
|
city_tile(target_city), target_city, NULL)) {
|
||
|
city_tile(target_city), target_city, nullptr)) {
|
||
|
/* Don't offer to perform an action known to be blocked. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
.building = target_building,
|
||
|
.tile = city_tile(target_city),
|
||
|
.unittype = target_utype,
|
||
|
}, NULL);
|
||
|
}, nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
const action_id act_id,
|
||
|
const struct unit *target_unit)
|
||
|
{
|
||
|
if (actor_unit == NULL || target_unit == NULL) {
|
||
|
if (actor_unit == nullptr || target_unit == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
.unit = target_unit,
|
||
|
.unittype = unit_type_get(target_unit),
|
||
|
},
|
||
|
NULL);
|
||
|
nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
const struct req_context *actor_ctxt;
|
||
|
const struct action *act = action_by_number(act_id);
|
||
|
if (actor_unit == NULL || target_tile == NULL) {
|
||
|
if (actor_unit == nullptr || target_tile == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
/* Doesn't leak information since the actor player can see the target
|
||
|
* tile. */
|
||
|
if (tile_is_seen(target_tile, unit_owner(actor_unit))
|
||
|
&& tile_city(target_tile) != NULL
|
||
|
&& tile_city(target_tile) != nullptr
|
||
|
&& !utype_can_do_act_if_tgt_citytile(unit_type_get(actor_unit),
|
||
|
act_id,
|
||
|
CITYT_CENTER, TRUE)) {
|
||
| ... | ... | |
|
if ((action_id_has_result_safe(act_id, ACTRES_ATTACK)
|
||
|
|| action_id_has_result_safe(act_id, ACTRES_WIPE_UNITS)
|
||
|
|| action_id_has_result_safe(act_id, ACTRES_COLLECT_RANSOM))
|
||
|
&& tile_city(target_tile) != NULL
|
||
|
&& tile_city(target_tile) != nullptr
|
||
|
&& !pplayers_at_war(city_owner(tile_city(target_tile)),
|
||
|
unit_owner(actor_unit))) {
|
||
|
/* Hard coded rule: can't "Bombard", "Suicide Attack", or "Attack"
|
||
| ... | ... | |
|
.unit = target_unit,
|
||
|
.unittype = unit_type_get(target_unit),
|
||
|
},
|
||
|
NULL);
|
||
|
nullptr);
|
||
|
if (!action_prob_possible(prob_unit)) {
|
||
|
/* One unit makes it impossible for all units. */
|
||
| ... | ... | |
|
const struct tile *target_tile,
|
||
|
const struct extra_type *target_extra)
|
||
|
{
|
||
|
if (actor_unit == NULL || target_tile == NULL) {
|
||
|
if (actor_unit == nullptr || target_tile == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
const struct tile *target_tile,
|
||
|
const struct extra_type *target_extra)
|
||
|
{
|
||
|
if (actor_unit == NULL || target_tile == NULL) {
|
||
|
if (actor_unit == nullptr || target_tile == nullptr) {
|
||
|
/* Can't do an action when actor or target are missing. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
const struct tile *actor_tile,
|
||
|
const action_id act_id)
|
||
|
{
|
||
|
if (actor_unit == NULL) {
|
||
|
if (actor_unit == nullptr) {
|
||
|
/* Can't do the action when the actor is missing. */
|
||
|
return ACTPROB_IMPOSSIBLE;
|
||
|
}
|
||
| ... | ... | |
|
.unittype = unit_type_get(actor_unit),
|
||
|
},
|
||
|
actor_home,
|
||
|
NULL,
|
||
|
NULL);
|
||
|
nullptr,
|
||
|
nullptr);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
* increase the odds. */
|
||
|
odds = odds
|
||
|
+ ((odds
|
||
|
* get_target_bonus_effects(NULL,
|
||
|
* get_target_bonus_effects(nullptr,
|
||
|
&(const struct req_context) {
|
||
|
.player = act_player,
|
||
|
.city = tgt_city,
|
||
| ... | ... | |
|
EFT_ACTION_ODDS_PCT))
|
||
|
/ 100)
|
||
|
- ((odds
|
||
|
* get_target_bonus_effects(NULL,
|
||
|
* get_target_bonus_effects(nullptr,
|
||
|
&(const struct req_context) {
|
||
|
.player = tgt_player,
|
||
|
.city = tgt_city,
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Returns TRUE if the wanted action can be done to the target.
|
||
|
target may be NULL. This is equivalent to passing an empty context.
|
||
|
target may be nullptr. This is equivalent to passing an empty context.
|
||
|
**************************************************************************/
|
||
|
static bool is_target_possible(const action_id wanted_action,
|
||
|
const struct player *actor_player,
|
||
| ... | ... | |
|
action_enabler_list_iterate(action_enablers_for_action(act_id),
|
||
|
enabler) {
|
||
|
const enum fc_tristate current
|
||
|
= mke_eval_reqs(actor_player, &actor_ctxt, NULL,
|
||
|
= mke_eval_reqs(actor_player, &actor_ctxt, nullptr,
|
||
|
&enabler->actor_reqs,
|
||
|
/* Needed since no player to evaluate DiplRel
|
||
|
* requirements against. */
|
||
| ... | ... | |
|
struct universal actor_univ = { .kind = VUT_UTYPE,
|
||
|
.value.utype = act_utype };
|
||
|
fc_assert_ret_val(paction != NULL, FALSE);
|
||
|
fc_assert_ret_val(paction != nullptr, FALSE);
|
||
|
fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
|
||
|
fc_assert_ret_val(act_utype != NULL, FALSE);
|
||
|
fc_assert_ret_val(act_utype != nullptr, FALSE);
|
||
|
return (action_actor_utype_hard_reqs_ok(paction, act_utype)
|
||
|
&& !req_vec_is_impossible_to_fulfill(&ae->actor_reqs)
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
struct action_auto_perf *action_auto_perf_slot_number(const int num)
|
||
|
{
|
||
|
fc_assert_ret_val(num >= 0, NULL);
|
||
|
fc_assert_ret_val(num < MAX_NUM_ACTION_AUTO_PERFORMERS, NULL);
|
||
|
fc_assert_ret_val(num >= 0, nullptr);
|
||
|
fc_assert_ret_val(num < MAX_NUM_ACTION_AUTO_PERFORMERS, nullptr);
|
||
|
return &auto_perfs[num];
|
||
|
}
|
||
| ... | ... | |
|
{
|
||
|
action_enabler_list_iterate(action_enablers_for_action(paction->id),
|
||
|
enab) {
|
||
|
if ((actor_uni == NULL
|
||
|
if ((actor_uni == nullptr
|
||
|
|| universal_fulfills_requirements(FALSE, &(enab->actor_reqs),
|
||
|
actor_uni))
|
||
|
&& (target_uni == NULL
|
||
|
&& (target_uni == nullptr
|
||
|
|| universal_fulfills_requirements(FALSE, &(enab->target_reqs),
|
||
|
target_uni))) {
|
||
|
return TRUE;
|
||
| ... | ... | |
|
break;
|
||
|
}
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Return min range ruleset variable name for the action or NULL if min
|
||
|
Return min range ruleset variable name for the action or nullptr if min
|
||
|
range can't be set in the ruleset.
|
||
|
TODO: Make actions generic and put min_range in a field of the action.
|
||
| ... | ... | |
|
case ACTION_FINISH_UNIT:
|
||
|
case ACTION_FINISH_BUILDING:
|
||
|
/* Min range is not ruleset changeable */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
case ACTION_NUKE:
|
||
|
return "explode_nuclear_min_range";
|
||
|
case ACTION_NUKE_CITY:
|
||
| ... | ... | |
|
fc_assert(act >= 0 && act < ACTION_COUNT);
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Return max range ruleset variable name for the action or NULL if max
|
||
|
Return max range ruleset variable name for the action or nullptr if max
|
||
|
range can't be set in the ruleset.
|
||
|
TODO: make actions generic and put max_range in a field of the action.
|
||
| ... | ... | |
|
case ACTION_FINISH_UNIT:
|
||
|
case ACTION_FINISH_BUILDING:
|
||
|
/* Max range is not ruleset changeable */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
case ACTION_HELP_WONDER:
|
||
|
return "help_wonder_max_range";
|
||
|
case ACTION_DISBAND_UNIT_RECOVER:
|
||
| ... | ... | |
|
fc_assert(act >= 0 && act < ACTION_COUNT);
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Return target kind ruleset variable name for the action or NULL if
|
||
|
Return target kind ruleset variable name for the action or nullptr if
|
||
|
target kind can't be set in the ruleset.
|
||
|
TODO: make actions generic and put target_kind in a field of the action.
|
||
| ... | ... | |
|
case ACTION_FINISH_UNIT:
|
||
|
case ACTION_FINISH_BUILDING:
|
||
|
/* Target kind is not ruleset changeable */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
case ACTION_NUKE:
|
||
|
return "explode_nuclear_target_kind";
|
||
|
case ACTION_NUKE_CITY:
|
||
| ... | ... | |
|
fc_assert(act >= 0 && act < ACTION_COUNT);
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Return actor consuming always ruleset variable name for the action or
|
||
|
NULL if actor consuming always can't be set in the ruleset.
|
||
|
nullptr if actor consuming always can't be set in the ruleset.
|
||
|
TODO: make actions generic and put actor consuming always in a field of
|
||
|
the action.
|
||
| ... | ... | |
|
case ACTION_FINISH_UNIT:
|
||
|
case ACTION_FINISH_BUILDING:
|
||
|
/* Actor consuming always is not ruleset changeable */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
case ACTION_FOUND_CITY:
|
||
|
return "found_city_consuming_always";
|
||
|
case ACTION_NUKE:
|
||
| ... | ... | |
|
fc_assert(act >= 0 && act < ACTION_COUNT);
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Return action blocked by ruleset variable name for the action or
|
||
|
NULL if actor consuming always can't be set in the ruleset.
|
||
|
nullptr if actor consuming always can't be set in the ruleset.
|
||
|
TODO: make actions generic and put blocked by actions in a field of
|
||
|
the action.
|
||
|
**************************************************************************/
|
||
|
const char *action_blocked_by_ruleset_var_name(const struct action *act)
|
||
|
{
|
||
|
fc_assert_ret_val(act != NULL, NULL);
|
||
|
fc_assert_ret_val(act != nullptr, nullptr);
|
||
|
switch ((enum gen_action)action_number(act)) {
|
||
|
case ACTION_MARKETPLACE:
|
||
| ... | ... | |
|
case ACTION_USER_ACTION3:
|
||
|
case ACTION_USER_ACTION4:
|
||
|
/* blocked_by is not ruleset changeable */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
case ACTION_COUNT:
|
||
|
fc_assert_ret_val(action_number(act) != ACTION_COUNT, NULL);
|
||
|
fc_assert_ret_val(action_number(act) != ACTION_COUNT, nullptr);
|
||
|
break;
|
||
|
ASSERT_UNUSED_ACTION_CASES;
|
||
|
}
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Return action post success forced action ruleset variable name for the
|
||
|
action or NULL if it can't be set in the ruleset.
|
||
|
action or nullptr if it can't be set in the ruleset.
|
||
|
**************************************************************************/
|
||
|
const char *
|
||
|
action_post_success_forced_ruleset_var_name(const struct action *act)
|
||
|
{
|
||
|
fc_assert_ret_val(act != NULL, NULL);
|
||
|
fc_assert_ret_val(act != nullptr, nullptr);
|
||
|
if (!(action_has_result(act, ACTRES_SPY_BRIBE_UNIT)
|
||
|
|| action_has_result(act, ACTRES_SPY_BRIBE_STACK)
|
||
| ... | ... | |
|
|| action_has_result(act, ACTRES_WIPE_UNITS)
|
||
|
|| action_has_result(act, ACTRES_COLLECT_RANSOM))) {
|
||
|
/* No support in the action performer function */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
switch ((enum gen_action)action_number(act)) {
|
||
| ... | ... | |
|
case ACTION_USER_ACTION3:
|
||
|
case ACTION_USER_ACTION4:
|
||
|
/* Not ruleset changeable */
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
case ACTION_COUNT:
|
||
|
fc_assert_ret_val(action_number(act) != ACTION_COUNT, NULL);
|
||
|
fc_assert_ret_val(action_number(act) != ACTION_COUNT, nullptr);
|
||
|
break;
|
||
|
ASSERT_UNUSED_ACTION_CASES;
|
||
|
}
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| common/actions.h | ||
|---|---|---|
|
/**********************************************************************//**
|
||
|
Return the action with the given id.
|
||
|
Returns NULL if no action with the given id exists.
|
||
|
Returns nullptr if no action with the given id exists.
|
||
|
**************************************************************************/
|
||
|
static inline struct action *action_by_number(action_id act_id)
|
||
|
{
|
||
|
if (!gen_action_is_valid((enum gen_action)act_id)) {
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/* We return NULL if there's NULL there, no need to special case it */
|
||
|
/* We return nullptr if there's nullptr there, no need to special case it */
|
||
|
return _actions[act_id];
|
||
|
}
|
||