Author: sveinung
Date: Wed Dec 31 11:55:37 2014
New Revision: 27458

URL: http://svn.gna.org/viewcvs/freeciv?rev=27458&view=rev
Log:
Unhard code the move fragment cost of trying to do an illegal action.

Introduce the new effect Illegal_Action_Move_Cost. It controls the number of
move fragment lost when the player tries to do an action that is illegal.

See patch #5629

Modified:
    trunk/ai/default/daieffects.c
    trunk/common/effects.h
    trunk/data/alien/effects.ruleset
    trunk/data/civ1/effects.ruleset
    trunk/data/civ2/effects.ruleset
    trunk/data/civ2civ3/effects.ruleset
    trunk/data/classic/effects.ruleset
    trunk/data/experimental/effects.ruleset
    trunk/data/multiplayer/effects.ruleset
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/unithand.c

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/ai/default/daieffects.c       (original)
+++ trunk/ai/default/daieffects.c       Wed Dec 31 11:55:37 2014
@@ -512,6 +512,7 @@
   case EFT_HISTORY:
   case EFT_NATION_PERFORMANCE:
   case EFT_NATION_HISTORY:
+  case EFT_ILLEGAL_ACTION_MOVE_COST:
     break;
     /* This has no effect for AI */
   case EFT_VISIBLE_WALLS:

Modified: trunk/common/effects.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.h?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/common/effects.h      (original)
+++ trunk/common/effects.h      Wed Dec 31 11:55:37 2014
@@ -271,6 +271,8 @@
 #define SPECENUM_VALUE104NAME "Thiefs_Share_Pct"
 #define SPECENUM_VALUE105 EFT_RETIRE_PCT
 #define SPECENUM_VALUE105NAME "Retire_Pct"
+#define SPECENUM_VALUE106 EFT_ILLEGAL_ACTION_MOVE_COST
+#define SPECENUM_VALUE106NAME "Illegal_Action_Move_Cost"
 /* keep this last */
 #define SPECENUM_COUNT EFT_COUNT
 #include "specenum_gen.h"

Modified: trunk/data/alien/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/alien/effects.ruleset    (original)
+++ trunk/data/alien/effects.ruleset    Wed Dec 31 11:55:37 2014
@@ -1025,3 +1025,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/data/civ1/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/civ1/effects.ruleset     (original)
+++ trunk/data/civ1/effects.ruleset     Wed Dec 31 11:55:37 2014
@@ -1435,3 +1435,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/data/civ2/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/civ2/effects.ruleset     (original)
+++ trunk/data/civ2/effects.ruleset     Wed Dec 31 11:55:37 2014
@@ -2274,3 +2274,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/data/civ2civ3/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/civ2civ3/effects.ruleset (original)
+++ trunk/data/civ2civ3/effects.ruleset Wed Dec 31 11:55:37 2014
@@ -3716,3 +3716,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/data/classic/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/classic/effects.ruleset  (original)
+++ trunk/data/classic/effects.ruleset  Wed Dec 31 11:55:37 2014
@@ -2364,3 +2364,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/data/experimental/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/experimental/effects.ruleset     (original)
+++ trunk/data/experimental/effects.ruleset     Wed Dec 31 11:55:37 2014
@@ -2678,3 +2678,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/data/multiplayer/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/effects.ruleset?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/data/multiplayer/effects.ruleset      (original)
+++ trunk/data/multiplayer/effects.ruleset      Wed Dec 31 11:55:37 2014
@@ -2419,3 +2419,7 @@
     { "type", "name", "range"
       "UnitFlag", "Cities", "Local"
     }
+
+[effect_illegal_action_move_cost_base]
+type   = "Illegal_Action_Move_Cost"
+value  = 1

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Wed Dec 31 11:55:37 2014
@@ -233,6 +233,10 @@
 action that is lost before it reaches the player ordering it. Evaluated
 against the actor unit.
 
+Illegal_Action_Move_Cost
+    The number of move fragments lost when the player tries to do an action
+that turns out to be illegal.
+
 Size_Adj
     Increase maximum size of a city by amount.
 

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Wed Dec 31 11:55:37 2014
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Dec.31"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Dec.31b"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=27458&r1=27457&r2=27458&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Dec 31 11:55:37 2014
@@ -71,8 +71,10 @@
 
 #include "unithand.h"
 
