From 5b7acecb1108476601258d881cd547a7273c1e2a Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 1 Apr 2024 12:03:47 +0300
Subject: [PATCH 51/51] Rename action_..._units() as action_..._stack()

See RM #363

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/daitools.c              | 16 ++++++++--------
 client/control.c                   |  2 +-
 common/actions.c                   | 22 +++++++++++-----------
 common/actions.h                   |  6 +++---
 server/actiontools.c               |  8 ++++----
 server/advisors/autoworkers.c      |  2 +-
 server/scripting/api_server_edit.c |  4 ++--
 server/unithand.c                  |  4 ++--
 server/unittools.c                 |  4 ++--
 9 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/ai/default/daitools.c b/ai/default/daitools.c
index 48c0dade56..c9cf65604b 100644
--- a/ai/default/daitools.c
+++ b/ai/default/daitools.c
@@ -829,32 +829,32 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
   /* 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. */
-  if (is_action_enabled_unit_on_units(nmap, ACTION_CAPTURE_UNITS,
+  if (is_action_enabled_unit_on_stack(nmap, ACTION_CAPTURE_UNITS,
                                       punit, ptile)) {
     /* Choose capture. */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_CAPTURE_UNITS);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_BOMBARD_LETHAL,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_BOMBARD_LETHAL,
                                              punit, ptile)) {
     /* Choose "Bombard Lethal". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_BOMBARD_LETHAL);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_BOMBARD,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_BOMBARD,
                                              punit, ptile)) {
     /* Choose "Bombard". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_BOMBARD);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_BOMBARD2,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_BOMBARD2,
                                              punit, ptile)) {
     /* Choose "Bombard 2". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_BOMBARD2);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_BOMBARD3,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_BOMBARD3,
                                              punit, ptile)) {
     /* Choose "Bombard 3". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_BOMBARD3);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_NUKE_UNITS,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_NUKE_UNITS,
                                              punit, ptile)) {
     /* Choose "Nuke Units". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
@@ -885,12 +885,12 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
     /* Choose "Nuke City". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
                    0, "", ACTION_NUKE_CITY);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_ATTACK,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_ATTACK,
                                              punit, ptile)) {
     /* Choose regular attack. */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_ATTACK);
