Author: sveinung
Date: Tue Aug  4 13:28:05 2015
New Revision: 29323

URL: http://svn.gna.org/viewcvs/freeciv?rev=29323&view=rev
Log:
orders system: support the Bombard action

See patch #6165

Modified:
    trunk/server/unithand.c
    trunk/server/unittools.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=29323&r1=29322&r2=29323&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Tue Aug  4 13:28:05 2015
@@ -3535,6 +3535,7 @@
     case ORDER_PERFORM_ACTION:
       switch ((enum gen_action) packet->action[i]) {
       case ACTION_NUKE:
+      case ACTION_BOMBARD:
         break;
       default:
         log_error("handle_unit_orders() the action %s isn't allowed in "

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29323&r1=29322&r2=29323&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Tue Aug  4 13:28:05 2015
@@ -3790,6 +3790,7 @@
 bool execute_orders(struct unit *punit, const bool fresh)
 {
   struct tile *dst_tile;
+  action_probability prob;
   bool res, last_order;
   int unitid = punit->id;
   struct player *pplayer = unit_owner(punit);
@@ -4125,10 +4126,6 @@
     case ORDER_PERFORM_ACTION:
       log_debug("  orders: doing action %d", order.action);
 
-      fc_assert_msg(
-            action_get_target_kind(order.action) == ATK_TILE,
-            "Only tile targets are currently supported");
-
       if (!is_valid_dir(order.dir)) {
         /* The target of the action is on the actor's tile. */
         dst_tile = unit_tile(punit);
@@ -4139,8 +4136,28 @@
 
       fc_assert_ret_val_msg(dst_tile, FALSE, "No target tile for action");
 
-      if (!action_prob_possible(action_prob_vs_tile(punit, order.action,
-                                                    dst_tile))) {
+      /* Assume impossible until told otherwise. */
+      prob = 0;
+
+      switch (action_get_target_kind(order.action)) {
+      case ATK_UNITS:
+        prob = action_prob_vs_units(punit, order.action,
+                                    dst_tile);
+        break;
+      case ATK_TILE:
+        prob = action_prob_vs_tile(punit, order.action,
+                                   dst_tile);
+        break;
+      case ATK_CITY:
+      case ATK_UNIT:
+        log_error("Unsupported action target kind");
+        return TRUE;
+      case ATK_COUNT:
+        log_error("Invalid action target kind");
+        return TRUE;
+      }
+
+      if (!action_prob_possible(prob)) {
         /* The player has enough information to know that this action is
          * against the rules. Don't risk any punishment by trying to
          * perform it. */


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

Reply via email to