-static void illegal_action(struct player *pplayer, struct unit *actor,
-                           enum gen_action stopped_action);
+static void illegal_action(struct player *pplayer,
+                           struct unit *actor,
+                           enum gen_action stopped_action,
+                           struct player *tgt_player);
 static void city_add_unit(struct player *pplayer, struct unit *punit);
 static void city_build(struct player *pplayer, struct unit *punit,
                        const char *name);
@@ -506,11 +508,24 @@
   Remember to stop using E_MY_DIPLOMAT_FAILED if non diplomat actions start
   using it.
 **************************************************************************/
-static void illegal_action(struct player *pplayer, struct unit *actor,
-                           enum gen_action stopped_action)
-{
-  /* The mistake has a cost */
-  actor->moves_left = MAX(0, actor->moves_left -1);
+static void illegal_action(struct player *pplayer,
+                           struct unit *actor,
+                           enum gen_action stopped_action,
+                           struct player *tgt_player)
+{
+  /* The mistake may have a cost. */
+  actor->moves_left = MAX(0, actor->moves_left
+      - get_target_bonus_effects(NULL,
+                                 unit_owner(actor),
+                                 tgt_player,
+                                 NULL,
+                                 NULL,
+                                 NULL,
+                                 actor,
+                                 unit_type(actor),
+                                 NULL,
+                                 NULL,
+                                 EFT_ILLEGAL_ACTION_MOVE_COST));
   send_unit_info(NULL, actor);
 
   notify_player(pplayer, unit_tile(actor),
@@ -576,7 +591,7 @@
                                         unit_bribe_cost(punit, pplayer),
                                         action_type);
       } else {
-        illegal_action(pplayer, pactor, action_type);
+        illegal_action(pplayer, pactor, action_type, unit_owner(punit));
         unit_query_impossible(pc, actor_id, target_id);
         return;
       }
@@ -591,7 +606,7 @@
                                         city_incite_cost(pplayer, pcity),
                                         action_type);
       } else {
-        illegal_action(pplayer, pactor, action_type);
+        illegal_action(pplayer, pactor, action_type, city_owner(pcity));
         unit_query_impossible(pc, actor_id, target_id);
         return;
       }
@@ -603,7 +618,7 @@
                                          pactor, pcity)) {
         spy_send_sabotage_list(pc, pactor, pcity);
       } else {
-        illegal_action(pplayer, pactor, action_type);
+        illegal_action(pplayer, pactor, action_type, city_owner(pcity));
         unit_query_impossible(pc, actor_id, target_id);
         return;
       }
@@ -664,7 +679,8 @@
 
         diplomat_bribe(pplayer, actor_unit, punit);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       unit_owner(punit));
       }
     }
     break;
@@ -676,7 +692,8 @@
 
         spy_sabotage_unit(pplayer, actor_unit, punit);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       unit_owner(punit));
       }
     }
     break;
@@ -687,7 +704,8 @@
 
         diplomat_sabotage(pplayer, actor_unit, pcity, B_LAST);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -699,7 +717,8 @@
         /* packet value is improvement ID + 1 (or some special codes) */
         diplomat_sabotage(pplayer, actor_unit, pcity, value - 1);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -711,7 +730,8 @@
 
         spy_poison(pplayer, actor_unit, pcity);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -723,7 +743,8 @@
 
         diplomat_investigate(pplayer, actor_unit, pcity);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -735,7 +756,8 @@
 
         diplomat_embassy(pplayer, actor_unit, pcity);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -747,7 +769,8 @@
 
         diplomat_incite(pplayer, actor_unit, pcity);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -766,7 +789,8 @@
         /* packet value is technology ID (or some special codes) */
         diplomat_get_tech(pplayer, actor_unit, pcity, A_UNSET);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -779,7 +803,8 @@
         /* packet value is technology ID (or some special codes) */
         diplomat_get_tech(pplayer, actor_unit, pcity, value);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -791,7 +816,8 @@
 
         spy_steal_gold(pplayer, actor_unit, pcity);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -804,7 +830,8 @@
         base_handle_unit_establish_trade(pplayer, actor_unit->id, pcity,
                                          TRUE);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -817,7 +844,8 @@
         base_handle_unit_establish_trade(pplayer, actor_unit->id, pcity,
                                          FALSE);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;
@@ -829,7 +857,8 @@
 
         handle_unit_help_build_wonder(pplayer, actor_unit->id, pcity->id);
       } else {
-        illegal_action(pplayer, actor_unit, action_type);
+        illegal_action(pplayer, actor_unit, action_type,
+                       city_owner(pcity));
       }
     }
     break;


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

Reply via email to