Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#6977) Goto into unknown area
Home

[Freeciv-Dev] Re: (PR#6977) Goto into unknown area

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ue80@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6977) Goto into unknown area
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Tue, 6 Jan 2004 13:14:28 -0800
Reply-to: rt@xxxxxxxxxxx

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

On Tue, Jan 06, 2004 at 02:47:42AM -0800, ue80@xxxxxxxxxxxxxxxxxxxxx wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6977 >
> 
> On Tue, Jan 06, 2004 at 08:52:52AM +0100, Raimar Falke wrote:
> > On Mon, Jan 05, 2004 at 11:10:17PM -0800, Jason Short wrote:
> > > 
> > > <URL: http://rt.freeciv.org/Ticket/Display.html?id=6977 >
> > > 
> > > > [ue80@xxxxxxxxxxxxxxxxxxxxx - Fri Nov 28 21:29:06 2003]:
> > > > 
> > > > Hi,
> > > > 
> > > > i really dislike that gotoing into black area isn't possible in the gtk2
> > > > client.
> > > > 
> > > > When moving to a certain spot sometimes it's a good idea to move through
> > > > "black" area to explore that area.
> > > 
> > > Should be a client option?
> > > 
> > > I have no idea how to implement this one, though.  Raimar or Greg: you
> > > want to take a shot at it?
> > 
> > I'm also for an option. Thomas?
> 
> Option sounds ok for me.

Please try the attached patch.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "Debugging is twice as hard as writing the code in the first place.
   Therefore, if you write the code as cleverly as possible, you are,
   by definition, not smart enough to debug it."
    -- Brian W. Kernighan

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.305
diff -u -u -r1.305 aiunit.c
--- ai/aiunit.c 2003/11/28 17:37:18     1.305
+++ ai/aiunit.c 2004/01/06 21:12:07
@@ -540,7 +540,7 @@
 
   pft_fill_default_parameter(&parameter);
   pft_fill_unit_parameter(&parameter, punit);
-  parameter.get_TB = no_fights_or_unknown;
+  parameter.get_TB = pft_no_fights_or_unknown;
   /* When exploring, even AI should pretend to not cheat. */
   parameter.omniscience = FALSE;
 
@@ -2257,7 +2257,7 @@
   pft_fill_default_parameter(&parameter);
   pft_fill_unit_overlap_param(&parameter, punit);
   /* We are looking for our units, no need to look into the unknown */
-  parameter.get_TB = no_fights_or_unknown;
+  parameter.get_TB = pft_no_fights_or_unknown;
   parameter.omniscience = FALSE;
   
   map = pf_create_map(&parameter);
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.64
diff -u -u -r1.64 goto.c
--- client/goto.c       2004/01/04 00:40:03     1.64
+++ client/goto.c       2004/01/06 21:12:08
@@ -28,6 +28,7 @@
 #include "clinet.h"
 #include "control.h"
 #include "mapview_g.h"
+#include "options.h"
 
 #include "goto.h"
 
