From 7192ccedc01ba9a5a4f2dd4e60bdccd1dad5b369 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 31 Aug 2024 14:47:00 +0300
Subject: [PATCH 26/26] Rename action_..._unit_units as action_..._unit_stack

See RM #817

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 doc/README.actions               |  2 +-
 server/scripting/script_server.c | 12 ++++++++++++
 server/unithand.c                |  6 ++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/doc/README.actions b/doc/README.actions
index f41f3d687c..e0e354d199 100644
--- a/doc/README.actions
+++ b/doc/README.actions
@@ -194,7 +194,7 @@ end
 
 signal.connect("action_started_unit_city", "action_started_callback")
 signal.connect("action_started_unit_unit", "action_started_callback")
-signal.connect("action_started_unit_units", "action_started_callback")
+signal.connect("action_started_unit_stack", "action_started_callback")
 signal.connect("action_started_unit_tile", "action_started_callback")
 signal.connect("action_started_unit_extras", "action_started_callback")
 signal.connect("action_started_unit_self", "action_started_callback")
diff --git a/server/scripting/script_server.c b/server/scripting/script_server.c
index 88931c1605..c51945ea3d 100644
--- a/server/scripting/script_server.c
+++ b/server/scripting/script_server.c
@@ -538,13 +538,25 @@ static void script_server_signals_create(void)
                           API_TYPE_ACTION, API_TYPE_BOOL,
                           API_TYPE_UNIT, API_TYPE_UNIT);
 
+  luascript_signal_create(fcl_main, "action_started_unit_stack", 3,
+                          API_TYPE_ACTION,
+                          API_TYPE_UNIT, API_TYPE_TILE);
+
+  luascript_signal_create(fcl_main, "action_finished_unit_stack", 4,
+                          API_TYPE_ACTION, API_TYPE_BOOL,
+                          API_TYPE_UNIT, API_TYPE_TILE);
+
   luascript_signal_create(fcl_main, "action_started_unit_units", 3,
                           API_TYPE_ACTION,
                           API_TYPE_UNIT, API_TYPE_TILE);
+  deprecate_signal(depr, "action_started_unit_units",
+                   "action_started_unit_stack", "3.3", NULL);
 
   luascript_signal_create(fcl_main, "action_finished_unit_units", 4,
                           API_TYPE_ACTION, API_TYPE_BOOL,
                           API_TYPE_UNIT, API_TYPE_TILE);
+  deprecate_signal(depr, "action_finished_unit_units",
+                   "action_finished_unit_stack", "3.3", NULL);
 
   luascript_signal_create(fcl_main, "action_started_unit_city", 3,
                           API_TYPE_ACTION,
diff --git a/server/unithand.c b/server/unithand.c
index a977756754..dfeb816a51 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -3561,6 +3561,8 @@ bool unit_perform_action(struct player *pplayer,
       && is_action_enabled_unit_on_stack(nmap, action_type,               \
                                          actor_unit, target_tile)) {      \
     bool success;                                                         \
+    script_server_signal_emit("action_started_unit_stack",                \
+                              action_by_number(action), actor, target);   \
     script_server_signal_emit("action_started_unit_units",                \
                               action_by_number(action), actor, target);   \
     if (!actor || !unit_is_alive(actor_id)) {                             \
@@ -3571,6 +3573,10 @@ bool unit_perform_action(struct player *pplayer,
     if (success) {                                                        \
       action_success_actor_price(paction, actor_id, actor);               \
     }                                                                     \
+    script_server_signal_emit("action_finished_unit_stack",               \
+                              action_by_number(action), success,          \
+                              unit_is_alive(actor_id) ? actor : NULL,     \
+                              target);                                    \
     script_server_signal_emit("action_finished_unit_units",               \
                               action_by_number(action), success,          \
                               unit_is_alive(actor_id) ? actor : NULL,     \
-- 
2.45.2

