Author: sveinung
Date: Mon Aug 24 14:58:56 2015
New Revision: 29667

URL: http://svn.gna.org/viewcvs/freeciv?rev=29667&view=rev
Log:
Check that action actor and target survived Lua

Add checks that the actor unit and, where applicable, its target survived
to the macros emitting the action_started_unit_* Lua signals.

See patch #6275

Modified:
    branches/S2_6/server/unithand.c

Modified: branches/S2_6/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=29667&r1=29666&r2=29667&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Mon Aug 24 14:58:56 2015
@@ -1061,13 +1061,29 @@
   script_server_signal_emit("action_started_unit_city", 3,                \
                             API_TYPE_ACTION, action_by_number(action),    \
                             API_TYPE_UNIT, actor,                         \
-                            API_TYPE_CITY, target);
+                            API_TYPE_CITY, target);                       \
+  if (!actor || !unit_alive(actor->id)) {                                 \
+    /* Actor unit was destroyed during pre action Lua. */                 \
+    return;                                                         \
+  }                                                                       \
+  if (!target || !city_exist(target->id)) {                               \
+    /* Target city was destroyed during pre action Lua. */                \
+    return;                                                         \
+  }
 
 #define ACTION_STARTED_UNIT_UNIT(action, actor, target)                   \
   script_server_signal_emit("action_started_unit_unit", 3,                \
                             API_TYPE_ACTION, action_by_number(action),    \
                             API_TYPE_UNIT, actor,                         \
-                            API_TYPE_UNIT, target);
+                            API_TYPE_UNIT, target);                       \
+  if (!actor || !unit_alive(actor->id)) {                                 \
+    /* Actor unit was destroyed during pre action Lua. */                 \
+    return;                                                         \
+  }                                                                       \
+  if (!target || !unit_alive(target->id)) {                               \
+    /* Target unit was destroyed during pre action Lua. */                \
+    return;                                                         \
+  }
 
   switch(action_type) {
   case ACTION_SPY_BRIBE_UNIT:


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

Reply via email to