From fb0277e9974d418a530aed501dc3fe85837c6651 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 8 Jan 2024 08:28:50 +0200
Subject: [PATCH 17/40] Move action_target_kind_default() to actres.c under
 name actres_...()

Replace switch-case by an indexed table lookup.

See RM #144

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/actions.c          |  95 +----------------------
 common/actions.h          |   2 -
 common/actres.c           | 153 +++++++++++++++++++++-----------------
 common/actres.h           |   3 +
 server/ruleset/ruleload.c |   2 +-
 5 files changed, 90 insertions(+), 165 deletions(-)

diff --git a/common/actions.c b/common/actions.c
index e34b9005f8..7ffc046f0d 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -933,7 +933,7 @@ static struct action *action_new(action_id id,
   BV_CLR_ALL(action->sub_results);
 
   action->actor_kind = AAK_UNIT;
-  action->target_kind = action_target_kind_default(result);
+  action->target_kind = actres_target_kind_default(result);
   action->sub_target_kind = action_sub_target_kind_default(result);
   action->target_complexity = actres_target_compl_calc(result);
 
@@ -6762,99 +6762,6 @@ const char *action_target_kind_ruleset_var_name(int act)
   return NULL;
 }
 
-/**********************************************************************//**
-  Return default target kind for the action with the specified result.
-**************************************************************************/
-enum action_target_kind
-action_target_kind_default(enum action_result result)
-{
-  fc_assert_ret_val(action_result_is_valid(result) || result == ACTRES_NONE,
-                    RS_DEFAULT_USER_ACTION_TARGET_KIND);
-
-  switch (result) {
-  case ACTRES_ESTABLISH_EMBASSY:
-  case ACTRES_SPY_INVESTIGATE_CITY:
-  case ACTRES_SPY_POISON:
-  case ACTRES_SPY_STEAL_GOLD:
-  case ACTRES_SPY_SABOTAGE_CITY:
-  case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
-  case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
-  case ACTRES_SPY_STEAL_TECH:
-  case ACTRES_SPY_TARGETED_STEAL_TECH:
-  case ACTRES_SPY_INCITE_CITY:
-  case ACTRES_TRADE_ROUTE:
-  case ACTRES_MARKETPLACE:
-  case ACTRES_HELP_WONDER:
-  case ACTRES_JOIN_CITY:
-  case ACTRES_STEAL_MAPS:
-  case ACTRES_SPY_NUKE:
-  case ACTRES_DESTROY_CITY:
-  case ACTRES_DISBAND_UNIT_RECOVER:
-  case ACTRES_HOME_CITY:
-  case ACTRES_UPGRADE_UNIT:
-  case ACTRES_AIRLIFT:
-  case ACTRES_STRIKE_BUILDING:
-  case ACTRES_STRIKE_PRODUCTION:
-  case ACTRES_CONQUER_CITY:
-  case ACTRES_SPY_SPREAD_PLAGUE:
-  case ACTRES_SPY_ESCAPE:
-    return ATK_CITY;
-  case ACTRES_SPY_BRIBE_UNIT:
-  case ACTRES_SPY_SABOTAGE_UNIT:
-  case ACTRES_EXPEL_UNIT:
-  case ACTRES_HEAL_UNIT:
-  case ACTRES_TRANSPORT_DEBOARD:
-  case ACTRES_TRANSPORT_UNLOAD:
-  case ACTRES_TRANSPORT_LOAD:
-  case ACTRES_TRANSPORT_BOARD:
-  case ACTRES_TRANSPORT_EMBARK:
-    return ATK_UNIT;
-  case ACTRES_BOMBARD:
-  case ACTRES_ATTACK:
-  case ACTRES_WIPE_UNITS:
-  case ACTRES_CAPTURE_UNITS:
-  case ACTRES_NUKE_UNITS:
-  case ACTRES_SPY_ATTACK:
-  case ACTRES_COLLECT_RANSOM:
-    return ATK_UNITS;
-  case ACTRES_FOUND_CITY:
-  case ACTRES_NUKE:
-  case ACTRES_PARADROP:
-  case ACTRES_PARADROP_CONQUER:
-  case ACTRES_TRANSFORM_TERRAIN:
-  case ACTRES_CULTIVATE:
-  case ACTRES_PLANT:
-  case ACTRES_PILLAGE:
-  case ACTRES_CLEAN:
-  case ACTRES_ROAD:
-  case ACTRES_BASE:
-  case ACTRES_MINE:
-  case ACTRES_IRRIGATE:
-  case ACTRES_TRANSPORT_DISEMBARK:
-  case ACTRES_HUT_ENTER:
-  case ACTRES_HUT_FRIGHTEN:
-  case ACTRES_UNIT_MOVE:
-  case ACTRES_TELEPORT:
-  case ACTRES_TELEPORT_CONQUER:
-    return ATK_TILE;
-  case ACTRES_CONQUER_EXTRAS:
-    return ATK_EXTRAS;
-  case ACTRES_DISBAND_UNIT:
-  case ACTRES_CONVERT:
-  case ACTRES_FORTIFY:
-  case ACTRES_HOMELESS:
-  case ACTRES_ENABLER_CHECK:
-    return ATK_SELF;
-  case ACTRES_NONE:
-    return RS_DEFAULT_USER_ACTION_TARGET_KIND;
-
-  ASSERT_UNUSED_ACTRES_CASES;
-  }
-
-  /* Should never be reached. */
-  return RS_DEFAULT_USER_ACTION_TARGET_KIND;
-}
-
 /**********************************************************************//**
   Returns TRUE iff the specified action result works with the specified
   action target kind.
diff --git a/common/actions.h b/common/actions.h
index 12b42b2708..09de098a7e 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -473,8 +473,6 @@ const char *action_min_range_ruleset_var_name(int act);
 const char *action_max_range_ruleset_var_name(int act);
 
 const char *action_target_kind_ruleset_var_name(int act);
-enum action_target_kind
-action_target_kind_default(enum action_result result);
 bool action_result_legal_target_kind(enum action_result result,
                                      enum action_target_kind tgt_kind);
 const char *action_target_kind_help(enum action_target_kind kind);
diff --git a/common/actres.c b/common/actres.c
index 9f5fdb77b0..ee9797ff93 100644
--- a/common/actres.c
+++ b/common/actres.c
@@ -33,208 +33,208 @@
 static struct actres act_results[ACTRES_LAST] = {
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_ESTABLISH_EMBASSY */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_SPY_INVESTIGATE_CITY */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_POISON */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_STEAL_GOLD */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_SABOTAGE_CITY */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_SABOTAGE_CITY */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_SABOTAGE_CITY_PRODUCTION */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_STEAL_TECH */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_MANDATORY, ABK_DIPLOMATIC, /* ACTRES_SPY_TARGETED_STEAL_TECH */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_INCITE_CITY */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRADE_ROUTE */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_MARKETPLACE */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_HELP_WONDER */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_BRIBE_UNIT */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_SABOTAGE_UNIT */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_CAPTURE_UNITS */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_FOUND_CITY */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_JOIN_CITY */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_STEAL_MAPS */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_BOMBARD */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_NUKE */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_NUKE */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_NUKE_UNITS */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_DESTROY_CITY */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_EXPEL_UNIT */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_DISBAND_UNIT_RECOVER */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE , ERM_NONE},
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_DISBAND_UNIT */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_SELF },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_HOME_CITY */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_UPGRADE_UNIT */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_PARADROP */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_AIRLIFT */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD,      /* ACTRES_ATTACK */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_MANDATORY, ABK_NONE,       /* ACTRES_STRIKE_BUILDING */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_STRIKE_PRODUCTION */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_CONQUER_CITY */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_HEAL_UNIT */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSFORM_TERRAIN */
     FALSE, ACTIVITY_TRANSFORM, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_CULTIVATE */
     FALSE, ACTIVITY_CULTIVATE, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_PLANT */
     FALSE, ACTIVITY_PLANT, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE,        /* ACTRES_PILLAGE */
     TRUE, ACTIVITY_PILLAGE, DRT_NONE,
