Author: sveinung
Date: Tue May 26 23:05:05 2015
New Revision: 29127

URL: http://svn.gna.org/viewcvs/freeciv?rev=29127&view=rev
Log:
Unhardcode caught stealing tech incident causing.

Introduce the new effect Casus_Belli_Caught. It regulates if getting caught
while trying to perform an action will cause an incident. Use it to
unhardcode the rule that getting caught while trying to steal a tech will
cause an incident.

See patch #6099

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/actiontools.c
    trunk/server/rscompat.c

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/ai/default/daieffects.c       (original)
+++ trunk/ai/default/daieffects.c       Tue May 26 23:05:05 2015
@@ -520,6 +520,7 @@
   case EFT_NATION_PERFORMANCE:
   case EFT_NATION_HISTORY:
   case EFT_ILLEGAL_ACTION_MOVE_COST:
+  case EFT_CASUS_BELLI_CAUGHT:
     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=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/common/effects.h      (original)
+++ trunk/common/effects.h      Tue May 26 23:05:05 2015
@@ -275,6 +275,8 @@
 #define SPECENUM_VALUE106NAME "Illegal_Action_Move_Cost"
 #define SPECENUM_VALUE107 EFT_HAVE_CONTACTS
 #define SPECENUM_VALUE107NAME "Have_Contacts"
