Author: cazfi
Date: Fri Dec  2 14:17:00 2016
New Revision: 34681

URL: http://svn.gna.org/viewcvs/freeciv?rev=34681&view=rev
Log:
When occypychance is above zero, and related move follows attack,
movement cost of the combined action is bigger of the costs of attack and 
movement,
no longer sum of them.

Requested by David Fernandez <bardo>

See bug #20945

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=34681&r1=34680&r2=34681&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Fri Dec  2 14:17:00 2016
@@ -3292,7 +3292,7 @@
    */
   punit->moves_left = unit_move_rate(punit) - moves_used - SINGLE_MOVE;
   pdefender->moves_left = unit_move_rate(pdefender) - def_moves_used;
-  
+
   if (punit->moves_left < 0) {
     punit->moves_left = 0;
   }
@@ -3381,8 +3381,8 @@
    * multiple defenders and unstacked combat). Note that this could mean 
    * capturing (or destroying) a city. */
 
-  if (pwinner == punit && fc_rand(100) < game.server.occupychance &&
-      !is_non_allied_unit_tile(def_tile, pplayer)) {
+  if (pwinner == punit && fc_rand(100) < game.server.occupychance
+      && !is_non_allied_unit_tile(def_tile, pplayer)) {
 
     /* Hack: make sure the unit has enough moves_left for the move to succeed,
        and adjust moves_left to afterward (if successful). */
@@ -3398,7 +3398,11 @@
          && unit_perform_action(unit_owner(punit), punit->id, pcity->id,
                                 0, "", ACTION_CONQUER_CITY, ACT_REQ_RULES))
         || (unit_move_handling(punit, def_tile, FALSE, TRUE, NULL))) {
-      punit->moves_left = old_moves - (full_moves - punit->moves_left);
+      int mcost = MAX(0, full_moves - punit->moves_left - SINGLE_MOVE);
+
+      /* Move cost is bigger of attack (SINGLE_MOVE) and occupying move costs.
+       * Attack SINGLE_COST is already calculated in to old_moves. */
+      punit->moves_left = old_moves - mcost;
       if (punit->moves_left < 0) {
         punit->moves_left = 0;
       }


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

Reply via email to