-    EC_NONE, ERM_PILLAGE },
+    EC_NONE, ERM_PILLAGE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_FORTIFY */
     FALSE, ACTIVITY_FORTIFYING, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_SELF },
   { ACT_TGT_COMPL_MANDATORY, ABK_NONE,       /* ACTRES_ROAD */
     FALSE, ACTIVITY_GEN_ROAD, DRT_NONE,
-    EC_ROAD, ERM_NONE },
+    EC_ROAD, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_CONVERT */
     FALSE, ACTIVITY_CONVERT, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_SELF },
   { ACT_TGT_COMPL_MANDATORY, ABK_NONE,       /* ACTRES_BASE */
     FALSE, ACTIVITY_BASE, DRT_NONE,
-    EC_BASE, ERM_NONE },
+    EC_BASE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_MANDATORY, ABK_NONE,       /* ACTRES_MINE */
     FALSE, ACTIVITY_MINE, DRT_NONE,
-    EC_MINE, ERM_NONE },
+    EC_MINE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_MANDATORY, ABK_NONE,       /* ACTRES_IRRIGATE */
     FALSE, ACTIVITY_IRRIGATE, DRT_NONE,
-    EC_IRRIGATION, ERM_NONE },
+    EC_IRRIGATION, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD,      /* ACTRES_COLLECT_RANSOM */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE,        /* ACTRES_UNUSED_1 */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, RS_DEFAULT_USER_ACTION_TARGET_KIND },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSPORT_DEBOARD */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSPORT_UNLOAD */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSPORT_DISEMBARK */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSPORT_BOARD */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSPORT_EMBARK */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_SPREAD_PLAGUE */
     TRUE, ACTIVITY_LAST, DRT_DIPLCHANCE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_DIPLOMATIC,    /* ACTRES_SPY_ATTACK */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_CONQUER_EXTRAS */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_EXTRAS },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_HUT_ENTER */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_ENTER },
