[Freeciv-Dev] (PR#40316) enemy cities not shown in fogged tiles

2008-07-24 Thread Freeciv guest user

http://bugs.freeciv.org/Ticket/Display.html?id=40316 >

> [EMAIL PROTECTED] - Do 24. Jul 2008, 00:49:34]:

> The problem must be that when the tile is fogged (in the tile packet),
> the ptile->worked flag is cleared.  Looking for "->worked = NULL" in
> the code should find the offending code - it shouldn't be cleared if
> there's a city on the tile.

Great! Without even looking at the code you know exactly how to track
down the bug. Just that the worked member isn't set to NULL directly but
via a wrapper method I looked for in packhand.c and just the first match
was an hit. :D Thank you a lot Jason!

Concerning the further discussion that evolved here I suppose that
should probably be moved to another ticket concerning the discovered
issues, as I regard the bug reported here solved with the 3-liners patch
attached. I agree with book that the border feature right now is
currently more a drawback than it helps the gameplay, however if it
would work like in civ3 where the borders are helping a defending nation
as all infrastructure like roads and rails are prohibited to be used by
enemy units invading the territory this feature would become really
interesting. But that should be something for another [wishlist] ticket...

Greetings,
Nico

P.S.: As I seem to have aroused the attention of so many admins in this
ticket I wanted to remind you on a personal side note to consider my
request for membership to your group in the Gna system (nickname
nicorwadh)...
diff -Nur -X.diff_ignore trunk/client/packhand.c changed/client/packhand.c
--- trunk/client/packhand.c	2008-07-24 23:06:22.0 +0200
+++ changed/client/packhand.c	2008-07-24 23:33:59.0 +0200
@@ -2295,7 +2295,9 @@
* (ptile->worked->tile == NULL) */
   tile_set_worked(ptile, pwork);
 } else {
-  tile_set_worked(ptile, NULL);
+  if (!tile_city(ptile)) {
+tile_set_worked(ptile, NULL);
+  }
 }
 
 tile_changed = TRUE;
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40296) [Patch] IPv6

2008-07-24 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=40296 >

 - Updated against svn
 - Crude dual-stack implementation (improvements to that will be left
to future tickets)

 I'm still going to commit some parts of this separately as they get
cleaned up enough.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/clinet.c freeciv/client/clinet.c
--- freeciv/client/clinet.c 2008-07-25 00:22:34.0 +0300
+++ freeciv/client/clinet.c 2008-07-25 00:22:41.0 +0300
@@ -167,8 +167,13 @@
 port = DEFAULT_SOCK_PORT;
 
   /* use name to find TCP/IP address of server */
-  if (!hostname)
+  if (!hostname) {
+#ifdef IPV6_USED
+hostname = "ip6-localhost";
+#else  /* IPV6 used */
 hostname = "localhost";
+#endif /* IPV6 used */
+  }
 
   if (!net_lookup_service(hostname, port, &server_addr)) {
 (void) mystrlcpy(errbuf, _("Failed looking up host."), errbufsize);
@@ -198,7 +203,7 @@
 (void) mystrlcpy(errbuf, _("Connection in progress."), errbufsize);
 return -1;
   }
-  
+
   if ((client.conn.sock = socket(server_addr.saddr.sa_family,
  SOCK_STREAM, 0)) == -1) {
 (void) mystrlcpy(errbuf, mystrerror(), errbufsize);
diff -Nurd -X.diff_ignore freeciv/client/connectdlg_common.c 
freeciv/client/connectdlg_common.c
--- freeciv/client/connectdlg_common.c  2008-07-14 21:49:09.0 +0300
+++ freeciv/client/connectdlg_common.c  2008-07-25 00:22:41.0 +0300
@@ -206,7 +206,13 @@
   append_output_window(_("Starting server..."));
 
   /* find a free port */ 
-  internal_server_port = find_next_free_port(DEFAULT_SOCK_PORT);
+  internal_server_port = find_next_free_port(DEFAULT_SOCK_PORT,
+#ifdef IPV6_USED
+  TRUE
+#else  /* IPv6 used */
+  FALSE
+#endif /* IPv6 used */
+  );
 
 # ifdef HAVE_WORKING_FORK
   server_pid = fork();
@@ -258,7 +264,7 @@
   fchmod(1, 0644);
 }
 
-/* If it's still attatched to our terminal, things get messed up, 
+/* If it's still attached to our terminal, things get messed up, 
   but civserver needs *something* */ 
 fclose(stdin);
 fd = open("/dev/null", O_RDONLY);
diff -Nurd -X.diff_ignore freeciv/client/servers.c freeciv/client/servers.c
--- freeciv/client/servers.c2008-07-25 00:22:34.0 +0300
+++ freeciv/client/servers.c2008-07-25 00:22:41.0 +0300
@@ -413,14 +413,14 @@
 (scan->error_func)(scan, _("Failed looking up metaserver's host"));
 return FALSE;
   }
-  
+
   if ((s = socket(addr.saddr.sa_family, SOCK_STREAM, 0)) == -1) {
 (scan->error_func)(scan, mystrerror());
 return FALSE;
   }
 
   my_nonblock(s);
-  
+
   if (my_connect(s, &addr.saddr, sockaddr_size(&addr)) == -1) {
 if (errno == EINPROGRESS) {
   /* With non-blocking sockets this is the expected result. */
@@ -538,15 +538,27 @@
 #else  /* HAVE_WINSOCK */
   char buffer[MAX_LEN_PACKET];
 #endif /* HAVE_WINSOCK */
-  struct ip_mreq mreq;
+  struct ip_mreq mreq4;
   const char *group;
   size_t size;
+  int family;
+
+#ifdef IPV6_SUPPORT
+  struct ipv6_mreq mreq6;
+#endif
+
 #ifndef HAVE_WINSOCK
   unsigned char ttl;
-#endif
+#endif /* WINSOCK */
+
+#ifdef IPV6_USED
+  family = AF_INET6;
+#else  /* IPv6 used */
+  family = AF_INET;
+#endif /* IPv6 used */
 
   /* Create a socket for broadcasting to servers. */
-  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+  if ((sock = socket(family, SOCK_DGRAM, 0)) < 0) {
 freelog(LOG_ERROR, "socket failed: %s", mystrerror());
 return FALSE;
   }
@@ -559,9 +571,20 @@
   /* Set the UDP Multicast group IP address. */
   group = get_multicast_group();
   memset(&addr, 0, sizeof(addr));
-  addr.saddr_in4.sin_family = AF_INET;
-  addr.saddr_in4.sin_addr.s_addr = inet_addr(get_multicast_group());
-  addr.saddr_in4.sin_port = htons(SERVER_LAN_PORT);
+#ifndef IPV6_SUPPORT
+  {
+inet_aton(group, &addr.saddr_in4.sin_addr);
+#else  /* IPv6 support */
+  if (family == AF_INET6) {
+addr.saddr.sa_family = AF_INET6;
+inet_pton(AF_INET6, group, &addr.saddr_in6.sin6_addr);
+addr.saddr_in6.sin6_port = htons(SERVER_LAN_PORT);
+  } else {
+inet_pton(AF_INET, group, &addr.saddr_in4.sin_addr);
+#endif /* IPv6 support */
+addr.saddr.sa_family = AF_INET;
+addr.saddr_in4.sin_port = htons(SERVER_LAN_PORT);
+  }
 
 /* this setsockopt call fails on Windows 98, so we stick with the default
  * value of 1 on Windows, which should be fine in most cases */
@@ -573,7 +596,7 @@
 freelog(LOG_ERROR, "setsockopt failed: %s", mystrerror());
 return FALSE;
   }
-#endif
+#endif /* HAVE_WINSOCK */
 
   if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, 
  sizeof(opt))) {
@@ -587,7 +610,7 @@
  
 
   if (sendto(sock, buffer, size, 0, &addr.saddr,
-  sockaddr_size(&addr)) < 0) {
+ sockaddr_size(&addr)) < 0) {
 /* This can happen when there's no network connection - it should
  * give an in-game message. */
 freelog(LOG_ERROR, "lanserver scan sendto failed: %s", mystrerror());
@@ -599,7 +622

Re: [Freeciv-Dev] (PR#40370) borders algorithm sucks

2008-07-24 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=40370 >

2008/7/22 Jason Dorje Short:
>
> A lower granularity should be possible.  Either the setting should
> allow the border_sq value to be set or it should be a floating-point
> value.

 This version allows setting _sq value directly.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aisettler.c freeciv/ai/aisettler.c
--- freeciv/ai/aisettler.c  2008-03-08 16:32:50.0 +0200
+++ freeciv/ai/aisettler.c  2008-07-24 23:00:39.0 +0300
@@ -491,7 +491,7 @@
* likelihood go away next turn, or even in a few nanoseconds. */
   continue;
 }
-if (game.info.borders > 0) {
+if (game.info.borders_sq > 0) {
   struct player *powner = tile_owner(ptile);
   if (NULL != powner
&& powner != pplayer
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/menu.c 
freeciv/client/gui-gtk-2.0/menu.c
--- freeciv/client/gui-gtk-2.0/menu.c   2008-07-24 19:15:22.0 +0300
+++ freeciv/client/gui-gtk-2.0/menu.c   2008-07-24 23:06:47.0 +0300
@@ -1433,7 +1433,8 @@
 menus_set_active("/_View/City Outlines", draw_city_outlines);
 menus_set_active("/_View/City Output", draw_city_output);
 menus_set_active("/_View/Map _Grid", draw_map_grid);
-menus_set_sensitive("/_View/National _Borders", game.info.borders > 
0);
+menus_set_sensitive("/_View/National _Borders",
+game.info.borders_sq > 0);
 menus_set_active("/_View/National _Borders", draw_borders);
 menus_set_active("/_View/City _Names", draw_city_names);
 
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/mapview.c 
freeciv/client/gui-sdl/mapview.c
--- freeciv/client/gui-sdl/mapview.c2008-03-08 16:33:05.0 +0200
+++ freeciv/client/gui-sdl/mapview.c2008-07-24 23:10:00.0 +0300
@@ -557,7 +557,7 @@
 2 * h + (DEFAULT_UNITS_H + (pInfo_Window->size.h - 
pInfo_Window->area.h))|| right) {
   struct city *pCity = tile_city(pTile);
 
- if (game.info.borders > 0 && !pCity) {
+  if (game.info.borders_sq > 0 && !pCity) {
const char *diplo_nation_plural_adjectives[DS_LAST] =
 {Q_("?nation:Neutral"), Q_("?nation:Hostile"),
"" /* unused, DS_CEASEFIRE*/,
@@ -583,7 +583,7 @@
 cat_snprintf(buffer, sizeof(buffer), _("\nUnclaimed 
territory"));
   }
}
-  } /* game.info.borders > 0 && !pCity */
+  } /* game.info.borders_sq > 0 && !pCity */
   
   if (pCity) {
 /* Look at city owner, not tile owner (the two should be the same, 
if
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/menu.c 
freeciv/client/gui-win32/menu.c
--- freeciv/client/gui-win32/menu.c 2008-07-03 21:58:06.0 +0300
+++ freeciv/client/gui-win32/menu.c 2008-07-24 23:10:54.0 +0300
@@ -1081,7 +1081,7 @@
   (SSHIP_NONE != client.conn.playing->spaceship.state));
 
 my_check_menu(menu, IDM_VIEW_MAP_GRID, draw_map_grid);
-my_enable_menu(menu, IDM_VIEW_NATIONAL_BORDERS, game.info.borders > 0);
+my_enable_menu(menu, IDM_VIEW_NATIONAL_BORDERS, game.info.borders_sq > 0);
 my_check_menu(menu, IDM_VIEW_NATIONAL_BORDERS, draw_borders);
 my_check_menu(menu, IDM_VIEW_CITY_NAMES, draw_city_names);
 my_enable_menu(menu, IDM_VIEW_CITY_GROWTH, draw_city_names);
diff -Nurd -X.diff_ignore freeciv/client/text.c freeciv/client/text.c
--- freeciv/client/text.c   2008-07-21 12:41:52.0 +0300
+++ freeciv/client/text.c   2008-07-24 23:07:46.0 +0300
@@ -112,7 +112,7 @@
   if (tile_has_special(ptile, S_HUT)) {
 astr_add_line(&str, _("Minor Tribe Village"));
   }
-  if (game.info.borders > 0 && !pcity) {
+  if (game.info.borders_sq > 0 && !pcity) {
 struct player *owner = tile_owner(ptile);
 
 if (NULL != client.conn.playing && owner == client.conn.playing) {
diff -Nurd -X.diff_ignore freeciv/client/tilespec.c freeciv/client/tilespec.c
--- freeciv/client/tilespec.c   2008-07-24 19:15:22.0 +0300
+++ freeciv/client/tilespec.c   2008-07-24 23:08:11.0 +0300
@@ -4119,7 +4119,7 @@
   }
 }
 
-if (draw_borders && game.info.borders > 0 && known[0] && known[1]) {
+if (draw_borders && game.info.borders_sq > 0 && known[0] && known[1]) {
   struct player *owner0 = tile_owner(pedge->tile[0]);
   struct player *owner1 = tile_owner(pedge->tile[1]);
 
diff -Nurd -X.diff_ignore freeciv/common/game.c freeciv/common/game.c
--- freeciv/common/game.c   2008-07-03 21:58:05.0 +0300
+++ freeciv/common/game.c   2008-07-24 22:56:34.0 +0300
@@ -287,7 +287,7 @@
   game.info.spacerace = GAME_DEFAULT_SPACERACE;
   game.info.turnblock = GAME_DEFAULT_TURNBLOCK;
   game.info.fogofwar  = GAME_DEFAULT_FOGOFWAR;
-  game.info.borders   = GAME_DEFAULT_BORDERS;
+  game.info.borders_sq= GAME_DEFAULT_BORDERS;
   game.info.happyborders  = GAME_DEFAULT_HAPPYBORDERS;
   game.i

[Freeciv-Dev] (PR#40400) [Patch] Fix civmanual crashes

2008-07-24 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=40400 >

 $subject


 - ML

diff -Nurd -X.diff_ignore freeciv/manual/civmanual.c freeciv/manual/civmanual.c
--- freeciv/manual/civmanual.c  2008-03-08 16:32:50.0 +0200
+++ freeciv/manual/civmanual.c  2008-07-24 22:12:15.0 +0300
@@ -107,7 +107,10 @@
   char filename[40];
   enum manuals manuals;
 
+  /* Initialize game with default values */
   game_init();
+  /* Reset aifill to zero */
+  game.info.aifill = 0;
   load_rulesets();
   for (manuals = 0; manuals < MANUAL_COUNT; manuals++) {
 int i;
@@ -268,9 +271,14 @@
 }
 fprintf(doc, "+%d T(%d)\n",
 pterrain->road_trade_incr, pterrain->road_time);
-fprintf(doc, "%s(%d)\n\n",
-terrain_name_translation(pterrain->transform_result),
-pterrain->transform_time);
+
+if (pterrain->transform_result) {
+  fprintf(doc, "%s(%d)\n\n",
+  terrain_name_translation(pterrain->transform_result),
+  pterrain->transform_time);
+} else {
+  fprintf(doc, "-(-)\n\n");
+}
 
 fprintf(doc, "%d / %d / %d\n\n",
 pterrain->rail_time,
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40368) S2_2/trunk "unused" resource definitions in data/civ1/terrain.ruleset ?

2008-07-24 Thread Madeline Book

http://bugs.freeciv.org/Ticket/Display.html?id=40368 >

Committed to S2_2 (r15046) and trunk (r15045).


--
喉が渇いたんだ。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40316) enemy cities not shown in fogged tiles

2008-07-24 Thread Madeline Book

http://bugs.freeciv.org/Ticket/Display.html?id=40316 >

> [per - Thu Jul 24 12:14:28 2008]:
> 
> On Thu, Jul 24, 2008 at 1:01 PM, Marko Lindqvist <[EMAIL PROTECTED]>
> wrote:
> > This also brings the concept of client sied "invisible cities".
> > These are cities client knows to exist, because it has seen some
> > tile it uses, but doesn't know where city center is or anything
> > about city internals. I fixed crash related to city->tile->city
> > == NULL not so long ago. Maybe this (legally) invisible city code
> > is not working correctly, but makes also fogged cities invisible.
> 
> Just make it a rule that if you see a city worked tile, you also see
> the city working it and surrounding tiles? It makes a great deal of
> sense from an in-game perspective, and should simplify the code logic.

I disagree with this game rule, it is not good for gameplay.
The reason being is that it would make sneaking up on cities
easier. An example would be a trireme that only has to see a
worked ocean tile to find where the city is located, in essence
giving it a larger vision radius near a city. This is also the
reason why almost all 2.0 multiplayer games disable borders;
it gives too much information to attackers and unbalances the
game.

(I do know that triremes cannot enter deep ocean now, which is
nice I suppose, but really it applies to any unit.)

(Also, I would like borders to be fogged like units and cities
too, but that is an issue for another ticket...)

As for the case of the seen worked tile but unknown city,
perhaps it would work to have the ptile->worked field be a city
id (and to restore ptile->city to its original purpose). Then
ptile->worked==0 would indicate an unworked tile, whereas a
positive value would indicate that the tile is being worked
by the city with that id. It would be an "invisible" city if
the client does not know about that city id (i.e. has never
seen the tile on which the city is located).


--
久しぶり!元気?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40316) enemy cities not shown in fogged tiles

2008-07-24 Thread Per I. Mathisen

http://bugs.freeciv.org/Ticket/Display.html?id=40316 >

On Thu, Jul 24, 2008 at 1:01 PM, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>  This also brings the concept of client sied "invisible cities". These
> are cities client knows to exist, because it has seen some tile it
> uses, but doesn't know where city center is or anything about city
> internals. I fixed crash related to city->tile->city == NULL not so
> long ago. Maybe this (legally) invisible city code is not working
> correctly, but makes also fogged cities invisible.

Just make it a rule that if you see a city worked tile, you also see
the city working it and surrounding tiles? It makes a great deal of
sense from an in-game perspective, and should simplify the code logic.

  - Per



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40316) enemy cities not shown in fogged tiles

2008-07-24 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=40316 >

2008/7/24 guest user:
>
> There is the catch: Between the versions the ptile->city member has been
> replaced by ptile->worked which points to the city working on the tile,
> so many tiles are pointing to the same city (in the city radius I
> suppose). That is what the tile_city function is all about (in S2_1 it
> didn't exist and the put_one_element function got just passed
> ptile->city), as it checks whether the tile that is worked on (if at
> all) is the center tile of the city itself or if not returns NULL
> (meaning it is just a tile in the vicinity of the given city and worked
> by it).

 This also brings the concept of client sied "invisible cities". These
are cities client knows to exist, because it has seen some tile it
uses, but doesn't know where city center is or anything about city
internals. I fixed crash related to city->tile->city == NULL not so
long ago. Maybe this (legally) invisible city code is not working
correctly, but makes also fogged cities invisible.


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev