Author: sveinung
Date: Fri Mar 24 12:44:49 2017
New Revision: 35156

URL: http://svn.gna.org/viewcvs/freeciv?rev=35156&view=rev
Log:
Always initialize probabilities to ACTPROB_NA.

Simplify handle_unit_get_actions() by always initializing the unit_actions
packet's probabilities field to ACTPROB_NA.

See hrm Feature #647145

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=35156&r1=35155&r2=35156&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Fri Mar 24 12:44:49 2017
@@ -1457,14 +1457,14 @@
   actor_unit = game_unit_by_number(actor_unit_id);
   target_tile = index_to_tile(&(wld.map), target_tile_id);
 
+  /* Initialize the action probabilities. */
+  action_iterate(act) {
+    probabilities[act] = ACTPROB_NA;
+  } action_iterate_end;
+
   /* Check if the request is valid. */
   if (!target_tile || !actor_unit || !actor_player
       || actor_unit->owner != actor_player) {
-    action_iterate(act) {
-      /* No probability can exist when the request is invalid. */
-      probabilities[act] = ACTPROB_NA;
-    } action_iterate_end;
-
     dsend_packet_unit_actions(pc, actor_unit_id,
                               IDENTITY_NUMBER_ZERO, IDENTITY_NUMBER_ZERO,
                               target_tile_id,
@@ -1501,7 +1501,6 @@
   action_iterate(act) {
     if (action_id_get_actor_kind(act) != AAK_UNIT) {
       /* Not relevant. */
-      probabilities[act] = ACTPROB_NA;
       continue;
     }
 


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

Reply via email to