[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]
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.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"We just typed make..."
-- Stephen Lambrigh, Director of Server Product Marketing at Informix,
about porting their Database to Linux
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.61
diff -u -u -r1.61 goto.c
--- client/goto.c 2003/10/29 07:32:57 1.61
+++ client/goto.c 2003/11/05 21:26:27
@@ -342,6 +342,24 @@
}
/**********************************************************************
+ 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 || is_non_allied_unit_tile(ptile, param->owner)) {
+ return TB_IGNORE;
+ }
+ if (is_non_allied_city_tile(ptile, param->owner)) {
+ return TB_DONT_LEAVE;
+ }
+ return TB_NORMAL;
+}
+
+/**********************************************************************
Fill the PF parameter with the correct client-goto values.
***********************************************************************/
static void fill_client_goto_parameter(struct unit *punit,
@@ -354,6 +372,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;
}
|
|