-  } else if (is_action_enabled_unit_on_units(nmap, ACTION_SUICIDE_ATTACK,
+  } else if (is_action_enabled_unit_on_stack(nmap, ACTION_SUICIDE_ATTACK,
                                              punit, ptile)) {
     /* Choose suicide attack (explode missile). */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
diff --git a/client/control.c b/client/control.c
index 161c79f9d7..170f02a2fd 100644
--- a/client/control.c
+++ b/client/control.c
@@ -1994,7 +1994,7 @@ static void do_disband_alternative(void *p)
     break;
   case ATK_UNITS:
     if ((ptile = unit_tile(punit))
-        && action_prob_possible(action_prob_vs_units(punit, act, ptile))) {
+        && action_prob_possible(action_prob_vs_stack(punit, act, ptile))) {
       request_do_action(act, punit->id, ptile->index, 0, "");
     }
     break;
diff --git a/common/actions.c b/common/actions.c
index e218e74a5b..e3e74c73ec 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -2287,7 +2287,7 @@ struct action *action_is_blocked_by(const struct action *act,
         /* Can't be enabled. No target. */
         continue;
       }
-      if (is_action_enabled_unit_on_units(nmap, blocker->id,
+      if (is_action_enabled_unit_on_stack(nmap, blocker->id,
                                           actor_unit, target_tile)) {
         return blocker;
       }
@@ -3136,7 +3136,7 @@ bool is_action_enabled_unit_on_unit(const struct civ_map *nmap,
   See note in is_action_enabled() for why the action may still be disabled.
 **************************************************************************/
 static bool
-is_action_enabled_unit_on_units_full(const struct civ_map *nmap,
+is_action_enabled_unit_on_stack_full(const struct civ_map *nmap,
                                      const action_id wanted_action,
                                      const struct unit *actor_unit,
                                      const struct city *actor_home,
@@ -3206,12 +3206,12 @@ is_action_enabled_unit_on_units_full(const struct civ_map *nmap,
 
   See note in is_action_enabled() for why the action may still be disabled.
 **************************************************************************/
-bool is_action_enabled_unit_on_units(const struct civ_map *nmap,
+bool is_action_enabled_unit_on_stack(const struct civ_map *nmap,
                                      const action_id wanted_action,
                                      const struct unit *actor_unit,
                                      const struct tile *target_tile)
 {
-  return is_action_enabled_unit_on_units_full(nmap, wanted_action, actor_unit,
+  return is_action_enabled_unit_on_stack_full(nmap, wanted_action, actor_unit,
                                               unit_home(actor_unit),
                                               unit_tile(actor_unit),
                                               target_tile);
@@ -4292,7 +4292,7 @@ struct act_prob action_prob_vs_unit(const struct unit *actor_unit,
   action on all units at the target tile.
 **************************************************************************/
 static struct act_prob
-action_prob_vs_units_full(const struct civ_map *nmap,
+action_prob_vs_stack_full(const struct civ_map *nmap,
                           const struct unit *actor_unit,
                           const struct city *actor_home,
                           const struct tile *actor_tile,
@@ -4467,13 +4467,13 @@ action_prob_vs_units_full(const struct civ_map *nmap,
   Get the actor unit's probability of successfully performing the chosen
   action on all units at the target tile.
 **************************************************************************/
-struct act_prob action_prob_vs_units(const struct unit *actor_unit,
+struct act_prob action_prob_vs_stack(const struct unit *actor_unit,
                                      const action_id act_id,
                                      const struct tile *target_tile)
 {
   const struct civ_map *nmap = &(wld.map);
 
-  return action_prob_vs_units_full(nmap, actor_unit,
+  return action_prob_vs_stack_full(nmap, actor_unit,
                                    unit_home(actor_unit),
                                    unit_tile(actor_unit),
                                    act_id,
@@ -4744,7 +4744,7 @@ struct act_prob action_prob_unit_vs_tgt(const struct action *paction,
   switch (action_get_target_kind(paction)) {
   case ATK_UNITS:
     if (tgt_tile) {
-      prob = action_prob_vs_units(act_unit, paction->id, tgt_tile);
+      prob = action_prob_vs_stack(act_unit, paction->id, tgt_tile);
     }
     break;
   case ATK_TILE:
@@ -4852,7 +4852,7 @@ action_speculate_unit_on_unit(action_id act_id,
   game state changes.
 **************************************************************************/
 struct act_prob
-action_speculate_unit_on_units(action_id act_id,
+action_speculate_unit_on_stack(action_id act_id,
                                const struct unit *actor,
                                const struct city *actor_home,
                                const struct tile *actor_tile,
@@ -4866,7 +4866,7 @@ action_speculate_unit_on_units(action_id act_id,
   const struct civ_map *nmap = &(wld.map);
 
   if (omniscient_cheat) {
-    if (is_action_enabled_unit_on_units_full(nmap, act_id,
+    if (is_action_enabled_unit_on_stack_full(nmap, act_id,
                                              actor, actor_home, actor_tile,
                                              target)) {
       return ACTPROB_CERTAIN;
@@ -4874,7 +4874,7 @@ action_speculate_unit_on_units(action_id act_id,
       return ACTPROB_IMPOSSIBLE;
     }
   } else {
-    return action_prob_vs_units_full(nmap, actor, actor_home, actor_tile,
+    return action_prob_vs_stack_full(nmap, actor, actor_home, actor_tile,
                                      act_id, target);
   }
 }
diff --git a/common/actions.h b/common/actions.h
index 285aa49876..e88c6f3559 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -530,7 +530,7 @@ bool is_action_enabled_unit_on_unit(const struct civ_map *nmap,
                                     const struct unit *actor_unit,
                                     const struct unit *target_unit);
 
-bool is_action_enabled_unit_on_units(const struct civ_map *nmap,
+bool is_action_enabled_unit_on_stack(const struct civ_map *nmap,
                                      const action_id wanted_action,
                                      const struct unit *actor_unit,
                                      const struct tile *target_tile);
@@ -557,7 +557,7 @@ struct act_prob action_prob_vs_unit(const struct unit* actor,
                                     const action_id act_id,
                                     const struct unit* victim);
 
-struct act_prob action_prob_vs_units(const struct unit* actor,
+struct act_prob action_prob_vs_stack(const struct unit* actor,
                                      const action_id act_id,
                                      const struct tile* victims);
 
@@ -598,7 +598,7 @@ action_speculate_unit_on_unit(action_id act_id,
                               const struct unit *target);
 
 struct act_prob
-action_speculate_unit_on_units(action_id act_id,
+action_speculate_unit_on_stack(action_id act_id,
                                const struct unit *actor,
                                const struct city *actor_home,
                                const struct tile *actor_tile,
diff --git a/server/actiontools.c b/server/actiontools.c
index f5280d0a20..06ef954380 100644
--- a/server/actiontools.c
+++ b/server/actiontools.c
@@ -757,7 +757,7 @@ struct tile *action_tgt_tile(struct unit *actor,
       prob = action_prob_vs_extras(actor, act, target, target_extra);
       break;
     case ATK_UNITS:
-      prob = action_prob_vs_units(actor, act, target);
+      prob = action_prob_vs_stack(actor, act, target);
       break;
     case ATK_CITY:
     case ATK_UNIT:
@@ -1033,7 +1033,7 @@ action_auto_perf_unit_do(const enum action_auto_perf_cause cause,
       switch (action_id_get_target_kind(act)) {
       case ATK_UNITS:
         if (tgt_tile
-            && is_action_enabled_unit_on_units(nmap, act, actor, tgt_tile)) {
+            && is_action_enabled_unit_on_stack(nmap, act, actor, tgt_tile)) {
           perform_action_to(act, actor, tgt_tile->index, EXTRA_NONE);
         }
         break;
@@ -1130,8 +1130,8 @@ action_auto_perf_unit_prob(const enum action_auto_perf_cause cause,
       switch (action_id_get_target_kind(act)) {
       case ATK_UNITS:
         if (tgt_tile
-            && is_action_enabled_unit_on_units(nmap, act, actor, tgt_tile)) {
-          current = action_prob_vs_units(actor, act, tgt_tile);
+            && is_action_enabled_unit_on_stack(nmap, act, actor, tgt_tile)) {
+          current = action_prob_vs_stack(actor, act, tgt_tile);
         }
         break;
       case ATK_TILE:
diff --git a/server/advisors/autoworkers.c b/server/advisors/autoworkers.c
index 372184bdd7..dd6bb504a4 100644
--- a/server/advisors/autoworkers.c
+++ b/server/advisors/autoworkers.c
@@ -1314,7 +1314,7 @@ bool auto_workers_speculate_can_act_at(const struct unit *punit,
                         FALSE);
       break;
     case ATK_UNITS:
-      return action_prob_possible(action_speculate_unit_on_units(
+      return action_prob_possible(action_speculate_unit_on_stack(
                                     paction->id,
                                     punit, unit_home(punit), ptile,
                                     omniscient_cheat,
diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c
index 9e2195e2e5..00efe26516 100644
--- a/server/scripting/api_server_edit.c
+++ b/server/scripting/api_server_edit.c
@@ -376,7 +376,7 @@ bool api_edit_perform_action_unit_vs_tile(lua_State *L, Unit *punit,
   fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
   switch (action_get_target_kind(paction)) {
   case ATK_UNITS:
-    enabled = is_action_enabled_unit_on_units(nmap, paction->id, punit, tgt);
+    enabled = is_action_enabled_unit_on_stack(nmap, paction->id, punit, tgt);
     break;
   case ATK_TILE:
     enabled = is_action_enabled_unit_on_tile(nmap, paction->id, punit,
@@ -438,7 +438,7 @@ bool api_edit_perform_action_unit_vs_tile_extra(lua_State *L, Unit *punit,
   fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
   switch (action_get_target_kind(paction)) {
   case ATK_UNITS:
-    enabled = is_action_enabled_unit_on_units(nmap, paction->id, punit, tgt);
+    enabled = is_action_enabled_unit_on_stack(nmap, paction->id, punit, tgt);
     break;
   case ATK_TILE:
     enabled = is_action_enabled_unit_on_tile(nmap, paction->id, punit,
diff --git a/server/unithand.c b/server/unithand.c
index d35cd62a06..e53bfb20a2 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -2381,7 +2381,7 @@ void handle_unit_get_actions(struct connection *pc,
     case ATK_UNITS:
       if (target_tile) {
         /* Calculate the probabilities. */
-        probabilities[act] = action_prob_vs_units(actor_unit, act,
+        probabilities[act] = action_prob_vs_stack(actor_unit, act,
                                                   target_tile);
       } else {
         /* No target to act against. */
@@ -3548,7 +3548,7 @@ bool unit_perform_action(struct player *pplayer,
 
 #define ACTION_PERFORM_UNIT_UNITS(action, actor, target, action_performer)\
   if (target_tile                                                         \
-      && is_action_enabled_unit_on_units(nmap, action_type,               \
+      && is_action_enabled_unit_on_stack(nmap, action_type,               \
                                          actor_unit, target_tile)) {      \
     bool success;                                                         \
     script_server_signal_emit("action_started_unit_units",                \
diff --git a/server/unittools.c b/server/unittools.c
index f23807c552..315934aed1 100644
--- a/server/unittools.c
+++ b/server/unittools.c
@@ -4798,7 +4798,7 @@ bool execute_orders(struct unit *punit, const bool fresh)
 
       switch (action_id_get_target_kind(order.action)) {
       case ATK_UNITS:
-        prob = action_prob_vs_units(punit, order.action,
+        prob = action_prob_vs_stack(punit, order.action,
                                     dst_tile);
         tgt_id = dst_tile->index;
         break;
@@ -5113,7 +5113,7 @@ void random_movements(struct player *pplayer)
           struct tile *dest = mapstep(&(wld.map), curtile, dirs[choice]);
 
           if (dest != NULL) {
-            if (action_prob_possible(action_prob_vs_units(punit, ACTION_ATTACK,
+            if (action_prob_possible(action_prob_vs_stack(punit, ACTION_ATTACK,
                                                           dest))) {
               if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET,
                                       "", ACTION_ATTACK, ACT_REQ_RULES)) {
-- 
2.43.0

