Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] Re: (PR#5057) Diplomats can't go on ennemy tiles
Home

[Freeciv-Dev] Re: (PR#5057) Diplomats can't go on ennemy tiles

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: remi.bonnet@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#5057) Diplomats can't go on ennemy tiles
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Wed, 13 Aug 2003 05:19:31 -0700
Reply-to: rt@xxxxxxxxxxxxxx

I split the patch into 2.  They are separate issues although both relating 
to diplomats.

I am ready to commit the goto part, whom I should attribute it to, Remi 
Bonnet?

The second part I am not sure about.  I propose a slightly different fix 
attached as dip_act_gb.diff.  The original patch is attached as 
dip_act_rb.diff

G.

On Wed, 13 Aug 2003, Guest wrote:

> 
> Bug found at CVS 12/08/03
> 
> Diplomats can't go on ennemy tiles because they are treated as peaceful
> units by goto. This patch give to the diplomats the same behaviour as
> for agressive units. 
> 
> I also fix a potential issue in unit.c. With the previous code, if a spy
> can't poisonate but can't sabotate but can bribe, a request to
> is_diplomat_action_available will return FALSE. This can't happen with
> the current code but it is a potential bug
> 

--- ./common/unit.c.orig        2003-08-13 07:57:34.000000000 +0200
+++ ./common/unit.c     2003-08-13 07:58:58.000000000 +0200
@@ -170,13 +170,17 @@
        unit_list_size(&ptile->units)==1 &&
        unit_flag(pdiplomat, F_SPY)) {
       punit = unit_list_get(&ptile->units, 0);
-      return pplayers_at_war(unit_owner(pdiplomat), unit_owner(punit));
+      if (pplayers_at_war(unit_owner(pdiplomat), unit_owner(punit))) {
+       return TRUE;
+      }
     }
 
     if ((action==DIPLOMAT_BRIBE || action==DIPLOMAT_ANY_ACTION) &&
        unit_list_size(&ptile->units)==1) {
       punit = unit_list_get(&ptile->units, 0);
-      return !pplayers_allied(unit_owner(punit), unit_owner(pdiplomat));
+      if (!pplayers_allied(unit_owner(punit), unit_owner(pdiplomat))) {
+       return TRUE;
+      }
     }
   }
   return FALSE;
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.181
diff -u -r1.181 unit.c
--- common/unit.c       2003/07/25 14:48:32     1.181
+++ common/unit.c       2003/08/13 12:15:05
@@ -166,15 +166,16 @@
     struct tile *ptile = map_get_tile(destx, desty);
     struct unit *punit;
 
-    if ((action==SPY_SABOTAGE_UNIT || action==DIPLOMAT_ANY_ACTION) &&
-       unit_list_size(&ptile->units)==1 &&
-       unit_flag(pdiplomat, F_SPY)) {
+    if (action == SPY_SABOTAGE_UNIT 
+        && unit_list_size(&ptile->units) == 1 
+        && unit_flag(pdiplomat, F_SPY)) {
       punit = unit_list_get(&ptile->units, 0);
       return pplayers_at_war(unit_owner(pdiplomat), unit_owner(punit));
     }
 
-    if ((action==DIPLOMAT_BRIBE || action==DIPLOMAT_ANY_ACTION) &&
-       unit_list_size(&ptile->units)==1) {
+    /* Bribing is the action with fewest restrictions */
+    if ((action == DIPLOMAT_BRIBE || action == DIPLOMAT_ANY_ACTION) 
+        && unit_list_size(&ptile->units) == 1) {
       punit = unit_list_get(&ptile->units, 0);
       return !pplayers_allied(unit_owner(punit), unit_owner(pdiplomat));
     }

[Prev in Thread] Current Thread [Next in Thread]