Author: sveinung
Date: Sun Aug  9 04:37:48 2015
New Revision: 29415

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

See patch #6194

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=29415&r1=29414&r2=29415&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Aug  9 04:37:48 2015
@@ -3643,6 +3643,16 @@
           return;
         }
         break;
+      case ACTION_ESTABLISH_EMBASSY:
+        /* Don't validate that the target tile really contains a city or
+         * that the actor player's map think the target tile has one.
+         * The player may target a city from its player map that isn't
+         * there any more and a city that he think is there even if his
+         * player map doesn't have it.
+         *
+         * With that said: The client should probably at least have an
+         * option to only aim city targeted actions at cities. */
+        break;
       case ACTION_NUKE:
       case ACTION_CAPTURE_UNITS:
       case ACTION_BOMBARD:

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29415&r1=29414&r2=29415&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Sun Aug  9 04:37:48 2015
@@ -3793,7 +3793,9 @@
 bool execute_orders(struct unit *punit, const bool fresh)
 {
   struct tile *dst_tile;
+  struct city *tgt_city;
   action_probability prob;
+  int tgt_id;
   bool performed;
   const char *name;
   bool res, last_order;
@@ -4141,6 +4143,25 @@
 
       fc_assert_ret_val_msg(dst_tile, FALSE, "No target tile for action");
 
+      /* Get the target city from the target tile. */
+      tgt_city = tile_city(dst_tile);
+
+      if (tgt_city == NULL
+          && action_get_target_kind(order.action) == ATK_CITY) {
+        /* This action targets a city but no city target was found. */
+
+        cancel_orders(punit, "  perform action vs city with no city");
+        notify_player(pplayer, unit_tile(punit), E_UNIT_ORDERS, ftc_server,
+                      _("%s could not do %s. No target city."),
+                      unit_link(punit),
+                      action_get_ui_name(order.action));
+
+        return TRUE;
+      }
+
+      /* No target selected. */
+      tgt_id = -1;
+
       /* Assume impossible until told otherwise. */
       prob = 0;
 
@@ -4148,12 +4169,18 @@
       case ATK_UNITS:
         prob = action_prob_vs_units(punit, order.action,
                                     dst_tile);
+        tgt_id = dst_tile->index;
         break;
       case ATK_TILE:
         prob = action_prob_vs_tile(punit, order.action,
                                    dst_tile);
+        tgt_id = dst_tile->index;
         break;
       case ATK_CITY:
+        prob = action_prob_vs_city(punit, order.action,
+                                   tgt_city);
+        tgt_id = tgt_city->id;
+        break;
       case ATK_UNIT:
         log_error("Unsupported action target kind");
 
@@ -4195,7 +4222,7 @@
 
       performed = unit_perform_action(pplayer,
                                       unitid,
-                                      dst_tile->index,
+                                      tgt_id,
                                       0, name,
                                       order.action);
 


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

Reply via email to