Author: sveinung Date: Fri Oct 28 15:15:31 2016 New Revision: 34275 URL: http://svn.gna.org/viewcvs/freeciv?rev=34275&view=rev Log: Support other caused action performers.
Make action auto performers caused by someone else possible. See patch #7883 Modified: trunk/server/actiontools.c trunk/server/actiontools.h trunk/server/cityturn.c Modified: trunk/server/actiontools.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/actiontools.c?rev=34275&r1=34274&r2=34275&view=diff ============================================================================== --- trunk/server/actiontools.c (original) +++ trunk/server/actiontools.c Fri Oct 28 15:15:31 2016 @@ -761,10 +761,11 @@ const struct action_auto_perf * action_auto_perf_unit_sel(const enum action_auto_perf_cause cause, const struct unit *actor, + const struct player *other_player, const struct output_type *output) { action_auto_perf_by_cause_iterate(cause, autoperformer) { - if (are_reqs_active(unit_owner(actor), NULL, + if (are_reqs_active(unit_owner(actor), other_player, NULL, NULL, unit_tile(actor), actor, unit_type_get(actor), output, NULL, NULL, @@ -789,19 +790,23 @@ const struct action * action_auto_perf_unit_do(const enum action_auto_perf_cause cause, struct unit *actor, - const struct output_type *output) + const struct player *other_player, + const struct output_type *output, + const struct tile *target_tile, + const struct city *target_city, + const struct unit *target_unit) { int i; int actor_id; - struct city *tgt_city; - struct tile *tgt_tile; - struct unit *tgt_unit; - struct tile *tgt_units; + const struct city *tgt_city; + const struct tile *tgt_tile; + const struct unit *tgt_unit; + const struct tile *tgt_units; const struct action_auto_perf *autoperf - = action_auto_perf_unit_sel(cause, actor, output); + = action_auto_perf_unit_sel(cause, actor, other_player, output); if (!autoperf) { /* No matching Action Auto Performer. */ @@ -811,10 +816,15 @@ actor_id = actor->id; /* Acquire the targets. */ - tgt_city = action_tgt_city(actor, unit_tile(actor), TRUE); - tgt_tile = action_tgt_tile(actor, unit_tile(actor), TRUE); - tgt_unit = action_tgt_unit(actor, unit_tile(actor), TRUE); - tgt_units = action_tgt_tile_units(actor, unit_tile(actor), TRUE); + tgt_city = (target_city ? target_city + : action_tgt_city(actor, unit_tile(actor), TRUE)); + tgt_tile = (target_tile ? target_tile + : action_tgt_tile(actor, unit_tile(actor), TRUE)); + tgt_unit = (target_unit ? target_unit + : action_tgt_unit(actor, unit_tile(actor), TRUE)); + tgt_units = (target_tile + ? target_tile + : action_tgt_tile_units(actor, unit_tile(actor), TRUE)); for (i = 0; i < ACTION_COUNT; i++) { const enum gen_action act = autoperf->alternatives[i]; Modified: trunk/server/actiontools.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/actiontools.h?rev=34275&r1=34274&r2=34275&view=diff ============================================================================== --- trunk/server/actiontools.h (original) +++ trunk/server/actiontools.h Fri Oct 28 15:15:31 2016 @@ -59,11 +59,16 @@ const struct action_auto_perf * action_auto_perf_unit_sel(const enum action_auto_perf_cause cause, const struct unit *actor, + const struct player *other_player, const struct output_type *output); const struct action * action_auto_perf_unit_do(const enum action_auto_perf_cause cause, struct unit *actor, - const struct output_type *output); + const struct player *other_player, + const struct output_type *output, + const struct tile *target_tile, + const struct city *target_city, + const struct unit *target_unit); #endif /* FC__ACTIONTOOLS_H */ Modified: trunk/server/cityturn.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=34275&r1=34274&r2=34275&view=diff ============================================================================== --- trunk/server/cityturn.c (original) +++ trunk/server/cityturn.c Fri Oct 28 15:15:31 2016 @@ -673,7 +673,7 @@ int punit_id; if (!action_auto_perf_unit_sel(AAPC_UNIT_UPKEEP, punit, - get_output_type(outp))) { + NULL, get_output_type(outp))) { /* Can't get rid of this unit. It is undisbandable for the current * situation. */ return FALSE; @@ -682,7 +682,9 @@ punit_id = punit->id; /* Try to perform this unit's can't upkeep actions. */ - action_auto_perf_unit_do(AAPC_UNIT_UPKEEP, punit, get_output_type(outp)); + action_auto_perf_unit_do(AAPC_UNIT_UPKEEP, punit, + NULL, get_output_type(outp), + NULL, NULL, NULL); if (wipe_in_the_end && unit_is_alive(punit_id)) { /* No forced action was able to kill the unit. Finish the job. */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits