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 #879062 ยป 0005-Shorten-auto_settlers_speculate_can_act_at.patch

Sveinung Kvilhaugsvik, 2020-06-25 05:38 AM

View differences:

server/advisors/autosettlers.c
/**********************************************************************//**
Returns TRUE iff the unit can do the targeted activity at the given
location.
Some activities aren't actions. They are therefore unable to use
action_speculate_*(). Activities that are actions will use the actor's
current tile when evaluating distance requirements etc if used with
can_unit_do_activity_targeted_at(). This makes them return the wrong
result. They must therefore use action_speculate_*(). Call the function
that gives the best speculative evaluation for the specified activity.
FIXME: Get rid of the need for this.
**************************************************************************/
bool auto_settlers_speculate_can_act_at(const struct unit *punit,
enum unit_activity activity,
......
struct extra_type *target,
const struct tile *ptile)
{
switch (activity) {
case ACTIVITY_MINE:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_MINE,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
struct action *paction = NULL;
case ACTIVITY_PLANT:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_PLANT,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
action_iterate(act_id) {
paction = action_by_number(act_id);
case ACTIVITY_IRRIGATE:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_IRRIGATE,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
case ACTIVITY_CULTIVATE:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_CULTIVATE,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
if (action_get_actor_kind(paction) != AAK_UNIT) {
/* Not relevant. */
continue;
}
case ACTIVITY_FORTIFYING:
return action_prob_possible(action_speculate_unit_on_self(
ACTION_FORTIFY,
punit, unit_home(punit), ptile,
omniscient_cheat));
if (action_get_activity(paction) == activity) {
/* Found one */
break;
}
} action_iterate_end;
case ACTIVITY_BASE:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_BASE,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
if (paction == NULL) {
/* The action it self isn't there. It can't be enabled. */
return FALSE;
}
case ACTIVITY_GEN_ROAD:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_ROAD,
switch (action_get_target_kind(paction)) {
case ATK_CITY:
return action_prob_possible(action_speculate_unit_on_city(
paction->id,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
case ACTIVITY_PILLAGE:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_PILLAGE,
tile_city(ptile)));
case ATK_UNIT:
fc_assert_ret_val(action_get_target_kind(paction) != ATK_UNIT, FALSE);
break;
case ATK_UNITS:
return action_prob_possible(action_speculate_unit_on_units(
paction->id,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
case ACTIVITY_TRANSFORM:
ptile));
case ATK_TILE:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_TRANSFORM_TERRAIN,
paction->id,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
case ACTIVITY_CONVERT:
case ATK_SELF:
return action_prob_possible(action_speculate_unit_on_self(
ACTION_CONVERT,
paction->id,
punit, unit_home(punit), ptile,
omniscient_cheat));
case ACTIVITY_POLLUTION:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_CLEAN_POLLUTION,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
case ACTIVITY_FALLOUT:
return action_prob_possible(action_speculate_unit_on_tile(
ACTION_CLEAN_FALLOUT,
punit, unit_home(punit), ptile,
omniscient_cheat,
ptile, target));
case ACTIVITY_IDLE:
case ACTIVITY_GOTO:
case ACTIVITY_FORTIFIED:
case ACTIVITY_SENTRY:
case ACTIVITY_EXPLORE:
case ACTIVITY_OLD_ROAD:
case ACTIVITY_OLD_RAILROAD:
case ACTIVITY_FORTRESS:
case ACTIVITY_AIRBASE:
case ACTIVITY_PATROL_UNUSED:
case ACTIVITY_LAST:
case ACTIVITY_UNKNOWN:
return can_unit_do_activity_targeted_at(punit, activity, target, ptile);
case ATK_COUNT:
fc_assert_ret_val(action_get_target_kind(paction) != ATK_COUNT, FALSE);
break;
}
fc_assert(FALSE);
    (1-1/1)