Feature #1799 ยป 1799.patch
| server/actiontools.c | ||
|---|---|---|
|
enum unit_activity activity = action_get_activity(paction);
|
||
|
unit_assign_specific_activity_target(actor_unit, &activity,
|
||
|
action_number(paction), &pextra);
|
||
|
action_number(paction), pextra);
|
||
|
if (pextra != NULL) {
|
||
|
return extra_number(pextra);
|
||
| server/advisors/advgoto.c | ||
|---|---|---|
|
/* Only go via ACTIVITY_IDLE if we are actually changing the activity */
|
||
|
unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE);
|
||
|
send_unit_info(NULL, punit); /* FIXME: probably duplicate */
|
||
|
unit_activity_handling_targeted(punit, activity, &tgt,
|
||
|
unit_activity_handling_targeted(punit, activity, tgt,
|
||
|
activity_default_action(activity));
|
||
|
}
|
||
|
punit->goto_tile = old_tile; /* May be NULL. */
|
||
| server/advisors/autoworkers.c | ||
|---|---|---|
|
/* Reached destination and can start working immediately */
|
||
|
if (activity_requires_target(best_act)) {
|
||
|
unit_activity_handling_targeted(punit, best_act, best_target,
|
||
|
unit_activity_handling_targeted(punit, best_act, *best_target,
|
||
|
action);
|
||
|
} else {
|
||
|
unit_activity_handling(punit, best_act, action);
|
||
| server/savegame/savecompat.c | ||
|---|---|---|
|
unit_assign_specific_activity_target(punit,
|
||
|
&punit->activity,
|
||
|
punit->action,
|
||
|
&punit->activity_target);
|
||
|
punit->activity_target);
|
||
|
} unit_list_iterate_end;
|
||
|
} players_iterate_alive_end;
|
||
|
}
|
||
| server/unithand.c | ||
|---|---|---|
|
enum gen_action trigger_action);
|
||
|
static bool unit_activity_targeted_internal(struct unit *punit,
|
||
|
enum unit_activity new_activity,
|
||
|
struct extra_type **new_target,
|
||
|
struct extra_type *new_target,
|
||
|
enum gen_action trigger_action);
|
||
|
static void illegal_action(struct player *pplayer,
|
||
|
struct unit *actor,
|
||
| ... | ... | |
|
const struct action *paction);
|
||
|
static bool do_action_activity_targeted(struct unit *punit,
|
||
|
const struct action *paction,
|
||
|
struct extra_type **new_target);
|
||
|
struct extra_type *new_target);
|
||
|
static inline bool
|
||
|
non_allied_not_listed_at(const struct player *pplayer,
|
||
|
const int *list, int n, const struct tile *ptile);
|
||
| ... | ... | |
|
ACTION_PERFORM_UNIT_ANY(paction, actor_unit, pcity, punit, target_tile,
|
||
|
do_action_activity_targeted(actor_unit,
|
||
|
paction,
|
||
|
&target_extra));
|
||
|
target_extra));
|
||
|
break;
|
||
|
case ACTRES_CLEAN:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_action_activity_targeted(actor_unit,
|
||
|
paction,
|
||
|
&target_extra));
|
||
|
target_extra));
|
||
|
break;
|
||
|
case ACTRES_ROAD:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_action_activity_targeted(actor_unit,
|
||
|
paction,
|
||
|
&target_extra));
|
||
|
target_extra));
|
||
|
break;
|
||
|
case ACTRES_BASE:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_action_activity_targeted(actor_unit,
|
||
|
paction,
|
||
|
&target_extra));
|
||
|
target_extra));
|
||
|
break;
|
||
|
case ACTRES_MINE:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_action_activity_targeted(actor_unit,
|
||
|
paction,
|
||
|
&target_extra));
|
||
|
target_extra));
|
||
|
break;
|
||
|
case ACTRES_IRRIGATE:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_action_activity_targeted(actor_unit,
|
||
|
paction,
|
||
|
&target_extra));
|
||
|
target_extra));
|
||
|
break;
|
||
|
case ACTRES_NONE:
|
||
|
/* 100% ruleset defined. */
|
||
| ... | ... | |
|
}
|
||
|
/* The activity can now be set. */
|
||
|
unit_activity_handling_targeted(punit, activity, &activity_target,
|
||
|
unit_activity_handling_targeted(punit, activity, activity_target,
|
||
|
trigger_action);
|
||
|
}
|
||
| ... | ... | |
|
struct extra_type *target = nullptr;
|
||
|
/* Assume untargeted pillaging if no target specified */
|
||
|
unit_activity_handling_targeted(punit, new_activity, &target,
|
||
|
unit_activity_handling_targeted(punit, new_activity, target,
|
||
|
trigger_action);
|
||
|
} else if (can_unit_do_activity(nmap, punit, new_activity,
|
||
|
trigger_action)) {
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
static bool do_action_activity_targeted(struct unit *punit,
|
||
|
const struct action *paction,
|
||
|
struct extra_type **new_target)
|
||
|
struct extra_type *new_target)
|
||
|
{
|
||
|
enum unit_activity new_activity = action_get_activity(paction);
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
bool unit_activity_handling_targeted(struct unit *punit,
|
||
|
enum unit_activity new_activity,
|
||
|
struct extra_type **new_target,
|
||
|
struct extra_type *new_target,
|
||
|
enum gen_action trigger_action)
|
||
|
{
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
| ... | ... | |
|
unit_activity_handling(punit, new_activity, trigger_action);
|
||
|
} else if (can_unit_do_activity_targeted(nmap, punit,
|
||
|
new_activity, trigger_action,
|
||
|
*new_target)) {
|
||
|
new_target)) {
|
||
|
struct action_list *list = action_list_by_activity(new_activity);
|
||
|
free_unit_orders(punit);
|
||
| ... | ... | |
|
if (list != nullptr && action_list_size(list) > 0) {
|
||
|
/* Trigger action system */
|
||
|
unit_do_action(unit_owner(punit), punit->id, punit->tile->index,
|
||
|
(*new_target) != nullptr ? (*new_target)->id : NO_TARGET,
|
||
|
new_target != nullptr ? new_target->id : NO_TARGET,
|
||
|
"", action_number(action_list_get(list, 0)));
|
||
|
} else {
|
||
|
unit_activity_targeted_internal(punit, new_activity, new_target,
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
static bool unit_activity_targeted_internal(struct unit *punit,
|
||
|
enum unit_activity new_activity,
|
||
|
struct extra_type **new_target,
|
||
|
struct extra_type *new_target,
|
||
|
enum gen_action trigger_action)
|
||
|
{
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
|
if (!can_unit_do_activity_targeted(nmap, punit,
|
||
|
new_activity, trigger_action,
|
||
|
*new_target)) {
|
||
|
new_target)) {
|
||
|
return FALSE;
|
||
|
} else {
|
||
|
enum unit_activity old_activity = punit->activity;
|
||
| ... | ... | |
|
* (to ACTIVITY_IDLE in practice) */
|
||
|
unit_activity_handling(punit, new_activity, trigger_action);
|
||
|
} else {
|
||
|
set_unit_activity_targeted(punit, new_activity, *new_target,
|
||
|
set_unit_activity_targeted(punit, new_activity, new_target,
|
||
|
trigger_action);
|
||
|
send_unit_info(nullptr, punit);
|
||
|
unit_activity_dependencies(punit, old_activity, old_target);
|
||
| server/unithand.h | ||
|---|---|---|
|
enum gen_action trigger_action);
|
||
|
bool unit_activity_handling_targeted(struct unit *punit,
|
||
|
enum unit_activity new_activity,
|
||
|
struct extra_type **new_target,
|
||
|
struct extra_type *new_target,
|
||
|
enum gen_action trigger_action);
|
||
|
void unit_change_homecity_handling(struct unit *punit, struct city *new_pcity,
|
||
|
bool rehome);
|
||
| server/unittools.c | ||
|---|---|---|
|
void unit_assign_specific_activity_target(struct unit *punit,
|
||
|
enum unit_activity *activity,
|
||
|
enum gen_action action,
|
||
|
struct extra_type **target)
|
||
|
struct extra_type *target)
|
||
|
{
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
|
if (*activity == ACTIVITY_PILLAGE
|
||
|
&& *target == nullptr) {
|
||
|
&& target == nullptr) {
|
||
|
struct tile *ptile = unit_tile(punit);
|
||
|
struct extra_type *tgt;
|
||
|
bv_extras extras = *tile_extras(ptile);
|
||
| ... | ... | |
|
if (can_unit_do_activity_targeted(nmap, punit, *activity, action,
|
||
|
tgt)) {
|
||
|
*target = tgt;
|
||
|
target = tgt;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
| server/unittools.h | ||
|---|---|---|
|
void unit_assign_specific_activity_target(struct unit *punit,
|
||
|
enum unit_activity *activity,
|
||
|
enum gen_action action,
|
||
|
struct extra_type **target);
|
||
|
struct extra_type *target);
|
||
|
void unit_forget_last_activity(struct unit *punit);
|
||
|
void unit_make_contact(const struct unit *punit,
|
||
|
struct tile *ptile, struct player *pplayer);
|
||