From d03fa2d5b6cc36fe870efaabdd4c24b58c4e02a1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 18 Oct 2023 04:59:00 +0300 Subject: [PATCH 33/33] Add action information to unit structure It's not yet always correct, but many callers just pass dummy values. See osdn #48866 Signed-off-by: Marko Lindqvist --- ai/default/aiair.c | 4 +- ai/default/aidiplomat.c | 2 +- ai/default/aiferry.c | 6 +-- ai/default/daisettler.c | 6 +-- ai/default/daitools.c | 14 +++---- ai/default/daiunit.c | 26 +++++++------ common/unit.c | 33 ++++++++++++----- common/unit.h | 10 ++++- server/advisors/advgoto.c | 16 +++++--- server/advisors/autoworkers.c | 17 +++++---- server/citytools.c | 2 +- server/maphand.c | 2 +- server/savegame/savegame2.c | 63 ++++++++++++++++++++++--------- server/savegame/savegame3.c | 23 ++++++++---- server/unithand.c | 70 +++++++++++++++++++++-------------- server/unithand.h | 6 ++- server/unittools.c | 41 ++++++++++---------- 17 files changed, 211 insertions(+), 130 deletions(-) diff --git a/ai/default/aiair.c b/ai/default/aiair.c index 35d82d5069..f3ec47b804 100644 --- a/ai/default/aiair.c +++ b/ai/default/aiair.c @@ -546,7 +546,7 @@ void dai_manage_airunit(struct ai_type *ait, struct player *pplayer, return; /* The unit died. */ } pf_path_destroy(path); - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } else if ((dst_tile = dai_find_strategic_airbase(ait, punit, &path))) { log_debug("%s will fly to (%i, %i) (%s) to fight there", unit_rule_name(punit), TILE_XY(dst_tile), @@ -561,7 +561,7 @@ void dai_manage_airunit(struct ai_type *ait, struct player *pplayer, log_debug("%s cannot find anything to kill and is staying put", unit_rule_name(punit)); def_ai_unit_data(punit, ait)->done = TRUE; - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } } diff --git a/ai/default/aidiplomat.c b/ai/default/aidiplomat.c index 9c08d5b8e3..4f74efd5fc 100644 --- a/ai/default/aidiplomat.c +++ b/ai/default/aidiplomat.c @@ -340,7 +340,7 @@ static void dai_diplomat_city(struct ai_type *ait, struct unit *punit, UNIT_LOG(LOG_ERROR, punit, "no moves left in ai_diplomat_city()!"); } - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); /* Select the best potentially legal action. */ /* FIXME: what if it is illegal? */ diff --git a/ai/default/aiferry.c b/ai/default/aiferry.c index aed679dfed..91ff664f97 100644 --- a/ai/default/aiferry.c +++ b/ai/default/aiferry.c @@ -615,7 +615,7 @@ static void dai_activate_passengers(struct ai_type *ait, struct unit *ferry) unit_list_iterate_safe(unit_tile(ferry)->units, aunit) { if (unit_transport_get(aunit) == ferry) { - unit_activity_handling(aunit, ACTIVITY_IDLE); + unit_activity_handling(aunit, ACTIVITY_IDLE, ACTION_NONE); def_ai_unit_data(aunit, ait)->done = FALSE; if (unit_owner(aunit) == ferry_owner) { @@ -922,7 +922,7 @@ bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer, } if (same_pos(unit_tile(punit), dest_tile)) { /* Arrived */ - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } else { /* We are in still transit */ def_ai_unit_data(punit, ait)->done = TRUE; @@ -1254,7 +1254,7 @@ void dai_manage_ferryboat(struct ai_type *ait, struct player *pplayer, UNIT_LOG(LOGLEVEL_FERRY, punit, "Ferryboat is not carrying anyone " "(moves left: %d).", punit->moves_left); aiferry_make_available(ait, punit); - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL); CHECK_UNIT(punit); diff --git a/ai/default/daisettler.c b/ai/default/daisettler.c index beb08dd4d2..663618d703 100644 --- a/ai/default/daisettler.c +++ b/ai/default/daisettler.c @@ -1043,7 +1043,7 @@ BUILD_CITY: * unavailable, call it off. */ if (!city_can_be_built_here(ptile, punit, FALSE)) { dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL); - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); send_unit_info(NULL, punit); return; /* Avoid recursion at all cost */ @@ -1195,7 +1195,7 @@ void dai_auto_settler_cont(struct ai_type *ait, const struct civ_map *nmap, { if (!adv_worker_safe_tile(nmap, pplayer, punit, unit_tile(punit))) { - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } } @@ -1257,7 +1257,7 @@ static enum cb_error_level dai_do_build_city(struct ai_type *ait, struct city *pcity; fc_assert_ret_val(pplayer == unit_owner(punit), FALSE); - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); /* Free city reservations */ dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL); diff --git a/ai/default/daitools.c b/ai/default/daitools.c index 585df192d4..16a1227139 100644 --- a/ai/default/daitools.c +++ b/ai/default/daitools.c @@ -659,7 +659,7 @@ void dai_unit_new_task(struct ai_type *ait, struct unit *punit, if (punit->activity == ACTIVITY_GOTO) { /* It would indicate we're going somewhere otherwise */ - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } if (unit_data->task == AIUNIT_BUILD_CITY) { @@ -800,12 +800,12 @@ static void dai_unit_bodyguard_move(struct ai_type *ait, } if (bodyguard->moves_left <= 0) { - /* should generally should not happen */ + /* Should generally not happen */ BODYGUARD_LOG(ait, LOG_DEBUG, bodyguard, "was left behind by charge"); return; } - unit_activity_handling(bodyguard, ACTIVITY_IDLE); + unit_activity_handling(bodyguard, ACTIVITY_IDLE, ACTION_NONE); (void) dai_unit_move(ait, bodyguard, ptile); } @@ -824,7 +824,7 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile fc_assert_ret_val(is_ai(unit_owner(punit)), TRUE); fc_assert_ret_val(is_tiles_adjacent(unit_tile(punit), ptile), TRUE); - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); /* FIXME: try the next action if the unit tried to do an illegal action. * That would allow the AI to stop using the omniscient * is_action_enabled_unit_on_*() functions. */ @@ -1235,10 +1235,10 @@ bool dai_unit_move(struct ai_type *ait, struct unit *punit, struct tile *ptile) } } - /* go */ - unit_activity_handling(punit, ACTIVITY_IDLE); + /* Go */ + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); /* Move */ - if (paction && ptrans + if (paction != nullptr && ptrans != nullptr && action_has_result(paction, ACTRES_TRANSPORT_EMBARK)) { /* "Transport Embark". */ unit_do_action(unit_owner(punit), punit->id, ptrans->id, diff --git a/ai/default/daiunit.c b/ai/default/daiunit.c index eb0163fb83..bb9c79a92b 100644 --- a/ai/default/daiunit.c +++ b/ai/default/daiunit.c @@ -863,7 +863,8 @@ static void dai_military_findjob(struct ai_type *ait, if (can_unit_do_activity(nmap, punit, ACTIVITY_PILLAGE) && is_land_barbarian(pplayer)) { /* Land barbarians pillage */ - unit_activity_handling(punit, ACTIVITY_PILLAGE); + unit_activity_handling(punit, ACTIVITY_PILLAGE, + activity_default_action(ACTIVITY_PILLAGE)); } dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL); @@ -1799,7 +1800,7 @@ static void dai_military_attack(struct ai_type *ait, struct player *pplayer, * adv_follow_path(). This way other units will know we're * on our way even if we don't reach target yet. */ punit->goto_tile = dest_tile; - unit_activity_handling(punit, ACTIVITY_GOTO); + unit_activity_handling(punit, ACTIVITY_GOTO, ACTION_NONE); if (NULL != path && !adv_follow_path(punit, path, dest_tile)) { /* Died. */ pf_path_destroy(path); @@ -2491,7 +2492,7 @@ void dai_manage_military(struct ai_type *ait, struct player *pplayer, CHECK_UNIT(punit); /* "Escorting" aircraft should not do anything. They are activated - * by their transport or charge. We do _NOT_ set them to 'done' + * by their transport or charge. We do _NOT_ set them to 'done' * since they may need be activated once our charge moves. */ if (unit_data->task == AIUNIT_ESCORT && utype_fuel(unit_type_get(punit))) { @@ -2520,7 +2521,7 @@ void dai_manage_military(struct ai_type *ait, struct player *pplayer, result = dai_hunter_manage(ait, pplayer, punit); if (NULL == game_unit_by_number(sanity)) { TIMING_LOG(AIT_HUNTER, TIMER_STOP); - return; /* died */ + return; /* Died */ } if (result == -1) { (void) dai_hunter_manage(ait, pplayer, punit); /* More carnage */ @@ -2566,7 +2567,7 @@ void dai_manage_military(struct ai_type *ait, struct player *pplayer, case AIUNIT_EXPLORE: switch (manage_auto_explorer(punit)) { case MR_DEATH: - /* don't use punit! */ + /* Don't use punit! */ return; case MR_OK: UNIT_LOG(LOG_DEBUG, punit, "more exploring"); @@ -2583,7 +2584,7 @@ void dai_manage_military(struct ai_type *ait, struct player *pplayer, TIMING_LOG(AIT_RECOVER, TIMER_STOP); break; case AIUNIT_HUNTER: - fc_assert(FALSE); /* dealt with above */ + fc_assert(FALSE); /* Dealt with above */ break; default: fc_assert(FALSE); @@ -2596,17 +2597,18 @@ void dai_manage_military(struct ai_type *ait, struct player *pplayer, if (unit_list_find(unit_tile(punit)->units, unit_data->ferryboat)) { - unit_activity_handling(punit, ACTIVITY_SENTRY); + unit_activity_handling(punit, ACTIVITY_SENTRY, ACTION_NONE); } else if (pcity || punit->activity == ACTIVITY_IDLE) { /* We do not need to fortify in cities - we fortify and sentry * according to home defense setup, for easy debugging. */ if (!pcity || unit_data->task == AIUNIT_DEFEND_HOME) { if (punit->activity == ACTIVITY_IDLE || punit->activity == ACTIVITY_SENTRY) { - unit_activity_handling(punit, ACTIVITY_FORTIFYING); + unit_activity_handling(punit, ACTIVITY_FORTIFYING, + activity_default_action(ACTIVITY_FORTIFYING)); } } else { - unit_activity_handling(punit, ACTIVITY_SENTRY); + unit_activity_handling(punit, ACTIVITY_SENTRY, ACTION_NONE); } } } @@ -2946,7 +2948,7 @@ static void dai_manage_barbarian_leader(struct ai_type *ait, if (leader->moves_left == 0 || (can_unit_survive_at_tile(&(wld.map), leader, leader_tile) && 1 < unit_list_size(leader_tile->units))) { - unit_activity_handling(leader, ACTIVITY_SENTRY); + unit_activity_handling(leader, ACTIVITY_SENTRY, ACTION_NONE); return; } @@ -3037,7 +3039,7 @@ static void dai_manage_barbarian_leader(struct ai_type *ait, pf_reverse_map_destroy(pfrm); if (NULL == worst_danger) { - unit_activity_handling(leader, ACTIVITY_IDLE); + unit_activity_handling(leader, ACTIVITY_IDLE, ACTION_NONE); UNIT_LOG(LOG_DEBUG, leader, "Barbarian leader: no close enemy."); return; } @@ -3075,7 +3077,7 @@ static void dai_manage_barbarian_leader(struct ai_type *ait, if (same_pos(unit_tile(leader), safest_tile)) { UNIT_LOG(LOG_DEBUG, leader, "Barbarian leader: reached the safest position."); - unit_activity_handling(leader, ACTIVITY_IDLE); + unit_activity_handling(leader, ACTIVITY_IDLE, ACTION_NONE); pf_map_destroy(pfm); return; } diff --git a/common/unit.c b/common/unit.c index a08f2a13db..fb92c94436 100644 --- a/common/unit.c +++ b/common/unit.c @@ -506,9 +506,9 @@ bool can_unit_change_homecity(const struct unit *punit) } /**********************************************************************//** - Returns the speed of a unit doing an activity. This depends on the + Returns the speed of a unit doing an activity. This depends on the veteran level and the base move_rate of the unit (regardless of HP or - effects). Usually this is just used for settlers but the value is also + effects). Usually this is just used for settlers but the value is also used for military units doing fortify/pillage activities. The speed is multiplied by ACTIVITY_FACTOR. @@ -526,7 +526,7 @@ int get_activity_rate(const struct unit *punit) * the number of moves actually remaining or the adjusted move rate. * This means sea formers won't have their activity rate increased by * Magellan's, and it means injured units work just as fast as - * uninjured ones. Note the value is never less than SINGLE_MOVE. */ + * uninjured ones. Note the value is never less than SINGLE_MOVE. */ int move_rate = unit_type_get(punit)->move_rate; /* All settler actions are multiplied by ACTIVITY_FACTOR. */ @@ -537,7 +537,7 @@ int get_activity_rate(const struct unit *punit) /**********************************************************************//** Returns the amount of work a unit does (will do) on an activity this - turn. Units that have no MP do no work. + turn. Units that have no MP do no work. The speed is multiplied by ACTIVITY_FACTOR. **************************************************************************/ @@ -1087,9 +1087,11 @@ bool can_unit_do_activity_targeted_at(const struct civ_map *nmap, Assign a new task to a unit. Doesn't account for changed_from. **************************************************************************/ static void set_unit_activity_internal(struct unit *punit, - enum unit_activity new_activity) + enum unit_activity new_activity, + enum gen_action trigger_action) { punit->activity = new_activity; + punit->action = trigger_action; punit->activity_count = 0; punit->activity_target = NULL; if (new_activity == ACTIVITY_IDLE && punit->moves_left > 0) { @@ -1101,7 +1103,8 @@ static void set_unit_activity_internal(struct unit *punit, /**********************************************************************//** Assign a new untargeted task to a unit. **************************************************************************/ -void set_unit_activity(struct unit *punit, enum unit_activity new_activity) +void set_unit_activity(struct unit *punit, enum unit_activity new_activity, + enum gen_action trigger_action) { fc_assert_ret(!activity_requires_target(new_activity)); @@ -1109,7 +1112,7 @@ void set_unit_activity(struct unit *punit, enum unit_activity new_activity) && punit->changed_from == ACTIVITY_FORTIFIED) { new_activity = ACTIVITY_FORTIFIED; } - set_unit_activity_internal(punit, new_activity); + set_unit_activity_internal(punit, new_activity, trigger_action); if (new_activity == punit->changed_from) { punit->activity_count = punit->changed_from_count; } @@ -1120,12 +1123,13 @@ void set_unit_activity(struct unit *punit, enum unit_activity new_activity) **************************************************************************/ void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, - struct extra_type *new_target) + struct extra_type *new_target, + enum gen_action trigger_action) { fc_assert_ret(activity_requires_target(new_activity) || new_target == NULL); - set_unit_activity_internal(punit, new_activity); + set_unit_activity_internal(punit, new_activity, trigger_action); punit->activity_target = new_target; if (new_activity == punit->changed_from && new_target == punit->changed_from_target) { @@ -1144,6 +1148,7 @@ bool is_unit_activity_on_tile(enum unit_activity activity, return TRUE; } } unit_list_iterate_end; + return FALSE; } @@ -1700,7 +1705,7 @@ struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity, punit->carrying = nullptr; - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); punit->battlegroup = BATTLEGROUP_NONE; punit->has_orders = FALSE; @@ -2833,3 +2838,11 @@ struct unit_order *create_unit_orders(int length, return unit_orders; } + +/**********************************************************************//** + Action that matches activity. Currently dummy placeholder. +**************************************************************************/ +enum gen_action activity_default_action(enum unit_activity act) +{ + return ACTION_NONE; +} diff --git a/common/unit.h b/common/unit.h index b71a841dec..ba76a9fbcb 100644 --- a/common/unit.h +++ b/common/unit.h @@ -21,6 +21,7 @@ extern "C" { #include "bitvector.h" /* common */ +#include "actions.h" #include "base.h" #include "fc_interface.h" #include "fc_types.h" @@ -155,6 +156,7 @@ struct unit { struct tile *goto_tile; /* May be NULL. */ enum unit_activity activity; + enum gen_action action; /* The amount of work that has been done on the current activity. This * is counted in turns but is multiplied by ACTIVITY_FACTOR (which allows @@ -341,10 +343,12 @@ bool can_unit_do_activity_targeted_at(const struct civ_map *nmap, enum unit_activity activity, struct extra_type *target, const struct tile *ptile); -void set_unit_activity(struct unit *punit, enum unit_activity new_activity); +void set_unit_activity(struct unit *punit, enum unit_activity new_activity, + enum gen_action trigger_action); void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, - struct extra_type *new_target); + struct extra_type *new_target, + enum gen_action trigger_action); int get_activity_rate(const struct unit *punit); int get_activity_rate_this_turn(const struct unit *punit); int get_turns_for_activity_at(const struct unit *punit, @@ -566,6 +570,8 @@ bool unit_order_list_is_sane(int length, const struct unit_order *orders); struct unit_order *create_unit_orders(int length, const struct unit_order *orders); +enum gen_action activity_default_action(enum unit_activity act); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/server/advisors/advgoto.c b/server/advisors/advgoto.c index 38b5e47a7f..c8400bf2ae 100644 --- a/server/advisors/advgoto.c +++ b/server/advisors/advgoto.c @@ -55,19 +55,23 @@ bool adv_follow_path(struct unit *punit, struct pf_path *path, if (punit->moves_left <= 0) { return TRUE; } + punit->goto_tile = ptile; - unit_activity_handling(punit, ACTIVITY_GOTO); + unit_activity_handling(punit, ACTIVITY_GOTO, ACTION_NONE); alive = adv_unit_execute_path(punit, path); + if (alive) { if (activity != ACTIVITY_GOTO) { /* Only go via ACTIVITY_IDLE if we are actually changing the activity */ - unit_activity_handling(punit, ACTIVITY_IDLE); + 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. */ send_unit_info(NULL, punit); } + return alive; } @@ -280,13 +284,13 @@ static bool adv_unit_move(struct unit *punit, struct tile *ptile) } } - /* go */ - unit_activity_handling(punit, ACTIVITY_IDLE); + /* Go */ + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); /* Move */ /* TODO: Differentiate (server side AI) player from server side agent * working for (possibly AI) player by using ACT_REQ_PLAYER and * ACT_REQ_SS_AGENT */ - if (paction && ptrans + if (paction != nullptr && ptrans != nullptr && action_has_result(paction, ACTRES_TRANSPORT_EMBARK)) { /* "Transport Embark". */ unit_do_action(unit_owner(punit), punit->id, ptrans->id, diff --git a/server/advisors/autoworkers.c b/server/advisors/autoworkers.c index c8a10a1ff1..27c2f376ee 100644 --- a/server/advisors/autoworkers.c +++ b/server/advisors/autoworkers.c @@ -947,7 +947,7 @@ void auto_worker_findwork(const struct civ_map *nmap, log_warn("Workers displacing each other recursing too much."); adv_unit_new_task(punit, AUT_NONE, NULL); - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); send_unit_info(NULL, punit); return; /* Avoid further recursion. */ @@ -1107,13 +1107,16 @@ bool auto_worker_setup_work(const struct civ_map *nmap, if (alive && same_pos(unit_tile(punit), best_tile) && punit->moves_left > 0) { + enum gen_action action = activity_default_action(best_act); + /* 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); + unit_activity_handling(punit, best_act, action); } - send_unit_info(NULL, punit); /* FIXME: probably duplicate */ + send_unit_info(NULL, punit); /* FIXME: Probably duplicate */ UNIT_LOG(LOG_DEBUG, punit, "reached its worksite and started work"); @@ -1222,16 +1225,16 @@ void auto_workers_player(struct player *pplayer) TILE_XY(unit_tile(punit)), server_side_agent_name(SSA_AUTOWORKER)); if (punit->activity == ACTIVITY_SENTRY) { - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } if (punit->activity == ACTIVITY_GOTO && punit->moves_left > 0) { - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } if (punit->activity != ACTIVITY_IDLE) { if (!is_ai(pplayer)) { if (!adv_worker_safe_tile(nmap, pplayer, punit, unit_tile(punit))) { - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } } else { CALL_PLR_AI_FUNC(settler_cont, pplayer, pplayer, punit, state); diff --git a/server/citytools.c b/server/citytools.c index 982a2c5a7a..f923e9cfec 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -1744,7 +1744,7 @@ void remove_city(struct city *pcity) continue; } - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); moved = FALSE; adjc_iterate(&(wld.map), pcenter, tile1) { struct unit *ptrans; diff --git a/server/maphand.c b/server/maphand.c index 7ac0103dfa..65086d4b17 100644 --- a/server/maphand.c +++ b/server/maphand.c @@ -1834,7 +1834,7 @@ static void terrain_change_bounce_single_unit(struct unit *punit, unit_alive = unit_move(punit, ptile2, 0, NULL, TRUE, FALSE, FALSE, FALSE, FALSE); if (unit_alive && punit->activity == ACTIVITY_SENTRY) { - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } break; } diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index 55c60ae9e4..dadf51ec20 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -573,8 +573,10 @@ static void loaddata_destroy(struct loaddata *loading) static void set_unit_activity_base(struct unit *punit, Base_type_id base) { + /* FIXME: Correct action from the savegame */ set_unit_activity_targeted(punit, ACTIVITY_BASE, - base_extra_get(base_by_number(base))); + base_extra_get(base_by_number(base)), + ACTION_NONE); } /************************************************************************//** @@ -583,8 +585,10 @@ static void set_unit_activity_base(struct unit *punit, static void set_unit_activity_road(struct unit *punit, Road_type_id road) { + /* FIXME: Correct action from the savegame */ set_unit_activity_targeted(punit, ACTIVITY_GEN_ROAD, - road_extra_get(road_by_number(road))); + road_extra_get(road_by_number(road)), + ACTION_NONE); } /* ======================================================================= @@ -4279,16 +4283,20 @@ static bool sg_load_player_unit(struct loaddata *loading, if (extra_id != -2) { if (extra_id >= 0 && extra_id < loading->extra.size) { pextra = loading->extra.order[extra_id]; - set_unit_activity_targeted(punit, activity, pextra); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, activity, pextra, ACTION_NONE); } else if (activity == ACTIVITY_IRRIGATE) { struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), EC_IRRIGATION, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, tgt, + ACTION_NONE); } else { - set_unit_activity(punit, ACTIVITY_CULTIVATE); + /* FIXME: Correct action from the savegame */ + set_unit_activity(punit, ACTIVITY_CULTIVATE, ACTION_NONE); } } else if (activity == ACTIVITY_MINE) { struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), @@ -4296,12 +4304,16 @@ static bool sg_load_player_unit(struct loaddata *loading, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_MINE, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_MINE, tgt, + ACTION_NONE); } else { - set_unit_activity(punit, ACTIVITY_PLANT); + /* FIXME: Correct action from the savegame */ + set_unit_activity(punit, ACTIVITY_PLANT, ACTION_NONE); } } else { - set_unit_activity(punit, activity); + /* FIXME: Correct action from the savegame */ + set_unit_activity(punit, activity, ACTION_NONE); } } else { /* extra_id == -2 -> activity_tgt not set */ @@ -4354,7 +4366,7 @@ static bool sg_load_player_unit(struct loaddata *loading, } else { log_sg("Cannot find base %d for %s to build", base_id, unit_rule_name(punit)); - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); } } else if (activity == ACTIVITY_GEN_ROAD) { if (proad) { @@ -4362,7 +4374,7 @@ static bool sg_load_player_unit(struct loaddata *loading, } else { log_sg("Cannot find road %d for %s to build", road_id, unit_rule_name(punit)); - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); } } else if (activity == ACTIVITY_PILLAGE) { struct extra_type *a_target; @@ -4379,16 +4391,21 @@ static bool sg_load_player_unit(struct loaddata *loading, /* An out-of-range base number is seen with old savegames. We take * it as indicating undirected pillaging. We will assign pillage * targets before play starts. */ - set_unit_activity_targeted(punit, activity, a_target); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, activity, a_target, ACTION_NONE); } else if (activity == ACTIVITY_IRRIGATE) { struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), EC_IRRIGATION, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, tgt, + ACTION_NONE); } else { - set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, NULL); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, NULL, + ACTION_NONE); } } else if (activity == ACTIVITY_MINE) { struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), @@ -4396,9 +4413,13 @@ static bool sg_load_player_unit(struct loaddata *loading, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_MINE, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_MINE, tgt, + ACTION_NONE); } else { - set_unit_activity_targeted(punit, ACTIVITY_MINE, NULL); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_MINE, NULL, + ACTION_NONE); } } else if (activity == ACTIVITY_OLD_POLLUTION_SG2 || activity == ACTIVITY_OLD_FALLOUT_SG2) { @@ -4407,12 +4428,18 @@ static bool sg_load_player_unit(struct loaddata *loading, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_CLEAN, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_CLEAN, tgt, + ACTION_NONE); } else { - set_unit_activity_targeted(punit, ACTIVITY_CLEAN, NULL); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_CLEAN, NULL, + ACTION_NONE); } } else { - set_unit_activity_targeted(punit, activity, NULL); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, activity, NULL, + ACTION_NONE); } } /* activity_tgt == NULL */ diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index 8e4f51a54a..dc8a872ff2 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -6114,16 +6114,20 @@ static bool sg_load_player_unit(struct loaddata *loading, if (extra_id != -2) { if (extra_id >= 0 && extra_id < loading->extra.size) { pextra = loading->extra.order[extra_id]; - set_unit_activity_targeted(punit, activity, pextra); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, activity, pextra, ACTION_NONE); } else if (activity == ACTIVITY_IRRIGATE) { struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), EC_IRRIGATION, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_IRRIGATE, tgt, + ACTION_NONE); } else { - set_unit_activity(punit, ACTIVITY_CULTIVATE); + /* FIXME: Correct action from the savegame */ + set_unit_activity(punit, ACTIVITY_CULTIVATE, ACTION_NONE); } } else if (activity == ACTIVITY_MINE) { struct extra_type *tgt = next_extra_for_tile(unit_tile(punit), @@ -6131,15 +6135,20 @@ static bool sg_load_player_unit(struct loaddata *loading, unit_owner(punit), punit); if (tgt != NULL) { - set_unit_activity_targeted(punit, ACTIVITY_MINE, tgt); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, ACTIVITY_MINE, tgt, + ACTION_NONE); } else { - set_unit_activity(punit, ACTIVITY_PLANT); + /* FIXME: Correct action from the savegame */ + set_unit_activity(punit, ACTIVITY_PLANT, ACTION_NONE); } } else { - set_unit_activity(punit, activity); + /* FIXME: Correct action from the savegame */ + set_unit_activity(punit, activity, ACTION_NONE); } } else { - set_unit_activity_targeted(punit, activity, NULL); + /* FIXME: Correct action from the savegame */ + set_unit_activity_targeted(punit, activity, NULL, ACTION_NONE); } /* activity_tgt == NULL */ sg_warn_ret_val(secfile_lookup_int(loading->file, &punit->activity_count, diff --git a/server/unithand.c b/server/unithand.c index 4740196ad1..36e94751b8 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -112,10 +112,12 @@ struct ane_expl { }; static bool unit_activity_internal(struct unit *punit, - enum unit_activity new_activity); + enum unit_activity new_activity, + 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, action_id stopped_action, @@ -4268,7 +4270,8 @@ static bool city_build(struct player *pplayer, struct unit *punit, static void handle_unit_change_activity_real(struct player *pplayer, int unit_id, enum unit_activity activity, - struct extra_type *activity_target) + struct extra_type *activity_target, + enum gen_action trigger_action) { struct unit *punit = player_unit_by_number(pplayer, unit_id); @@ -4303,12 +4306,13 @@ static void handle_unit_change_activity_real(struct player *pplayer, } if (activity == ACTIVITY_EXPLORE) { - /* Please use unit_server_side_agent_set. */ + /* Please use unit_server_side_agent_set(). */ return; } /* The activity can now be set. */ - unit_activity_handling_targeted(punit, activity, &activity_target); + unit_activity_handling_targeted(punit, activity, &activity_target, + trigger_action); } /**********************************************************************//** @@ -4369,7 +4373,8 @@ void handle_unit_change_activity(struct player *pplayer, int unit_id, } #endif /* FREECIV_WEB */ - handle_unit_change_activity_real(pplayer, unit_id, activity, activity_target); + handle_unit_change_activity_real(pplayer, unit_id, activity, activity_target, + activity_default_action(activity)); } /**********************************************************************//** @@ -6282,7 +6287,7 @@ void handle_unit_sscs_set(struct player *pplayer, return; } - if (!unit_activity_internal(punit, ACTIVITY_IDLE)) { + if (!unit_activity_internal(punit, ACTIVITY_IDLE, ACTION_NONE)) { /* Impossible to set to Idle? */ fc_assert(FALSE); } @@ -6291,7 +6296,7 @@ void handle_unit_sscs_set(struct player *pplayer, return; } - if (!unit_activity_internal(punit, ACTIVITY_SENTRY)) { + if (!unit_activity_internal(punit, ACTIVITY_SENTRY, ACTION_NONE)) { /* Should have been caught above */ fc_assert(FALSE); } @@ -6351,7 +6356,7 @@ void handle_unit_server_side_agent_set(struct player *pplayer, unit_plans_clear(punit); if (agent == SSA_AUTOEXPLORE) { - if (!unit_activity_internal(punit, ACTIVITY_EXPLORE)) { + if (!unit_activity_internal(punit, ACTIVITY_EXPLORE, ACTION_NONE)) { /* Should have been caught above */ fc_assert(FALSE); punit->ssa_controller = SSA_NONE; @@ -6422,7 +6427,7 @@ static void unit_activity_dependencies(struct unit *punit, if (punit2->activity == ACTIVITY_PILLAGE) { extra_deps_iterate(&(punit2->activity_target->reqs), pdep) { if (pdep == old_target) { - set_unit_activity(punit2, ACTIVITY_IDLE); + set_unit_activity(punit2, ACTIVITY_IDLE, ACTION_NONE); send_unit_info(NULL, punit2); break; } @@ -6437,16 +6442,16 @@ static void unit_activity_dependencies(struct unit *punit, punit->ssa_controller = SSA_NONE; break; default: - ; /* do nothing */ + ; /* Do nothing */ } break; case ACTIVITY_EXPLORE: punit->ssa_controller = SSA_AUTOEXPLORE; - set_unit_activity(punit, ACTIVITY_EXPLORE); + set_unit_activity(punit, ACTIVITY_EXPLORE, ACTION_NONE); send_unit_info(NULL, punit); break; default: - /* do nothing */ + /* Do nothing */ break; } } @@ -6465,14 +6470,15 @@ static bool do_action_activity(struct unit *punit, fc_assert_ret_val(new_activity != ACTIVITY_LAST, FALSE); fc_assert_ret_val(!activity_requires_target(new_activity), FALSE); - return unit_activity_internal(punit, new_activity); + return unit_activity_internal(punit, new_activity, action_id(paction)); } /**********************************************************************//** Handle request for changing activity. **************************************************************************/ bool unit_activity_handling(struct unit *punit, - enum unit_activity new_activity) + enum unit_activity new_activity, + enum gen_action trigger_action) { const struct civ_map *nmap = &(wld.map); @@ -6484,10 +6490,11 @@ bool unit_activity_handling(struct unit *punit, struct extra_type *target = NULL; /* 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)) { free_unit_orders(punit); - unit_activity_internal(punit, new_activity); + unit_activity_internal(punit, new_activity, trigger_action); } return TRUE; @@ -6500,7 +6507,8 @@ bool unit_activity_handling(struct unit *punit, this returns TRUE, unit may have died during the action. **************************************************************************/ static bool unit_activity_internal(struct unit *punit, - enum unit_activity new_activity) + enum unit_activity new_activity, + enum gen_action trigger_action) { if (!can_unit_do_activity(&(wld.map), punit, new_activity)) { return FALSE; @@ -6508,7 +6516,7 @@ static bool unit_activity_internal(struct unit *punit, enum unit_activity old_activity = punit->activity; struct extra_type *old_target = punit->activity_target; - set_unit_activity(punit, new_activity); + set_unit_activity(punit, new_activity, trigger_action); send_unit_info(NULL, punit); unit_activity_dependencies(punit, old_activity, old_target); @@ -6530,9 +6538,11 @@ static bool do_action_activity_targeted(struct unit *punit, fc_assert_ret_val(new_activity != ACTIVITY_LAST, FALSE); fc_assert_ret_val(activity_requires_target(new_activity), - unit_activity_internal(punit, new_activity)); + unit_activity_internal(punit, new_activity, + action_id(paction))); - return unit_activity_targeted_internal(punit, new_activity, new_target); + return unit_activity_targeted_internal(punit, new_activity, new_target, + action_id(paction)); } /**********************************************************************//** @@ -6540,14 +6550,16 @@ static bool do_action_activity_targeted(struct unit *punit, **************************************************************************/ 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) { if (!activity_requires_target(new_activity)) { - unit_activity_handling(punit, new_activity); + unit_activity_handling(punit, new_activity, trigger_action); } else if (can_unit_do_activity_targeted(&(wld.map), punit, new_activity, *new_target)) { free_unit_orders(punit); - unit_activity_targeted_internal(punit, new_activity, new_target); + unit_activity_targeted_internal(punit, new_activity, new_target, + trigger_action); } return TRUE; @@ -6561,7 +6573,8 @@ bool unit_activity_handling_targeted(struct unit *punit, **************************************************************************/ 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) { if (!can_unit_do_activity_targeted(&(wld.map), punit, new_activity, *new_target)) { @@ -6577,9 +6590,10 @@ static bool unit_activity_targeted_internal(struct unit *punit, && !activity_requires_target(new_activity)) { /* unit_assign_specific_activity_target() changed our target activity * (to ACTIVITY_IDLE in practice) */ - unit_activity_handling(punit, new_activity); + 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(NULL, punit); unit_activity_dependencies(punit, old_activity, old_target); @@ -6641,7 +6655,7 @@ void handle_unit_orders(struct player *pplayer, if (ACTIVITY_IDLE != punit->activity) { /* New orders implicitly abandon current activity */ - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); } if (length) { diff --git a/server/unithand.h b/server/unithand.h index 26e786f831..60396547e2 100644 --- a/server/unithand.h +++ b/server/unithand.h @@ -21,10 +21,12 @@ #include /* <> so looked from the build directory first. */ bool unit_activity_handling(struct unit *punit, - enum unit_activity new_activity); + enum unit_activity new_activity, + 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); diff --git a/server/unittools.c b/server/unittools.c index 05567041ae..24f919aac3 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -561,7 +561,7 @@ void player_restore_units(struct player *pplayer) if (alive) { /* Clear activity. Unit info will be sent in the end of * the function. */ - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); adv_unit_new_task(punit, AUT_NONE, NULL); punit->goto_tile = NULL; @@ -661,7 +661,7 @@ static void unit_restore_hitpoints(struct unit *punit) if (punit->hp >= unit_type_get(punit)->hp) { punit->hp = unit_type_get(punit)->hp; if (was_lower && punit->activity == ACTIVITY_SENTRY) { - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); } } @@ -832,7 +832,7 @@ void unit_activities_cancel(struct unit *punit) free_unit_orders(punit); } - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); send_unit_info(NULL, punit); } @@ -1028,7 +1028,7 @@ static void update_unit_activity(struct unit *punit) * Mark it idle (already finished) so its "current" * activity is not considered illegal * in tile_change_side_effects() . */ - set_unit_activity(punit2, ACTIVITY_IDLE); + set_unit_activity(punit2, ACTIVITY_IDLE, ACTION_NONE); } } unit_list_iterate_end; @@ -1039,7 +1039,7 @@ static void update_unit_activity(struct unit *punit) if (punit->activity_count >= action_id_get_act_time(ACTION_FORTIFY, punit, ptile, punit->activity_target)) { - set_unit_activity(punit, ACTIVITY_FORTIFIED); + set_unit_activity(punit, ACTIVITY_FORTIFIED, punit->action); unit_activity_done = TRUE; } } @@ -1049,7 +1049,7 @@ static void update_unit_activity(struct unit *punit) >= action_id_get_act_time(ACTION_CONVERT, punit, ptile, punit->activity_target)) { unit_convert(punit); - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); unit_activity_done = TRUE; } } @@ -2032,7 +2032,7 @@ static void wipe_unit_full(struct unit *punit, bool transported, /* Activate sentried units - like planes on a disbanded carrier. * Note this will activate ground units even if they just change * transporter. */ - set_unit_activity(pcargo, ACTIVITY_IDLE); + set_unit_activity(pcargo, ACTIVITY_IDLE, ACTION_NONE); } /* Unit info for unhealthy units will be sent when they are @@ -2989,23 +2989,23 @@ void do_explore(struct unit *punit) return; case MR_OK: /* FIXME: manage_auto_explorer() isn't supposed to change the activity, - * but don't count on this. See PR#39792. + * but don't count on this. See PR#39792. */ if (punit->activity == ACTIVITY_EXPLORE) { break; } /* fallthru */ default: - unit_activity_handling(punit, ACTIVITY_IDLE); + unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE); /* FIXME: When the manage_auto_explorer() call changes the activity from * EXPLORE to IDLE, in unit_activity_handling() ai.control is left - * alone. We reset it here. See PR#12931. */ + * alone. We reset it here. See PR#12931. */ punit->ssa_controller = SSA_NONE; break; } - send_unit_info(NULL, punit); /* probably duplicate */ + send_unit_info(NULL, punit); /* Probably duplicate */ } /**********************************************************************//** @@ -3480,7 +3480,7 @@ static bool unit_survive_autoattack(struct unit *punit) 1.0 - punitwin, threshold); #endif - unit_activity_handling(penemy, ACTIVITY_IDLE); + unit_activity_handling(penemy, ACTIVITY_IDLE, ACTION_NONE); action_auto_perf_unit_do(AAPC_UNIT_MOVED_ADJ, penemy, unit_owner(punit), NULL, NULL, tgt_tile, tile_city(tgt_tile), punit, NULL); @@ -3565,7 +3565,7 @@ static void wakeup_neighbor_sentries(struct unit *punit) || can_player_see_unit(unit_owner(penemy), punit)) /* on board transport; don't awaken */ && can_unit_exist_at_tile(&(wld.map), penemy, unit_tile(penemy))) { - set_unit_activity(penemy, ACTIVITY_IDLE); + set_unit_activity(penemy, ACTIVITY_IDLE, ACTION_NONE); send_unit_info(NULL, penemy); } } unit_list_iterate_end; @@ -3753,7 +3753,7 @@ static void check_unit_activity(struct unit *punit) case ACTIVITY_GEN_ROAD: case ACTIVITY_CONVERT: case ACTIVITY_LAST: - set_unit_activity(punit, ACTIVITY_IDLE); + set_unit_activity(punit, ACTIVITY_IDLE, ACTION_NONE); break; }; } @@ -4174,7 +4174,7 @@ bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost, && !unit_has_orders(punit) && punit->ssa_controller == SSA_NONE && !can_unit_exist_at_tile(&(wld.map), punit, pdesttile)) { - set_unit_activity(punit, ACTIVITY_SENTRY); + set_unit_activity(punit, ACTIVITY_SENTRY, ACTION_NONE); } send_unit_info(NULL, punit); @@ -4478,16 +4478,16 @@ bool execute_orders(struct unit *punit, const bool fresh) && punit->orders.index + 1 == punit->orders.length); if (last_order) { - /* Clear the orders before we engage in the move. That way any + /* Clear the orders before we engage in the move. That way any * has_orders checks will yield FALSE and this will be treated as - * a normal move. This is important: for instance a caravan goto + * a normal move. This is important: for instance a caravan goto * will popup the caravan dialog on the last move only. */ free_unit_orders(punit); } - /* Advance the orders one step forward. This is needed because any + /* Advance the orders one step forward. This is needed because any * updates sent to the client as a result of the action should include - * the new index value. Note that we have to send_unit_info somewhere + * the new index value. Note that we have to send_unit_info() somewhere * after this point so that the client is properly updated. */ punit->orders.index++; @@ -4510,7 +4510,8 @@ bool execute_orders(struct unit *punit, const bool fresh) if (can_unit_do_activity(nmap, punit, activity)) { punit->done_moving = TRUE; - set_unit_activity(punit, activity); + /* FIXME: Have actions also with orders */ + set_unit_activity(punit, activity, activity_default_action(activity)); send_unit_info(NULL, punit); break; -- 2.42.0