Author: cazfi
Date: Sun Jan 17 22:29:37 2016
New Revision: 31477

URL: http://svn.gna.org/viewcvs/freeciv?rev=31477&view=rev
Log:
Made adding an unit to a city to emit "city_size_change" signal to lua scripts.

See bug #24308

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31477&r1=31476&r2=31477&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Jan 17 22:29:37 2016
@@ -2192,16 +2192,23 @@
 static bool city_add_unit(struct player *pplayer, struct unit *punit,
                           struct city *pcity)
 {
+  int amount = unit_pop_value(punit);
+
   /* Sanity check: The actor is still alive. */
   fc_assert_ret_val(punit, FALSE);
 
   /* Sanity check: The target city still exists. */
   fc_assert_ret_val(pcity, FALSE);
 
-  fc_assert_ret_val(unit_pop_value(punit) > 0, FALSE);
-  city_size_add(pcity, unit_pop_value(punit));
+  fc_assert_ret_val(amount > 0, FALSE);
+
+  script_server_signal_emit("city_size_change", 3,
+                            API_TYPE_CITY, pcity,
+                            API_TYPE_INT, amount,
+                            API_TYPE_STRING, "unit_added");
+  city_size_add(pcity, amount);
   /* Make the new people something, otherwise city fails the checks */
-  pcity->specialists[DEFAULT_SPECIALIST] += unit_pop_value(punit);
+  pcity->specialists[DEFAULT_SPECIALIST] += amount;
   citizens_update(pcity, unit_nationality(punit));
   /* Refresh the city data. */
   city_refresh(pcity);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to