Author: sveinung Date: Mon Aug 24 14:19:16 2015 New Revision: 29666 URL: http://svn.gna.org/viewcvs/freeciv?rev=29666&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: trunk/server/unithand.c Modified: trunk/server/unithand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=29666&r1=29665&r2=29666&view=diff ============================================================================== --- trunk/server/unithand.c (original) +++ trunk/server/unithand.c Mon Aug 24 14:19:16 2015 @@ -1433,25 +1433,49 @@ 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 FALSE; \ + } \ + if (!target || !city_exist(target->id)) { \ + /* Target city was destroyed during pre action Lua. */ \ + return FALSE; \ + } #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 FALSE; \ + } \ + if (!target || !unit_alive(target->id)) { \ + /* Target unit was destroyed during pre action Lua. */ \ + return FALSE; \ + } #define ACTION_STARTED_UNIT_UNITS(action, actor, target) \ script_server_signal_emit("action_started_unit_units", 3, \ API_TYPE_ACTION, action_by_number(action), \ API_TYPE_UNIT, actor, \ - API_TYPE_TILE, target); + API_TYPE_TILE, target); \ + if (!actor || !unit_alive(actor->id)) { \ + /* Actor unit was destroyed during pre action Lua. */ \ + return FALSE; \ + } #define ACTION_STARTED_UNIT_TILE(action, actor, target) \ script_server_signal_emit("action_started_unit_tile", 3, \ API_TYPE_ACTION, action_by_number(action), \ API_TYPE_UNIT, actor, \ - API_TYPE_TILE, target); + API_TYPE_TILE, target); \ + if (!actor || !unit_alive(actor->id)) { \ + /* Actor unit was destroyed during pre action Lua. */ \ + return FALSE; \ + } switch(action_type) { case ACTION_SPY_BRIBE_UNIT: _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits