Author: sveinung
Date: Fri Nov  4 13:10:03 2016
New Revision: 34383

URL: http://svn.gna.org/viewcvs/freeciv?rev=34383&view=rev
Log:
actiontools: act perf acquire target to macro.

The acquire target code for action_auto_perf_unit_sel() and
action_auto_perf_unit_prob() is and should be identical. Move it to the new
macro action_auto_perf_acquire_targets.

See patch #7926

Modified:
    trunk/server/actiontools.c

Modified: trunk/server/actiontools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/actiontools.c?rev=34383&r1=34382&r2=34383&view=diff
==============================================================================
--- trunk/server/actiontools.c  (original)
+++ trunk/server/actiontools.c  Fri Nov  4 13:10:03 2016
@@ -779,6 +779,20 @@
   return NULL;
 }
 
+#define action_auto_perf_acquire_targets                                   \
+  tgt_city = (target_city ? target_city                                    \
+                          : action_tgt_city(actor, unit_tile(actor),       \
+                                            TRUE));                        \
+  tgt_tile = (target_tile ? target_tile                                    \
+                          : action_tgt_tile(actor, unit_tile(actor),       \
+                                            TRUE));                        \
+  tgt_unit = (target_unit ? target_unit                                    \
+                          : action_tgt_unit(actor, unit_tile(actor),       \
+                                            TRUE));                        \
+  tgt_units = (target_tile                                                 \
+               ? target_tile                                               \
+               : action_tgt_tile_units(actor, unit_tile(actor), TRUE));
+
 /**************************************************************************
   Make the specified actor unit perform an action because of cause.
 
@@ -814,15 +828,7 @@
   actor_id = actor->id;
 
   /* Acquire the targets. */
-  tgt_city = (target_city ? target_city
-                          : action_tgt_city(actor, unit_tile(actor), TRUE));
-  tgt_tile = (target_tile ? target_tile
-                          : action_tgt_tile(actor, unit_tile(actor), TRUE));
-  tgt_unit = (target_unit ? target_unit
-                          : action_tgt_unit(actor, unit_tile(actor), TRUE));
-  tgt_units = (target_tile
-               ? target_tile
-               : action_tgt_tile_units(actor, unit_tile(actor), TRUE));
+  action_auto_perf_acquire_targets;
 
   action_auto_perf_actions_iterate(autoperf, act) {
     if (action_id_get_actor_kind(act) == AAK_UNIT) {
@@ -911,15 +917,7 @@
   out = ACTPROB_IMPOSSIBLE;
 
   /* Acquire the targets. */
-  tgt_city = (target_city ? target_city
-                          : action_tgt_city(actor, unit_tile(actor), TRUE));
-  tgt_tile = (target_tile ? target_tile
-                          : action_tgt_tile(actor, unit_tile(actor), TRUE));
-  tgt_unit = (target_unit ? target_unit
-                          : action_tgt_unit(actor, unit_tile(actor), TRUE));
-  tgt_units = (target_tile
-               ? target_tile
-               : action_tgt_tile_units(actor, unit_tile(actor), TRUE));
+  action_auto_perf_acquire_targets;
 
   action_auto_perf_actions_iterate(autoperf, act) {
     struct act_prob current = ACTPROB_IMPOSSIBLE;


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

Reply via email to