@@ -330,7 +331,7 @@
 {
   struct tile *ptile = map_get_tile(x, y);
 
-  if (known == TILE_UNKNOWN) {
+  if (known == TILE_UNKNOWN && !goto_into_unknown) {
     return TB_IGNORE;
   }
   if (is_non_allied_unit_tile(ptile, param->owner)
@@ -350,7 +351,7 @@
 {
   struct tile *ptile = map_get_tile(x, y);
 
-  if (known == TILE_UNKNOWN) {
+  if (known == TILE_UNKNOWN && !goto_into_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.
@@ -381,8 +382,10 @@
   } else if (unit_flag(punit, F_TRADE_ROUTE)
             || unit_flag(punit, F_HELP_WONDER)) {
     parameter->get_TB = get_TB_caravan;
+  } else if (goto_into_unknown) {
+    parameter->get_TB = pft_no_fights;
   } else {
-    parameter->get_TB = no_fights_or_unknown;
+    parameter->get_TB = pft_no_fights_or_unknown;
   }
   parameter->turn_mode = TM_WORST_TIME;
   parameter->start_x = punit->x;
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.88
diff -u -u -r1.88 options.c
--- client/options.c    2003/12/16 15:07:52     1.88
+++ client/options.c    2004/01/06 21:12:08
@@ -73,6 +73,7 @@
 bool ask_city_name = TRUE;
 bool popup_new_cities = TRUE;
 bool keyboardless_goto = TRUE;
+bool goto_into_unknown = FALSE;
 
 /* This option is currently set by the client - not by the user. */
 bool update_city_text_in_refresh_tile = TRUE;
@@ -125,6 +126,7 @@
   GEN_BOOL_OPTION(dialogs_on_top,          N_("Keep dialogs on top (GTK+ 2.0 
only)")),
   GEN_BOOL_OPTION(ask_city_name,            N_("Prompt for city names")),
   GEN_BOOL_OPTION(popup_new_cities,         N_("Pop up city dialog for new 
cities")),
+  GEN_BOOL_OPTION(goto_into_unknown,        N_("Should units goto into unknown 
terrain")),
   GEN_OPTION_TERMINATOR
 };
 #undef GEN_INT_OPTION
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.33
diff -u -u -r1.33 options.h
--- client/options.h    2003/12/16 15:07:52     1.33
+++ client/options.h    2004/01/06 21:12:08
@@ -47,6 +47,7 @@
 extern bool popup_new_cities;
 extern bool update_city_text_in_refresh_tile;
 extern bool keyboardless_goto;
+extern bool goto_into_unknown;
 
 enum client_option_type {
   COT_BOOL,
Index: common/aicore/pf_tools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.c,v
retrieving revision 1.9
diff -u -u -r1.9 pf_tools.c
--- common/aicore/pf_tools.c    2003/11/19 15:17:16     1.9
+++ common/aicore/pf_tools.c    2004/01/06 21:12:09
@@ -351,14 +351,32 @@
   PF callback to prohibit going into the unknown.  Also makes sure we 
   don't plan to attack anyone.
 ***********************************************************************/
-enum tile_behavior no_fights_or_unknown(int x, int y, 
-                                        enum known_type known,
-                                        struct pf_parameter *param)
+enum tile_behavior pft_no_fights_or_unknown(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)
+      || is_non_allied_city_tile(ptile, param->owner)) {
+    /* Can't attack */
+    return TB_IGNORE;
+  }
+  return TB_NORMAL;
+}
+
+/********************************************************************** 
+  PF callback to prohibit going into the unknown.  Also makes sure we 
+  don't plan to attack anyone.
+***********************************************************************/
+enum tile_behavior pft_no_fights(int x, int y,
+                                enum known_type known,
+                                struct pf_parameter *param)
+{
+  struct tile *ptile = map_get_tile(x, y);
+
+  if (is_non_allied_unit_tile(ptile, param->owner)
       || is_non_allied_city_tile(ptile, param->owner)) {
     /* Can't attack */
     return TB_IGNORE;
Index: common/aicore/pf_tools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.h,v
retrieving revision 1.5
diff -u -u -r1.5 pf_tools.h
--- common/aicore/pf_tools.h    2003/10/13 07:30:57     1.5
+++ common/aicore/pf_tools.h    2004/01/06 21:12:09
@@ -24,9 +24,11 @@
                                 struct unit *punit);
 void pft_fill_unit_attack_param(struct pf_parameter *parameter,
                                 struct unit *punit);
-enum tile_behavior no_fights_or_unknown(int x, int y, 
-                                        enum known_type known,
-                                        struct pf_parameter *param);
+enum tile_behavior pft_no_fights_or_unknown(int x, int y,
+                                           enum known_type known,
+                                           struct pf_parameter *param);
+enum tile_behavior pft_no_fights(int x, int y, enum known_type known,
+                                struct pf_parameter *param);
 
 #define pf_iterator(map, position) {                       \
   struct pf_position position;                             \

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