From 8d25d036201118d767aca1dd701edb83fca685ce Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 30 Dec 2023 13:10:37 +0200
Subject: [PATCH 20/20] Move action_get_act_time() to actres.c under name
 actres_get_act_time()

See RM #97

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/actions.c | 47 -----------------------------------------------
 common/actions.h |  9 ++-------
 common/actres.c  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 common/actres.h  |  4 ++++
 4 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/common/actions.c b/common/actions.c
index 67ffbc8e67..c74213ef83 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -1369,53 +1369,6 @@ int action_get_role(const struct action *paction)
   return paction->id + L_LAST;
 }
 
-/**********************************************************************//**
-  Returns the unit activity time (work) this action takes (requires) or
-  ACT_TIME_INSTANTANEOUS if the action happens at once.
-
-  See update_unit_activity() and tile_activity_time()
-**************************************************************************/
-int action_get_act_time(const struct action *paction,
-                        const struct unit *actor_unit,
-                        const struct tile *tgt_tile,
-                        const struct extra_type *tgt_extra)
-{
-  enum unit_activity pactivity = actres_activity_result(paction->result);
-
-  if (pactivity == ACTIVITY_LAST) {
-    /* Happens instantaneously, not at turn change. */
-    return ACT_TIME_INSTANTANEOUS;
-  }
-
-  switch (pactivity) {
-  case ACTIVITY_PILLAGE:
-  case ACTIVITY_CLEAN:
-  case ACTIVITY_BASE:
-  case ACTIVITY_GEN_ROAD:
-  case ACTIVITY_IRRIGATE:
-  case ACTIVITY_MINE:
-  case ACTIVITY_CULTIVATE:
-  case ACTIVITY_PLANT:
-  case ACTIVITY_TRANSFORM:
-    return tile_activity_time(pactivity, tgt_tile, tgt_extra);
-  case ACTIVITY_FORTIFYING:
-    return 1;
-  case ACTIVITY_CONVERT:
-    return unit_type_get(actor_unit)->convert_time * ACTIVITY_FACTOR;
-  case ACTIVITY_EXPLORE:
-  case ACTIVITY_IDLE:
-  case ACTIVITY_FORTIFIED:
-  case ACTIVITY_SENTRY:
-  case ACTIVITY_GOTO:
-  case ACTIVITY_LAST:
-    /* Should not happen. Caught by the assertion below. */
-    break;
-  }
-
-  fc_assert(FALSE);
-  return ACT_TIME_INSTANTANEOUS;
-}
-
 /**********************************************************************//**
   Create a new action enabler.
 **************************************************************************/
diff --git a/common/actions.h b/common/actions.h
index ae7ac20e7e..14304fb990 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -683,13 +683,8 @@ bool action_requires_details(const struct action *paction);
 #define action_id_requires_details(act_id)                                \
   action_requires_details(action_by_number(act_id))
 
-int action_get_act_time(const struct action *paction,
-                        const struct unit *actor_unit,
-                        const struct tile *tgt_tile,
-                        const struct extra_type *tgt_extra)                \
-  fc__attribute((nonnull (1)));
-#define action_id_get_act_time(act_id, actor_unit, tgt_tile, tgt_extra)    \
-  action_get_act_time(action_by_number(act_id),                            \
+#define action_id_get_act_time(act_id, actor_unit, tgt_tile, tgt_extra)   \
+  actres_get_act_time(action_by_number(act_id)->result,                   \
                       actor_unit, tgt_tile, tgt_extra)
 
 bool action_id_is_rare_pop_up(action_id act_id);
diff --git a/common/actres.c b/common/actres.c
index a33f260915..442e19dfa5 100644
--- a/common/actres.c
+++ b/common/actres.c
@@ -307,6 +307,54 @@ enum unit_activity actres_activity_result(enum action_result result)
   return act_results[result].activity;
 }
 
+/**********************************************************************//**
+  Returns the unit activity time (work) this action takes (requires) or
+  ACT_TIME_INSTANTANEOUS if the action happens at once.
+
+  See update_unit_activity() and tile_activity_time()
+**************************************************************************/
+int actres_get_act_time(enum action_result result,
+                        const struct unit *actor_unit,
+                        const struct tile *tgt_tile,
+                        const struct extra_type *tgt_extra)
+{
+  enum unit_activity pactivity = actres_activity_result(result);
+
+  if (pactivity == ACTIVITY_LAST) {
+    /* Happens instantaneously, not at turn change. */
+    return ACT_TIME_INSTANTANEOUS;
+  }
+
+  switch (pactivity) {
+  case ACTIVITY_PILLAGE:
+  case ACTIVITY_CLEAN:
+  case ACTIVITY_BASE:
+  case ACTIVITY_GEN_ROAD:
+  case ACTIVITY_IRRIGATE:
+  case ACTIVITY_MINE:
+  case ACTIVITY_CULTIVATE:
+  case ACTIVITY_PLANT:
+  case ACTIVITY_TRANSFORM:
+    return tile_activity_time(pactivity, tgt_tile, tgt_extra);
+  case ACTIVITY_FORTIFYING:
+    return 1;
+  case ACTIVITY_CONVERT:
+    return unit_type_get(actor_unit)->convert_time * ACTIVITY_FACTOR;
+  case ACTIVITY_EXPLORE:
+  case ACTIVITY_IDLE:
+  case ACTIVITY_FORTIFIED:
+  case ACTIVITY_SENTRY:
+  case ACTIVITY_GOTO:
+  case ACTIVITY_LAST:
+    /* Should not happen. Caught by the assertion below. */
+    break;
+  }
+
+  fc_assert(FALSE);
+
+  return ACT_TIME_INSTANTANEOUS;
+}
+
 /**********************************************************************//**
   Map actres to initial odds type.
 
diff --git a/common/actres.h b/common/actres.h
index 7f20f6719d..f506cc9329 100644
--- a/common/actres.h
+++ b/common/actres.h
@@ -126,6 +126,10 @@ enum act_tgt_compl actres_target_compl_calc(enum action_result result);
 enum action_battle_kind actres_get_battle_kind(enum action_result result);
 bool actres_is_hostile(enum action_result result);
 enum unit_activity actres_activity_result(enum action_result result);
+int actres_get_act_time(enum action_result result,
+                        const struct unit *actor_unit,
+                        const struct tile *tgt_tile,
+                        const struct extra_type *tgt_extra);
 enum dice_roll_type actres_dice_type(enum action_result result);
 bool actres_creates_extra(enum action_result result,
                           const struct extra_type *pextra);
-- 
2.43.0

