From 90455c79e4f945473022f476964b459075bd1fec Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 17 Aug 2024 02:03:44 +0300 Subject: [PATCH 17/17] Lua: Add unit_transferred signal Requested by ihnatus See osdn #44888 Signed-off-by: Marko Lindqvist --- server/scripting/script_server.c | 3 +++ server/unithand.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/server/scripting/script_server.c b/server/scripting/script_server.c index bb8d1f0207..88931c1605 100644 --- a/server/scripting/script_server.c +++ b/server/scripting/script_server.c @@ -527,6 +527,9 @@ static void script_server_signals_create(void) luascript_signal_create(fcl_main, "pulse", 0); + luascript_signal_create(fcl_main, "unit_transferred", 2, + API_TYPE_UNIT, API_TYPE_PLAYER); + luascript_signal_create(fcl_main, "action_started_unit_unit", 3, API_TYPE_ACTION, API_TYPE_UNIT, API_TYPE_UNIT); diff --git a/server/unithand.c b/server/unithand.c index 74860b7759..2168ab7c84 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -4132,6 +4132,10 @@ void unit_change_homecity_handling(struct unit *punit, struct city *new_pcity, } unit_get_goods(punit); + + if (old_owner != new_owner) { + script_server_signal_emit("unit_transferred", punit, old_owner); + } } /**********************************************************************//** -- 2.43.0