Author: sveinung
Date: Fri Sep  4 13:08:55 2015
New Revision: 29768

URL: http://svn.gna.org/viewcvs/freeciv?rev=29768&view=rev
Log:
orders system: support the "Bribe Unit" action

See patch #6319

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=29768&r1=29767&r2=29768&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Fri Sep  4 13:08:55 2015
@@ -3920,6 +3920,7 @@
       case ACTION_TRADE_ROUTE:
       case ACTION_MARKETPLACE:
       case ACTION_HELP_WONDER:
+      case ACTION_SPY_BRIBE_UNIT:
       case ACTION_CAPTURE_UNITS:
       case ACTION_JOIN_CITY:
       case ACTION_STEAL_MAPS:
@@ -3933,7 +3934,6 @@
       case ACTION_SPY_TARGETED_SABOTAGE_CITY:
       case ACTION_SPY_TARGETED_STEAL_TECH:
       /* Targets a single unit. */
-      case ACTION_SPY_BRIBE_UNIT:
       case ACTION_SPY_SABOTAGE_UNIT:
       case ACTION_EXPEL_UNIT:
         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=29768&r1=29767&r2=29768&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Fri Sep  4 13:08:55 2015
@@ -58,6 +58,7 @@
 #include "script_server.h"
 
 /* server */
+#include "actiontools.h"
 #include "aiiface.h"
 #include "barbarian.h"
 #include "citytools.h"
@@ -3768,6 +3769,7 @@
 {
   struct tile *dst_tile;
   struct city *tgt_city;
+  struct unit *tgt_unit;
   action_probability prob;
   int tgt_id;
   bool performed;
@@ -4057,6 +4059,22 @@
         return TRUE;
       }
 
+      /* Get a target unit at the target tile. */
+      tgt_unit = action_tgt_unit(punit, dst_tile);
+
+      if (tgt_unit == NULL
+          && action_get_target_kind(order.action) == ATK_UNIT) {
+        /* This action targets a unit but no target unit was found. */
+
+        cancel_orders(punit, "  perform action vs unit with no unit");
+        notify_player(pplayer, unit_tile(punit), E_UNIT_ORDERS, ftc_server,
+                      _("%s could not do %s. No target unit."),
+                      unit_link(punit),
+                      action_get_ui_name(order.action));
+
+        return TRUE;
+      }
+
       /* No target selected. */
       tgt_id = -1;
 
@@ -4080,11 +4098,10 @@
         tgt_id = tgt_city->id;
         break;
       case ATK_UNIT:
-        log_error("Unsupported action target kind");
-
-        /* Makes the check below abort and cancel the orders */
-        prob = 0;
-
+        prob = action_prob_vs_unit(punit, order.action,
+                                   tgt_unit);
+
+        tgt_id = tgt_unit->id;
         break;
       case ATK_COUNT:
         log_error("Invalid action target kind");
@@ -4109,7 +4126,7 @@
 
         /* Try to explain what rule made it illegal. */
         illegal_action_msg(unit_owner(punit), E_BAD_COMMAND, punit,
-                           order.action, dst_tile, tgt_city, NULL);
+                           order.action, dst_tile, tgt_city, tgt_unit);
 
         return TRUE;
       }


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

Reply via email to