+    EC_NONE, ERM_ENTER, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_HUT_FRIGHTEN */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_ENTER },
+    EC_NONE, ERM_ENTER, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_UNIT_MOVE */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_PARADROP_CONQUER */
     FALSE, ACTIVITY_LAST, DRT_NONE, /* TODO: Should this be hostile? */
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_HOMELESS */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_SELF },
   { ACT_TGT_COMPL_SIMPLE, ABK_STANDARD,      /* ACTRES_WIPE_UNITS */
     TRUE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNITS },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_SPY_ESCAPE */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_CITY },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TRANSPORT_LOAD */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_UNIT },
   { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE,        /* ACTRES_CLEAN */
     FALSE, ACTIVITY_CLEAN, DRT_NONE,
-    EC_NONE, ERM_CLEAN },
+    EC_NONE, ERM_CLEAN, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TELEPORT */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_TELEPORT_CONQUER */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE },
+    EC_NONE, ERM_NONE, ATK_TILE },
   { ACT_TGT_COMPL_SIMPLE, ABK_NONE,          /* ACTRES_ENABLER_CHECK */
     FALSE, ACTIVITY_LAST, DRT_NONE,
-    EC_NONE, ERM_NONE }
+    EC_NONE, ERM_NONE, ATK_SELF }
 };
 
 /*********************************************************************//**
@@ -551,6 +551,23 @@ int actres_max_range_default(enum action_result result)
   return 0;
 }
 
+
+/**********************************************************************//**
+  Return default target kind for the action with the specified result.
+**************************************************************************/
+enum action_target_kind
+actres_target_kind_default(enum action_result result)
+{
+  if (result == ACTRES_NONE) {
+    return RS_DEFAULT_USER_ACTION_TARGET_KIND;
+  }
+
+  fc_assert_ret_val(action_result_is_valid(result),
+                    RS_DEFAULT_USER_ACTION_TARGET_KIND);
+
+  return act_results[result].def_tgt_kind;
+}
+
 /**********************************************************************//**
   Does action with the result create the extra
 
diff --git a/common/actres.h b/common/actres.h
index 7d95b62212..eacc4b493a 100644
--- a/common/actres.h
+++ b/common/actres.h
@@ -117,6 +117,7 @@ struct actres {
   enum extra_cause ecause; /* Could deduct this from 'activity', but we should merge
                             * activities completely with actions in the future */
   enum extra_rmcause ermcause;
+  enum action_target_kind def_tgt_kind;
 };
 
 void actres_init(void);
@@ -146,6 +147,8 @@ enum fc_tristate actres_possible(enum action_result result,
 
 int actres_min_range_default(enum action_result result);
 int actres_max_range_default(enum action_result result);
+enum action_target_kind
+actres_target_kind_default(enum action_result result);
 
 #ifdef __cplusplus
 }
diff --git a/server/ruleset/ruleload.c b/server/ruleset/ruleload.c
index 83c3a9c4f7..01c99760d9 100644
--- a/server/ruleset/ruleload.c
+++ b/server/ruleset/ruleload.c
@@ -6364,7 +6364,7 @@ static bool load_action_kind(struct section_file *file, action_id act)
 
   action_by_number(act)->target_kind
       = secfile_lookup_enum_default(file,
-                                    action_target_kind_default(
+                                    actres_target_kind_default(
                                       paction->result),
                                     action_target_kind,
                                     "actions.%s",
-- 
2.43.0

