Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #877184 ยป 0024-Action-reasoning-API-clean-up.patch

Sveinung Kvilhaugsvik, 2020-06-09 07:20 PM

View differences:

client/control.c
return FALSE;
}
return univs_have_action_enabler(ACTION_IRRIGATE, &for_unit, &for_tile);
return action_id_univs_not_blocking(ACTION_IRRIGATE,
&for_unit, &for_tile);
}
/**********************************************************************//**
client/gui-gtk-3.0/citydlg.c
}
if ((pterr->mining_result == pterr
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr))
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr))
|| (pterr->mining_result != pterr && pterr->mining_result != NULL
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr))) {
&& action_id_univs_not_blocking(ACTION_PLANT,
NULL, &for_terr))) {
choice_dialog_add(shl, _("Mine"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_MINE), FALSE, NULL);
}
if ((pterr->irrigation_result == pterr
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr))
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr))
|| (pterr->irrigation_result != pterr && pterr->irrigation_result != NULL
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr))) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr))) {
choice_dialog_add(shl, _("Irrigate"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_IRRIGATE), FALSE, NULL);
......
GINT_TO_POINTER(ACTIVITY_GEN_ROAD), FALSE, NULL);
}
if (pterr->transform_result != pterr && pterr->transform_result != NULL
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
choice_dialog_add(shl, _("Transform"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_TRANSFORM), FALSE, NULL);
client/gui-gtk-3.0/helpdlg.c
if (pterrain->irrigation_result != pterrain
&& pterrain->irrigation_result != T_NONE
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->irrigation_time),
pterrain->irrigation_time);
......
if (pterrain->mining_result != pterrain
&& pterrain->mining_result != T_NONE
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->mining_time),
pterrain->mining_time);
......
if (pterrain->transform_result != T_NONE
&& pterrain->transform_time != 0
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->transform_time),
pterrain->transform_time);
......
if (pterrain->irrigation_result == pterrain
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation"));
}
if (pterrain->mining_result == pterrain
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine"));
}
if (pterrain->road_time != 0) {
client/gui-gtk-3.22/citydlg.c
}
if ((pterr->mining_result == pterr
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr))
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr))
|| (pterr->mining_result != pterr && pterr->mining_result != NULL
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr))) {
&& action_id_univs_not_blocking(ACTION_PLANT,
NULL, &for_terr))) {
choice_dialog_add(shl, _("Mine"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_MINE), FALSE, NULL);
}
if ((pterr->irrigation_result == pterr
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr))
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr))
|| (pterr->irrigation_result != pterr && pterr->irrigation_result != NULL
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr))) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr))) {
choice_dialog_add(shl, _("Irrigate"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_IRRIGATE), FALSE, NULL);
......
GINT_TO_POINTER(ACTIVITY_GEN_ROAD), FALSE, NULL);
}
if (pterr->transform_result != pterr && pterr->transform_result != NULL
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
choice_dialog_add(shl, _("Transform"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_TRANSFORM), FALSE, NULL);
client/gui-gtk-3.22/helpdlg.c
if (pterrain->irrigation_result != pterrain
&& pterrain->irrigation_result != T_NONE
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->irrigation_time),
pterrain->irrigation_time);
......
if (pterrain->mining_result != pterrain
&& pterrain->mining_result != T_NONE
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->mining_time),
pterrain->mining_time);
......
if (pterrain->transform_result != T_NONE
&& pterrain->transform_time != 0
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->transform_time),
pterrain->transform_time);
......
if (pterrain->irrigation_result == pterrain
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation"));
}
if (pterrain->mining_result == pterrain
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine"));
}
if (pterrain->road_time != 0) {
client/gui-gtk-4.0/citydlg.c
}
if ((pterr->mining_result == pterr
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr))
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr))
|| (pterr->mining_result != pterr && pterr->mining_result != NULL
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr))) {
&& action_id_univs_not_blocking(ACTION_PLANT,
NULL, &for_terr))) {
choice_dialog_add(shl, _("Mine"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_MINE), FALSE, NULL);
}
if ((pterr->irrigation_result == pterr
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr))
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr))
|| (pterr->irrigation_result != pterr && pterr->irrigation_result != NULL
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr))) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr))) {
choice_dialog_add(shl, _("Irrigate"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_IRRIGATE), FALSE, NULL);
......
GINT_TO_POINTER(ACTIVITY_GEN_ROAD), FALSE, NULL);
}
if (pterr->transform_result != pterr && pterr->transform_result != NULL
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
choice_dialog_add(shl, _("Transform"),
G_CALLBACK(set_city_workertask),
GINT_TO_POINTER(ACTIVITY_TRANSFORM), FALSE, NULL);
client/gui-gtk-4.0/helpdlg.c
if (pterrain->irrigation_result != pterrain
&& pterrain->irrigation_result != T_NONE
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->irrigation_time),
pterrain->irrigation_time);
......
if (pterrain->mining_result != pterrain
&& pterrain->mining_result != T_NONE
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->mining_time),
pterrain->mining_time);
......
if (pterrain->transform_result != T_NONE
&& pterrain->transform_time != 0
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
fc_snprintf(buf, sizeof(buf),
PL_("%d turn", "%d turns", pterrain->transform_time),
pterrain->transform_time);
......
if (pterrain->irrigation_result == pterrain
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation"));
}
if (pterrain->mining_result == pterrain
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine"));
}
if (pterrain->road_time != 0) {
client/gui-qt/citydlg.cpp
con_menu->addAction(wid_act);
if (pterr->mining_result != pterr && pterr->mining_result != NULL
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
con_menu->addAction(_("Plant"));
} else if (pterr->mining_result == pterr
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_MINE,
NULL, &for_terr)) {
con_menu->addAction(_("Mine"));
}
if (pterr->irrigation_result != pterr && pterr->irrigation_result != NULL
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE, NULL, &for_terr)) {
con_menu->addAction(_("Irrigate"));
} else if (pterr->irrigation_result == pterr
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_IRRIGATE,
NULL, &for_terr)) {
con_menu->addAction(_("Irrigate"));
}
if (pterr->transform_result != pterr && pterr->transform_result != NULL
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
con_menu->addAction(_("Transform"));
}
client/gui-qt/helpdlg.cpp
if (pterrain->irrigation_result != pterrain
&& pterrain->irrigation_result != T_NONE
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_CULTIVATE,
NULL, &for_terr)) {
QLabel *tb;
char buffer[1024];
......
if (pterrain->mining_result != pterrain
&& pterrain->mining_result != T_NONE
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
QLabel *tb;
char buffer[1024];
......
if (pterrain->transform_result != T_NONE
&& pterrain->transform_time != 0
&& univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) {
QLabel *tb;
char buffer[1024];
......
if (pterrain->irrigation_result == pterrain
&& pterrain->irrigation_time != 0
&& univs_have_action_enabler(ACTION_IRRIGATE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
/* TRANS: this and similar literal strings interpreted as (Qt) HTML */
add_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation"));
}
if (pterrain->mining_result == pterrain
&& pterrain->mining_time != 0
&& univs_have_action_enabler(ACTION_MINE, NULL, &for_terr)) {
&& action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
add_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine"));
}
if (pterrain->road_time != 0) {
client/helpdata.c
irrigation_result =
(pterrain->irrigation_result == pterrain
|| pterrain->irrigation_result == T_NONE
|| !univs_have_action_enabler(ACTION_CULTIVATE, NULL, &for_terr)) ? ""
: terrain_name_translation(pterrain->irrigation_result);
|| !action_id_univs_not_blocking(ACTION_CULTIVATE, NULL, &for_terr))
? ""
: terrain_name_translation(pterrain->irrigation_result);
mining_result =
(pterrain->mining_result == pterrain
|| pterrain->mining_result == T_NONE
|| !univs_have_action_enabler(ACTION_PLANT, NULL, &for_terr)) ? ""
: terrain_name_translation(pterrain->mining_result);
|| !action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr))
? ""
: terrain_name_translation(pterrain->mining_result);
transform_result =
(pterrain->transform_result == pterrain
|| pterrain->transform_result == T_NONE
|| !univs_have_action_enabler(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) ? ""
|| !action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
NULL, &for_terr)) ? ""
: terrain_name_translation(pterrain->transform_result);
/* Use get_internal_string_length() for correct alignment with
* multibyte character encodings */
common/actions.c
return TRUE;
}
/**********************************************************************//**
Returns TRUE if the specified action never can be performed when the
situation requirement is fulfilled for the actor.
**************************************************************************/
bool action_blocked_by_situation_act(const struct action *paction,
const struct requirement *situation)
{
action_enabler_list_iterate(action_enablers_for_action(paction->id),
enabler) {
if (!does_req_contradicts_reqs(situation, &enabler->actor_reqs)) {
return FALSE;
}
} action_enabler_list_iterate_end;
return TRUE;
}
/**********************************************************************//**
Returns TRUE if the specified action never can be performed when the
situation requirement is fulfilled for the target.
**************************************************************************/
bool action_blocked_by_situation_tgt(const struct action *paction,
const struct requirement *situation)
{
action_enabler_list_iterate(action_enablers_for_action(paction->id),
enabler) {
if (!does_req_contradicts_reqs(situation, &enabler->target_reqs)) {
return FALSE;
}
} action_enabler_list_iterate_end;
return TRUE;
}
/**********************************************************************//**
Returns TRUE if the wanted action can be done to the target.
**************************************************************************/
......
/**********************************************************************//**
Is there any action enablers of the given type not blocked by universals?
**************************************************************************/
bool univs_have_action_enabler(action_id action,
bool action_univs_not_blocking(const struct action *paction,
struct universal *actor_uni,
struct universal *target_uni)
{
action_enabler_list_iterate(action_enablers_for_action(action), enab) {
action_enabler_list_iterate(action_enablers_for_action(paction->id),
enab) {
if ((actor_uni == NULL
|| universal_fulfills_requirements(FALSE, &(enab->actor_reqs),
actor_uni))
common/actions.h
action_enabler_obligatory_reqs_missing(struct action_enabler *enabler);
bool action_enabler_obligatory_reqs_add(struct action_enabler *enabler);
bool univs_have_action_enabler(action_id action,
struct universal *actor_uni,
struct universal *target_uni);
struct action *action_is_blocked_by(const action_id act_id,
const struct unit *actor_unit,
const struct tile *target_tile,
......
const struct unit_type *actor_unittype);
/* Reasoning about actions */
bool action_immune_government(struct government *gov, action_id act);
bool action_blocked_by_situation_act(const struct action *paction,
const struct requirement *situation);
#define action_id_blocked_by_situation_act(act_id, situation) \
action_blocked_by_situation_act(action_by_number(act_id), situation)
bool action_univs_not_blocking(const struct action *paction,
struct universal *actor_uni,
struct universal *target_uni);
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni) \
action_univs_not_blocking(action_by_number(act_id), act_uni, tgt_uni)
bool action_blocked_by_situation_tgt(const struct action *paction,
const struct requirement *situation);
#define action_id_blocked_by_situation_tgt(act_id, situation) \
action_blocked_by_situation_tgt(action_by_number(act_id), situation)
bool action_immune_government(struct government *gov, action_id act);
bool is_action_possible_on_city(action_id act_id,
const struct player *actor_player,
    (1-1/1)