Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13716) No_Diplomacy effect
Home

[Freeciv-Dev] (PR#13716) No_Diplomacy effect

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13716) No_Diplomacy effect
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 20 Aug 2005 07:02:25 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13716 >

This patch addds the No_Diplomacy effect, which stops a player from having
any diplomactic relations to any other player, including embassy actions
by diplomats and spies.

This is meant to replace some checks for is_barbarian() by something more
generally useful.

  - Per

Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.190
diff -u -r1.190 player.c
--- common/player.c     18 Aug 2005 06:44:28 -0000      1.190
+++ common/player.c     20 Aug 2005 13:03:11 -0000
@@ -60,6 +60,13 @@
 ***************************************************************/
 bool pplayer_can_ally(const struct player *p1, const struct player *p2)
 {
+  if (p1 == p2) {
+    return TRUE; /* duh! */
+  }
+  if (get_player_bonus(p1, EFT_NO_DIPLOMACY)
+      || get_player_bonus(p2, EFT_NO_DIPLOMACY)) {
+    return FALSE;
+  }
   players_iterate(pplayer) {
     enum diplstate_type ds = pplayer_get_diplstate(p1, pplayer)->type;
     if (pplayer != p1
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.100
diff -u -r1.100 diplhand.c
--- server/diplhand.c   20 Jul 2005 18:28:48 -0000      1.100
+++ server/diplhand.c   20 Aug 2005 13:03:35 -0000
@@ -660,7 +671,8 @@
     return;
   }
 
-  if (is_barbarian(pplayer) || is_barbarian(pother)) {
+  if (get_player_bonus(pplayer, EFT_NO_DIPLOMACY)
+      || get_player_bonus(pother, EFT_NO_DIPLOMACY)) {
     notify_player(pplayer, _("Your diplomatic envoy was decapitated!"));
     return;
   }
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.90
diff -u -r1.90 diplomats.c
--- server/diplomats.c  26 Jul 2005 16:36:00 -0000      1.90
+++ server/diplomats.c  20 Aug 2005 13:03:36 -0000
@@ -273,7 +274,7 @@
   }
 
   /* Check for Barbarian response. */
-  if (is_barbarian (cplayer)) {
+  if (get_player_bonus(cplayer, EFT_NO_DIPLOMACY)) {
     notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
                     _("Your %s was executed in %s by primitive %s."),
                     unit_name(pdiplomat->type),
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.410
diff -u -r1.410 plrhand.c
--- server/plrhand.c    18 Aug 2005 18:30:08 -0000      1.410
+++ server/plrhand.c    20 Aug 2005 13:03:40 -0000
@@ -1158,8 +1158,10 @@
   int player1 = pplayer1->player_no, player2 = pplayer2->player_no;
 
   if (pplayer1 == pplayer2
-      || !pplayer1->is_alive || !pplayer2->is_alive
-      || is_barbarian(pplayer1) || is_barbarian(pplayer2)) {
+      || !pplayer1->is_alive
+      || !pplayer2->is_alive
+      || get_player_bonus(pplayer1, EFT_NO_DIPLOMACY) > 0
+      || get_player_bonus(pplayer2, EFT_NO_DIPLOMACY) > 0) {
     return;
   }
 
@@ -1529,8 +1531,7 @@
   /* cplayer is not yet part of players_iterate which goes only
      to game.info.nplayers. */
   players_iterate(other_player) {
-    /* Barbarians are at war with everybody */
-    if (is_barbarian(other_player)) {
+    if (get_player_bonus(other_player, EFT_NO_DIPLOMACY)) {
       cplayer->diplstates[other_player->player_no].type = DS_WAR;
       other_player->diplstates[cplayer->player_no].type = DS_WAR;
     } else {
Index: common/effects.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.c,v
retrieving revision 1.46
diff -u -r1.46 effects.c
--- common/effects.c    2 Aug 2005 06:39:49 -0000       1.46
+++ common/effects.c    20 Aug 2005 13:31:23 -0000
@@ -115,7 +115,8 @@
   "Has_Senate",
   "Inspire_Partisans",
   "Happiness_To_Gold",
-  "Fanatics"
+  "Fanatics",
+  "No_Diplomacy"
 };
 
 static bool initialized = FALSE;
Index: common/effects.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.h,v
retrieving revision 1.27
diff -u -r1.27 effects.h
--- common/effects.h    2 Aug 2005 06:39:49 -0000       1.27
+++ common/effects.h    20 Aug 2005 13:31:23 -0000
@@ -104,6 +104,7 @@
   EFT_INSPIRE_PARTISANS,
   EFT_HAPPINESS_TO_GOLD,
   EFT_FANATICS, /* stupid special case, we hatess it */
+  EFT_NO_DIPLOMACY,
   EFT_LAST     /* keep this last */
 };
 
Index: data/default/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/effects.ruleset,v
retrieving revision 1.11
diff -u -r1.11 effects.ruleset
--- data/default/effects.ruleset        2 Aug 2005 06:39:49 -0000       1.11
+++ data/default/effects.ruleset        20 Aug 2005 13:37:20 -0000
@@ -16,6 +16,15 @@
 ; /* <-- avoid gettext warnings
 ; */ <-- avoid gettext warnings
 
+; Barbarian effects
+
+[effect_barb1]
+name    = "No_Diplomacy"
+value   = 1
+reqs    =
+    { "type",   "name", "range"
+      "Nation", "Barbarian", "Player"
+    }
 
 ; Specialist output bonuses
 
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.237
diff -u -r1.237 aicity.c
--- ai/aicity.c 18 Aug 2005 06:44:26 -0000      1.237
+++ ai/aicity.c 20 Aug 2005 13:52:37 -0000
@@ -344,6 +344,7 @@
       case EFT_OUTPUT_PER_TILE:
       case EFT_OUTPUT_WASTE_PCT:
       case EFT_SPECIALIST_OUTPUT:
+      case EFT_NO_DIPLOMACY:
          break;
 
       case EFT_SLOW_DOWN_TIMELINE:
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.248
diff -u -r1.248 unit.c
--- common/unit.c       26 Jul 2005 16:35:59 -0000      1.248
+++ common/unit.c       20 Aug 2005 13:59:26 -0000
@@ -89,17 +89,20 @@
        return pplayers_at_war(unit_owner(pdiplomat), city_owner(pcity));
       if(action==DIPLOMAT_MOVE)
         return pplayers_allied(unit_owner(pdiplomat), city_owner(pcity));
-      if (action == DIPLOMAT_EMBASSY && !is_barbarian(city_owner(pcity)) &&
-         !player_has_embassy(unit_owner(pdiplomat), city_owner(pcity)))
+      if (action == DIPLOMAT_EMBASSY
+          && !get_player_bonus(city_owner(pcity), EFT_NO_DIPLOMACY)
+          && !player_has_embassy(unit_owner(pdiplomat), city_owner(pcity))) {
        return TRUE;
+      }
       if(action==SPY_POISON &&
         pcity->size>1 &&
         unit_flag(pdiplomat, F_SPY))
        return pplayers_at_war(unit_owner(pdiplomat), city_owner(pcity));
       if(action==DIPLOMAT_INVESTIGATE)
         return TRUE;
-      if (action == DIPLOMAT_STEAL && !is_barbarian(city_owner(pcity)))
+      if (action == DIPLOMAT_STEAL && !is_barbarian(city_owner(pcity))) {
        return TRUE;
+      }
       if(action==DIPLOMAT_INCITE)
         return !pplayers_allied(city_owner(pcity), unit_owner(pdiplomat));
       if(action==DIPLOMAT_ANY_ACTION)

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13716) No_Diplomacy effect, Per I. Mathisen <=