Author: sveinung Date: Fri Nov 6 13:33:57 2015 New Revision: 30437 URL: http://svn.gna.org/viewcvs/freeciv?rev=30437&view=rev Log: Stop assuming the unit survived a failed disband
Traditional disband orders the ways it tries to disband a unit so it matches the pre 3.0 disband unit command. Stop assuming that a failed disband action means that the unit survived. It may have failed because the unit was killed in Lua before the action started. See bug #24026 Modified: trunk/server/unittools.c Modified: trunk/server/unittools.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=30437&r1=30436&r2=30437&view=diff ============================================================================== --- trunk/server/unittools.c (original) +++ trunk/server/unittools.c Fri Nov 6 13:33:57 2015 @@ -3761,6 +3761,8 @@ **************************************************************************/ void unit_do_disband_trad(struct player *owner, struct unit *punit) { + const int punit_id_stored = punit->id; + fc_assert_ret(owner == unit_owner(punit)); /* Help Wonder gives 100% of the shields used to produce the unit to the @@ -3782,6 +3784,11 @@ } } + if (!unit_alive(punit_id_stored)) { + /* The unit is gone. Maybe it was killed in Lua? */ + return; + } + /* Disbanding a unit inside a city gives it 50% of the shields used to * produce the unit. */ if (unit_can_do_action(punit, ACTION_RECYCLE_UNIT)) { @@ -3799,6 +3806,11 @@ return; } } + } + + if (!unit_alive(punit_id_stored)) { + /* The unit is gone. Maybe it was killed in Lua? */ + return; } /* All shields will be wasted. */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits