Author: sveinung
Date: Thu May 11 08:26:31 2017
New Revision: 35503

URL: http://svn.gna.org/viewcvs/freeciv?rev=35503&view=rev
Log:
Missile consumption: use action shared system.

Have the attack action use the shared action system when consuming units
with the Missile unit class flag.

This replaces the custom auto help for the Missile unit class flag.

See hrm Feature #657680

Modified:
    branches/S3_0/client/helpdata.c
    branches/S3_0/common/unittype.c
    branches/S3_0/server/actiontools.c
    branches/S3_0/server/unithand.c

Modified: branches/S3_0/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/helpdata.c?rev=35503&r1=35502&r2=35503&view=diff
==============================================================================
--- branches/S3_0/client/helpdata.c     (original)
+++ branches/S3_0/client/helpdata.c     Thu May 11 08:26:31 2017
@@ -1578,9 +1578,6 @@
   if (uclass_has_flag(pclass, UCF_DAMAGE_SLOWS)) {
     CATLSTR(buf, bufsz, _("  * Slowed down while damaged.\n"));
   }
-  if (uclass_has_flag(pclass, UCF_MISSILE)) {
-    CATLSTR(buf, bufsz, _("  * Gets used up in making an attack.\n"));
-  }
   if (uclass_has_flag(pclass, UCF_CAN_FORTIFY)
       && !utype_has_flag(utype, UTYF_CANT_FORTIFY)) {
     if (utype->defense_strength > 0) {
@@ -2080,7 +2077,7 @@
             _("* Won't lose all movement when moving from non-native "
               "terrain to native terrain.\n"));
   }
-  if (!uclass_has_flag(utype_class(utype), UCF_MISSILE)
+  if (!utype_is_consumed_by_action(action_by_number(ACTION_ATTACK), utype)
       && utype_has_flag(utype, UTYF_ONEATTACK)) {
     CATLSTR(buf, bufsz,
            _("* Making an attack ends this unit's turn.\n"));
@@ -2472,7 +2469,8 @@
     /* Some units can never become veteran through combat in practice. */
     bool veteran_through_combat =
       !((!utype_can_do_action(utype, ACTION_ATTACK)
-         || uclass_has_flag(utype_class(utype), UCF_MISSILE))
+         || utype_is_consumed_by_action(action_by_number(ACTION_ATTACK),
+                                        utype))
         && utype->defense_strength == 0);
 #endif
     /* FIXME: if we knew the raise chances on the client, we could be

Modified: branches/S3_0/common/unittype.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/unittype.c?rev=35503&r1=35502&r2=35503&view=diff
==============================================================================
--- branches/S3_0/common/unittype.c     (original)
+++ branches/S3_0/common/unittype.c     Thu May 11 08:26:31 2017
@@ -871,6 +871,8 @@
   case ACTION_SPY_NUKE:
     /* A Spy has a chance to escape after performing the action. */
     return !utype_has_flag(utype, UTYF_SPY);
+  case ACTION_ATTACK:
+    return uclass_has_flag(utype->uclass, UCF_MISSILE);
   default:
     return FALSE;
   }

Modified: branches/S3_0/server/actiontools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/actiontools.c?rev=35503&r1=35502&r2=35503&view=diff
==============================================================================
--- branches/S3_0/server/actiontools.c  (original)
+++ branches/S3_0/server/actiontools.c  Thu May 11 08:26:31 2017
@@ -47,6 +47,8 @@
       wipe_unit(actor, ULR_DISBANDED, NULL);
     } else if (action_has_result(paction, ACTION_NUKE)) {
       wipe_unit(actor, ULR_DETONATED, NULL);
+    } else if (action_has_result(paction, ACTION_ATTACK)) {
+      wipe_unit(actor, ULR_MISSILE, NULL);
     } else {
       wipe_unit(actor, ULR_USED, NULL);
     }

Modified: branches/S3_0/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/unithand.c?rev=35503&r1=35502&r2=35503&view=diff
==============================================================================
--- branches/S3_0/server/unithand.c     (original)
+++ branches/S3_0/server/unithand.c     Thu May 11 08:26:31 2017
@@ -133,7 +133,8 @@
 static bool do_unit_upgrade(struct player *pplayer,
                             struct unit *punit, struct city *pcity,
                             enum action_requester ordered_by);
-static bool do_attack(struct unit *actor_unit, struct tile *target_tile);
+static bool do_attack(struct unit *actor_unit, struct tile *target_tile,
+                      const struct action *paction);
 static bool do_unit_conquer_city(struct player *act_player,
                                  struct unit *act_unit,
                                  struct city *tgt_city,
@@ -2503,7 +2504,7 @@
     break;
   case ACTION_ATTACK:
     ACTION_STARTED_UNIT_TILE(action_type, actor_unit, target_tile,
-                             do_attack(actor_unit, target_tile));
+                             do_attack(actor_unit, target_tile, paction));
     break;
   case ACTION_COUNT:
     log_error("handle_unit_do_action() %s (%d) ordered to perform an "
@@ -3290,7 +3291,8 @@
   Returns TRUE iff action could be done, FALSE if it couldn't. Even if
   this returns TRUE, unit may have died during the action.
 **************************************************************************/
-static bool do_attack(struct unit *punit, struct tile *def_tile)
+static bool do_attack(struct unit *punit, struct tile *def_tile,
+                      const struct action *paction)
 {
   char loser_link[MAX_LEN_LINK], winner_link[MAX_LEN_LINK];
   struct unit *ploser, *pwinner;
@@ -3341,7 +3343,7 @@
   old_defender_vet = pdefender->veteran;
   unit_versus_unit(punit, pdefender, &att_hp, &def_hp);
 
-  if ((att_hp <= 0 || uclass_has_flag(unit_class_get(punit), UCF_MISSILE))
+  if ((att_hp <= 0 || utype_is_consumed_by_action(paction, punit->utype))
       && unit_transported(punit)) {
     /* Dying attacker must be first unloaded so it doesn't die insider 
transport */
     unit_transport_unload_send(punit);
@@ -3397,7 +3399,8 @@
 
   /* N.B.: unit_link always returns the same pointer. */
   sz_strlcpy(loser_link, unit_tile_link(ploser));
-  sz_strlcpy(winner_link, uclass_has_flag(unit_class_get(pwinner), UCF_MISSILE)
+  sz_strlcpy(winner_link,
+             utype_is_consumed_by_action(paction, pwinner->utype)
              ? unit_tile_link(pwinner) : unit_link(pwinner));
 
   if (punit == ploser) {
@@ -3437,10 +3440,9 @@
 
     punit->moved = TRUE;       /* We moved */
     kill_unit(pwinner, ploser,
-              vet && !uclass_has_flag(unit_class_get(punit), UCF_MISSILE));
+              vet && !utype_is_consumed_by_action(paction, punit->utype));
     if (unit_is_alive(winner_id)) {
-      if (uclass_has_flag(unit_class_get(pwinner), UCF_MISSILE)) {
-        wipe_unit(pwinner, ULR_MISSILE, NULL);
+      if (utype_is_consumed_by_action(paction, pwinner->utype)) {
         return TRUE;
       }
     } else {


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

Reply via email to