+#define SPECENUM_VALUE108 EFT_CASUS_BELLI_CAUGHT
+#define SPECENUM_VALUE108NAME "Casus_Belli_Caught"
 /* 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=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/alien/effects.ruleset    (original)
+++ trunk/data/alien/effects.ruleset    Tue May 26 23:05:05 2015
@@ -1027,3 +1027,12 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/data/civ1/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/effects.ruleset?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/civ1/effects.ruleset     (original)
+++ trunk/data/civ1/effects.ruleset     Tue May 26 23:05:05 2015
@@ -1449,3 +1449,12 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/data/civ2/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/effects.ruleset?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/civ2/effects.ruleset     (original)
+++ trunk/data/civ2/effects.ruleset     Tue May 26 23:05:05 2015
@@ -2303,3 +2303,21 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }
+
+[effect_incident_caught_tgt_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Targeted Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/data/civ2civ3/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/effects.ruleset?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/civ2civ3/effects.ruleset (original)
+++ trunk/data/civ2civ3/effects.ruleset Tue May 26 23:05:05 2015
@@ -3753,3 +3753,21 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }
+
+[effect_incident_caught_tgt_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Targeted Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/data/classic/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/effects.ruleset?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/classic/effects.ruleset  (original)
+++ trunk/data/classic/effects.ruleset  Tue May 26 23:05:05 2015
@@ -2395,3 +2395,21 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }
+
+[effect_incident_caught_tgt_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Targeted Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/data/experimental/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/effects.ruleset?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/experimental/effects.ruleset     (original)
+++ trunk/data/experimental/effects.ruleset     Tue May 26 23:05:05 2015
@@ -2734,3 +2734,21 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }
+
+[effect_incident_caught_tgt_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Targeted Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/data/multiplayer/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/effects.ruleset?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/data/multiplayer/effects.ruleset      (original)
+++ trunk/data/multiplayer/effects.ruleset      Tue May 26 23:05:05 2015
@@ -2424,3 +2424,21 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_incident_caught_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }
+
+[effect_incident_caught_tgt_steal_tech]
+type   = "Casus_Belli_Caught"
+value  = 1
+reqs   =
+    { "type", "name", "range", "present"
+      "Action", "Targeted Steal Tech", "Local", TRUE
+      "DiplRel", "War", "Local", FALSE
+    }

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Tue May 26 23:05:05 2015
@@ -237,6 +237,11 @@
     The number of move fragments lost when the player tries to do an action
 that turns out to be illegal.
 
+Casus_Belli_Caught
+    When a player is caught trying to do an action to another player it
+causes an incident. This gives the victim a casus belli against the player
+that was caught.
+
 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=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue May 26 23:05:05 2015
@@ -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-3.0-2015.May.19"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.May.26"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/actiontools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/actiontools.c?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/server/actiontools.c  (original)
+++ trunk/server/actiontools.c  Tue May 26 23:05:05 2015
@@ -154,8 +154,86 @@
                                const struct tile *victim_tile,
                                const char *victim_link)
 {
-  maybe_cause_incident(action_id, offender,
-                       victim_player, victim_tile, victim_link);
+  if (offender == victim_player) {
+    /* The player is more than willing to forgive him self. */
+    return;
+  }
+
+  if (0 < get_target_bonus_effects(NULL,
+                                   offender, victim_player,
+                                   tile_city(victim_tile),
+                                   NULL,
+                                   victim_tile,
+                                   NULL, NULL,
+                                   NULL, NULL,
+                                   action_by_number(action_id),
+                                   EFT_CASUS_BELLI_CAUGHT)) {
+    /* Getting caught trying to do this action gives the victim a
+     * casus belli against the actor. */
+
+    /* Customize message based on action type. */
+    switch (action_get_target_kind(action_id)) {
+    case ATK_CITY:
+      notify_player(offender, victim_tile,
+                    E_DIPLOMATIC_INCIDENT, ftc_server,
+                    _("You have caused an incident getting caught"
+                      " trying to do %s to %s."),
+                    gen_action_translated_name(action_id),
+                    victim_link);
+      notify_player(victim_player, victim_tile,
+                    E_DIPLOMATIC_INCIDENT, ftc_server,
+                    _("The %s have caused an incident getting caught"
+                      " trying to do %s to %s."),
+                    nation_plural_for_player(offender),
+                    gen_action_translated_name(action_id),
+                    victim_link);
+      break;
+    case ATK_UNIT:
+    case ATK_UNITS:
+      notify_player(offender, victim_tile,
+                    E_DIPLOMATIC_INCIDENT, ftc_server,
+                    _("You have caused an incident getting caught"
+                      " trying to do %s to %s %s."),
+                    gen_action_translated_name(action_id),
+                    nation_adjective_for_player(victim_player),
+                    victim_link);
+      notify_player(victim_player, victim_tile,
+                    E_DIPLOMATIC_INCIDENT, ftc_server,
+                    _("The %s have caused an incident getting caught"
+                      " trying to do %s to your %s."),
+                    nation_plural_for_player(offender),
+                    gen_action_translated_name(action_id),
+                    victim_link);
+      break;
+    case ATK_TILE:
+      notify_player(offender, victim_tile,
+                    E_DIPLOMATIC_INCIDENT, ftc_server,
+                    _("You have caused an incident getting caught"
+                      " trying to do %s at %s."),
+                    gen_action_translated_name(action_id),
+                    victim_link);
+      notify_player(victim_player, victim_tile,
+                    E_DIPLOMATIC_INCIDENT, ftc_server,
+                    _("The %s have caused an incident getting caught"
+                      " trying to do %s at %s."),
+                    nation_plural_for_player(offender),
+                    gen_action_translated_name(action_id),
+                    victim_link);
+      break;
+    case ATK_COUNT:
+      fc_assert(ATK_COUNT != ATK_COUNT);
+      break;
+    }
+
+    /* Give the victim player a casus belli. */
+    player_diplstate_get(victim_player, offender)->has_reason_to_cancel = 2;
+
+    /* Notify players controlled by the built in AI. */
+    call_incident(INCIDENT_DIPLOMAT, offender, victim_player);
+
+    send_player_all_c(offender, NULL);
+    send_player_all_c(victim_player, NULL);
+  }
 }
 
 /**************************************************************************

Modified: trunk/server/rscompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rscompat.c?rev=29127&r1=29126&r2=29127&view=diff
==============================================================================
--- trunk/server/rscompat.c     (original)
+++ trunk/server/rscompat.c     Tue May 26 23:05:05 2015
@@ -311,6 +311,32 @@
     /* The fudge factor to more closely approximate Civ2 behavior has
      * moved to the ruleset. */
      peffect = effect_new(EFT_TRADE_REVENUE_BONUS, 1585, NULL);
+
+     /* Diplomatic incident from getting caught stealing tech has moved to
+      * the ruleset. */
+
+     /* Start with the targeted steal tech. */
+     peffect = effect_new(EFT_CASUS_BELLI_CAUGHT, 1, NULL);
+
+     /* Should only apply to the targeted steal tech action. */
+     effect_req_append(peffect, req_from_str("Action", "Local", FALSE,
+                                             TRUE, "Targeted Steal Tech"));
+
+     /* No incident if stolen during war. */
+     effect_req_append(peffect, req_from_str("DiplRel", "Local", FALSE,
+                                            FALSE, "War"));
+
+     /* Getting caught trying to do the untargeted steal tech action would
+      * also cause an incident. */
+     peffect = effect_new(EFT_CASUS_BELLI_CAUGHT, 1, NULL);
+
+     /* Should only apply to the untargeted steal tech action. */
+     effect_req_append(peffect, req_from_str("Action", "Local", FALSE,
+                                             TRUE, "Steal Tech"));
+
+     /* No incident if stolen during war. */
+     effect_req_append(peffect, req_from_str("DiplRel", "Local", FALSE,
+                                            FALSE, "War"));
   }
 
   /* Upgrade existing effects. */


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

Reply via email to