Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: (PR#6718) Cannot client goto caravan into other player
Home

[Freeciv-Dev] Re: (PR#6718) Cannot client goto caravan into other player

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6718) Cannot client goto caravan into other player's city
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 Nov 2003 15:31:20 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6718 >

Gregory Berkolaiko wrote:
> On Wed, 5 Nov 2003, Raimar Falke wrote:
> 
> 
>>On Wed, Nov 05, 2003 at 12:17:39PM -0800, Gregory Berkolaiko wrote:
>>
>>>On Wed, 5 Nov 2003, Raimar Falke wrote:
>>>
>>>
>>>>On Sat, Nov 01, 2003 at 03:13:41AM -0800, Per I. Mathisen wrote:
>>>>
>>>>>Small bug: You cannot use client goto to send a caravan into a city owned
>>>>>by another player. Savegame attached.
>>>>>
>>>>>(Since the savegame is made in civworld, you must give the caravan a home
>>>>>city before trying to use it.)
>>>>
>>>>And the easy fix.
>>>
>>>This way goto can suggest paths that attack units
>>
>>Good catch. New untested version attached. 
> 
> 
> There are problems still I think.  It assumes you cannot see units inside 
> other player's cities.

How about this one?  Still untested.

jason

? genlist_safe_unlink.diff
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.61
diff -u -r1.61 goto.c
--- client/goto.c       2003/10/29 07:32:57     1.61
+++ client/goto.c       2003/11/12 23:29:16
@@ -342,6 +342,30 @@
 }
 
 /********************************************************************** 
+  PF callback for caravans. Caravans doesn't go into the unknown and
+  don't attack enemy units but enter enemy cities.
+***********************************************************************/
+static enum tile_behavior get_TB_caravan(int x, int y, enum known_type known,
+                                        struct pf_parameter *param)
+{
+  struct tile *ptile = map_get_tile(x, y);
+
+  if (known == TILE_UNKNOWN) {
+    return TB_IGNORE;
+  } else if (is_non_allied_city_tile(ptile, param->owner)) {
+    /* F_TRADE_ROUTE units can travel to, but not through, enemy cities.
+     * FIXME: F_HELP_WONDER units cannot.  */
+    return TB_DONT_LEAVE;
+  } else if (is_non_allied_unit_tile(ptile, param->owner)) {
+    /* Note this must be below the city check. */
+    return TB_IGNORE;
+  }
+
+  /* Includes empty, allied, or allied-city tiles. */
+  return TB_NORMAL;
+}
+
+/********************************************************************** 
   Fill the PF parameter with the correct client-goto values.
 ***********************************************************************/
 static void fill_client_goto_parameter(struct unit *punit,
@@ -354,6 +378,9 @@
   assert(parameter->get_TB == NULL);
   if (unit_type(punit)->attack_strength > 0 || unit_flag(punit, F_DIPLOMAT)) {
     parameter->get_TB = get_TB_aggr;
+  } else if (unit_flag(punit, F_TRADE_ROUTE)
+            || unit_flag(punit, F_HELP_WONDER)) {
+    parameter->get_TB = get_TB_caravan;
   } else {
     parameter->get_TB = no_fights_or_unknown;
   }

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