Author: sveinung Date: Thu Oct 22 11:07:20 2015 New Revision: 30159 URL: http://svn.gna.org/viewcvs/freeciv?rev=30159&view=rev Log: Explain if action blocks action
See patch #6454 Modified: trunk/server/unithand.c Modified: trunk/server/unithand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=30159&r1=30158&r2=30159&view=diff ============================================================================== --- trunk/server/unithand.c (original) +++ trunk/server/unithand.c Thu Oct 22 11:07:20 2015 @@ -100,6 +100,8 @@ ANEK_TGT_IS_UNCLAIMED, /* Explanation: the action is disabled in this scenario. */ ANEK_SCENARIO_DISABLED, + /* Explanation: the action is blocked by another action. */ + ANEK_ACTION_BLOCKS, /* Explanation not detected. */ ANEK_UNKNOWN, }; @@ -115,6 +117,9 @@ /* The player to advice declaring war on. */ struct player *no_war_with; + + /* The action that blocks the action. */ + struct action *blocker; }; }; @@ -728,6 +733,7 @@ const struct unit *target_unit) { struct player *must_war_player; + struct action *blocker; struct player *tgt_player = NULL; struct ane_expl *expl = fc_malloc(sizeof(struct ane_expl)); bool can_exist = can_unit_exist_at_tile(punit, unit_tile(punit)); @@ -846,6 +852,12 @@ /* Please add a check for any new action forbidding scenario setting * above this comment. */ expl->kind = ANEK_SCENARIO_DISABLED; + } else if (action_id_is_valid(action_id) + && (blocker = action_is_blocked_by(action_id, punit, + target_tile, target_city, + target_unit))) { + expl->kind = ANEK_ACTION_BLOCKS; + expl->blocker = blocker; } else { expl->kind = ANEK_UNKNOWN; } @@ -930,6 +942,11 @@ notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server, _("Can't perform any action this scenario permits.")); break; + case ANEK_ACTION_BLOCKS: + /* If an action blocked another action the blocking action must be + * possible. */ + fc_assert(expl->kind != ANEK_ACTION_BLOCKS); + /* Fall through to unknown cause. */ case ANEK_UNKNOWN: notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server, _("No action possible.")); @@ -1236,6 +1253,15 @@ /* TRANS: Can't do Build City in this scenario. */ _("Can't do %s in this scenario."), gen_action_translated_name(stopped_action)); + break; + case ANEK_ACTION_BLOCKS: + notify_player(pplayer, unit_tile(actor), + event, ftc_server, + /* TRANS: Freight ... Recycle Unit ... Help Wonder ... */ + _("Your %s can't do %s when %s is legal."), + unit_name_translation(actor), + gen_action_translated_name(stopped_action), + gen_action_translated_name(expl->blocker->id)); break; case ANEK_UNKNOWN: notify_player(pplayer, unit_tile(actor), _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits