Re: [Freeciv-Dev] borders and fog of war

2008-07-25 Thread Daniel Markstedt
On Fri, 25 Jul 2008 19:02:47 +0900, Per Inge Mathisen  
[EMAIL PROTECTED] wrote:

 On Thu, Jul 24, 2008 at 6:34 PM, Madeline Book [EMAIL PROTECTED]  
 wrote:
 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.

 There was a suggestion some years(?) ago that players should have full
 vision inside their borders, to offset such information leakage. I
 think that is a reasonable idea.


I agree with this idea.

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

 You mean last seen borders would be remembered by the player,
 instead of being given as it really is? IIRC, and this starts being
 quite a while ago, the first borders implementation was like this. It
 was a horrible mess. I do not think you want to go back there. What
 problem would this solve, in any case?

   - Per


I remember a time (sometime in early 2.1 alpha) when we had this  
implementation - it was above all a visual mess. You had to constantly go  
and re-explore the surrounding terrain to 'clean up' the border residue  
cluttering the view.

Instead I would suggest simply not displaying borders of hostile players  
at all in fogged tiles. This would remedy the multiplayer balance issue,  
while still giving some idea of the political layout of the world since  
you can always see the borders of friendly players.

  ~Daniel

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


[Freeciv-Dev] (PR#40401) consistent segfault

2008-07-25 Thread r7

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40401 

This transaction appears to have no content
hi all

getting consistent segfault behaviour. please find attached gdb trace.

version info:
   [EMAIL PROTECTED] BLAG]# uname -ori  rpm -q freeciv
   2.6.25.10-libre.86.fc9.1.i686 i386 GNU/Linux
   freeciv-2.1.5-1.fc9.i386
   [EMAIL PROTECTED] BLAG]#

actions causing this:
   launch civclient
   click on Start New Game
   screen changes, displays text as far as:
 Go Give 'em hell!
 Starting server...
   all frozen

hope this helps. looking forward to your reply. if you require any 
further information, please ask.

best
r7
-- 
r7 [at] aktivix [dot] org
$ gdb civclient
GNU gdb Fedora (6.8-11.fc9)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i386-redhat-linux-gnu...
(no debugging symbols found)
Missing separate debuginfos, use: debuginfo-install freeciv.i386
(gdb) run
Starting program: /usr/bin/civclient 
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type return to continue, or q return to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type return to continue, or q return to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb80ad710 (LWP 14511)]
(no debugging symbols found)
(no debugging symbols found)
ALSA lib pcm_dmix.c:963:(snd_pcm_dmix_open) unable to create IPC semaphore
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type return to continue, or q return to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb7eacb90 (LWP 14514)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Detaching after fork from child process 14515.

Program received signal SIGSEGV, Segmentation fault.
0x08113d5e in gtk_main_quit ()
(gdb) 


signature.asc
Description: PGP signature
___
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-25 Thread Marko Lindqvist

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

2008/7/25 Marko Lindqvist:
 You seem to be avoiding
 setting ptile-worked to NULL when server requests it by sending
 worked == IDENTITY_NUMBER_ZERO. It seems to me that problem has to be
 in server side sending such information in the first place.

 For fogged tile, worked id should be id of the dumb city from player
map (city player *believes* to be there).


- ML



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


[Freeciv-Dev] (PR#40403) [Patch] AI invasion improvement

2008-07-25 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40403 

 Store actual number of attack or occupy capable units in
city.ai.invasion instead of just one bit telling if such units exist
or not. This makes it possible to concentrate attacks in the future.
This patch already makes AI not to believe it will conquer city if it
has less attacking units than there is defenders.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/advmilitary.c freeciv/ai/advmilitary.c
--- freeciv/ai/advmilitary.c2008-07-23 03:30:10.0 +0300
+++ freeciv/ai/advmilitary.c2008-07-25 21:27:11.0 +0300
@@ -984,8 +984,8 @@
 desire = 0;
 
   } else if (uclass_has_flag(utype_class(punittype), UCF_CAN_OCCUPY)  
acity
-  TEST_BIT(acity-ai.invasion, INVASION_ATTACK)
-  !TEST_BIT(acity-ai.invasion, INVASION_OCCUPY)) {
+  acity-ai.invasion.attack  0
+  acity-ai.invasion.occupy == 0) {
 desire = bcost * SHIELD_WEIGHTING;
 
   } else {
@@ -1205,7 +1205,7 @@
def_owner = unit_owner(pdef);
   }
 }
-if (COULD_OCCUPY(myunit) || TEST_BIT(acity-ai.invasion, INVASION_OCCUPY)) 
{
+if (COULD_OCCUPY(myunit) || acity-ai.invasion.occupy  0) {
   /* bonus for getting the city */
   benefit += 40;
 }
diff -Nurd -X.diff_ignore freeciv/ai/aiair.c freeciv/ai/aiair.c
--- freeciv/ai/aiair.c  2008-01-20 04:03:28.0 +0200
+++ freeciv/ai/aiair.c  2008-07-25 21:33:24.0 +0300
@@ -75,8 +75,9 @@
   /* TODO: There is a danger of producing too many units that will not 
* attack anything.  Production should not happen if there is an idle 
* unit of the same type nearby */
-  if (acity  !TEST_BIT(acity-ai.invasion, INVASION_OCCUPY)  punit-id != 
0) {
-/* No ground troups are invading */
+  if (acity  punit-id != 0
+   acity-ai.invasion.occupy == 0  !COULD_OCCUPY(punit)) {
+/* No units capable of occupying are invading */
 freelog(LOG_DEBUG, Don't want to attack %s, although we could, 
 city_name(acity));
 return FALSE;
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c 2008-02-02 09:34:56.0 +0200
+++ freeciv/ai/aiunit.c 2008-07-25 21:25:22.0 +0300
@@ -1141,7 +1141,7 @@
   center of the area is either the unit itself (dest == FALSE) or the
   destination of the current goto (dest == TRUE). The invasion threat
   is marked in pcity-ai.invasion by setting the which bit (to
-  tell attack from sea apart from ground unit attacks).
+  tell attack which can only kill units from occupy possibility).
 
   If dest == TRUE then a valid goto is presumed.
 **/
@@ -1165,9 +1165,11 @@
 
 if (pcity
  HOSTILE_PLAYER(pplayer, ai, city_owner(pcity))
-!TEST_BIT(pcity-ai.invasion, which)
 (dest || !has_defense(pcity))) {
-  pcity-ai.invasion |= COND_SET_BIT(TRUE, which);
+  pcity-ai.invasion.attack++;
+  if (which == INVASION_OCCUPY) {
+pcity-ai.invasion.occupy++;
+  }
 }
   } square_iterate_end;
 }
@@ -1259,7 +1261,8 @@
 city_list_iterate(aplayer-cities, acity) {
   reinforcements_cost_and_value(punit, acity-tile,
 acity-ai.attack, acity-ai.bcost);
-  acity-ai.invasion = 0;
+  acity-ai.invasion.attack = 0;
+  acity-ai.invasion.occupy = 0;
 } city_list_iterate_end;
   } players_iterate_end;
 
@@ -1360,6 +1363,8 @@
   }
 
   players_iterate(aplayer) {
+int reserves;
+
 /* For the virtual unit case, which is when we are called to evaluate
  * which units to build, we want to calculate in danger and which
  * players we want to make war with in the future. We do _not_ want
@@ -1425,9 +1430,16 @@
 }
   }
 
-  if (COULD_OCCUPY(punit) || TEST_BIT(acity-ai.invasion, 
INVASION_OCCUPY)) {
-/* There are units able to occupy the city! */
-benefit += 40;
+  reserves = acity-ai.invasion.attack - 
unit_list_size(acity-tile-units);
+
+  if (reserves = 0) {
+/* We have enough units to kill all the units in the city */
+if (reserves  0
+ (COULD_OCCUPY(punit) || acity-ai.invasion.occupy  0)) {
+  /* There are units able to occupy the city after all defenders
+   * are killed! */
+  benefit += 60;
+}
   }
 
   attack = (attack_value + acity-ai.attack) 
@@ -1448,8 +1460,8 @@
 /* Too far! */
 want = 0;
   } else if (COULD_OCCUPY(punit)
-  TEST_BIT(acity-ai.invasion, INVASION_ATTACK)
-  !TEST_BIT(acity-ai.invasion, INVASION_OCCUPY)) {
+  acity-ai.invasion.attack  0
+  acity-ai.invasion.occupy == 0) {
 /* Units able to occupy really needed there! */
 want = bcost * SHIELD_WEIGHTING;
   } else {
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.h 

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

2008-07-25 Thread Freeciv guest user

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

 [EMAIL PROTECTED] - Fr 25. Jul 2008, 16:12:11]:

 It seems to me that problem has to be
 in server side sending such information in the first place. Something
 wrong with send_tile_info()?

Thanks for the hint. The same I did on the client side can also be done
in this function on the server, see the attached patch.
diff -Nur -X.diff_ignore trunk/server/maphand.c changed/server/maphand.c
--- trunk/server/maphand.c	2008-07-24 23:03:15.0 +0200
+++ changed/server/maphand.c	2008-07-25 23:50:56.0 +0200
@@ -412,7 +412,9 @@
   info.owner = (NULL != tile_owner(ptile))
? player_number(tile_owner(ptile))
: MAP_TILE_OWNER_NULL;
-  info.worked = IDENTITY_NUMBER_ZERO;
+  info.worked = (NULL != tile_city(ptile))
+? tile_worked(ptile)-id
+: IDENTITY_NUMBER_ZERO;
 
   info.terrain = (NULL != plrtile-terrain)
   ? terrain_number(plrtile-terrain)
___
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-25 Thread Freeciv guest user

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

 [EMAIL PROTECTED] - Fr 25. Jul 2008, 16:12:11]:

 It seems to me that problem has to be
 in server side sending such information in the first place. Something
 wrong with send_tile_info()?

Thanks for the hint. The same I did on the client side can also be done
in this function on the server, see the attached patch.

Greetings,
Nico
diff -Nur -X.diff_ignore trunk/server/maphand.c changed/server/maphand.c
--- trunk/server/maphand.c	2008-07-24 23:03:15.0 +0200
+++ changed/server/maphand.c	2008-07-25 23:50:56.0 +0200
@@ -412,7 +412,9 @@
   info.owner = (NULL != tile_owner(ptile))
? player_number(tile_owner(ptile))
: MAP_TILE_OWNER_NULL;
-  info.worked = IDENTITY_NUMBER_ZERO;
+  info.worked = (NULL != tile_city(ptile))
+? tile_worked(ptile)-id
+: IDENTITY_NUMBER_ZERO;
 
   info.terrain = (NULL != plrtile-terrain)
   ? terrain_number(plrtile-terrain)
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] borders and fog of war

2008-07-25 Thread Madeline Book
On 7/25/08, Daniel Markstedt [EMAIL PROTECTED] wrote:
 On Fri, 25 Jul 2008 19:02:47 +0900, Per Inge Mathisen
  [EMAIL PROTECTED] wrote:

   On Thu, Jul 24, 2008 at 6:34 PM, Madeline Book [EMAIL PROTECTED]
   wrote:
   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.
  
   There was a suggestion some years(?) ago that players should have full
   vision inside their borders, to offset such information leakage. I
   think that is a reasonable idea.

It might be interesting to try this out, but it does not address the
problem that when someone finds the border edge, they get
extra information that someone has a city near there. I realize
this is hardly significant when playing with AIs or novice players,
but knowning where your opponent is (and without him knowing
that you know that) can be the difference between a win and a
loss for two expert human players.

There is also the issue that players can essentially see through
the fog since border information is sent even when a tile is
fogged. So for example they can see when a city changes owner
by the changing of the border around the city tile.

   (Also, I would like borders to be fogged like units and cities
   too, but that is an issue for another ticket...)
  
   You mean last seen borders would be remembered by the player,
   instead of being given as it really is? IIRC, and this starts being
   quite a while ago, the first borders implementation was like this. It
   was a horrible mess. I do not think you want to go back there. What
   problem would this solve, in any case?
  
 - Per
  


 I remember a time (sometime in early 2.1 alpha) when we had this
  implementation - it was above all a visual mess. You had to constantly go
  and re-explore the surrounding terrain to 'clean up' the border residue
  cluttering the view.

  Instead I would suggest simply not displaying borders of hostile players
  at all in fogged tiles. This would remedy the multiplayer balance issue,
  while still giving some idea of the political layout of the world since
  you can always see the borders of friendly players.

This is one way it could be handled I suppose. My own idea would
be to only send updated border information when the unit sees the
source of that border (a city or fortress I presume). This would avoid
the visual mess of partial seen borders (at least to the granularity
of sources rather than individual tiles) and not give extra hints to
attackers.


--
手を打とうとしましたが、貧乏なので難しい事になってしまいました。

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


[Freeciv-Dev] (PR#40404) [Patch] AI: improvement_effect_value() considers affected unit classes

2008-07-25 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40404 

 For number of effect types, check limitations on affected unit classes.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c 2008-07-18 22:08:33.0 +0300
+++ freeciv/ai/aicity.c 2008-07-25 23:09:15.0 +0300
@@ -339,8 +339,49 @@
   return v;
 }
 
+/**
+  Unit class affected by this effect.
+**/
+static struct unit_class *affected_unit_class(const struct effect *peffect)
+{
+  requirement_list_iterate(peffect-reqs, preq) {
+if (preq-source.kind == VUT_UCLASS) {
+  return preq-source.value.uclass;
+}
+  } requirement_list_iterate_end;
 
-/** 
+  return NULL;
+}
+
+/**
+  Number of AI stats units affected by effect
+**/
+static int num_affected_units(const struct effect *peffect,
+  const struct ai_data *ai)
+{
+  struct unit_class *uclass;
+  enum unit_move_type move;
+
+  uclass = affected_unit_class(peffect);
+  if (uclass) {
+move = uclass_move_type(uclass);
+switch (move) {
+ case LAND_MOVING:
+ return ai-stats.units.land;
+ case SEA_MOVING:
+   return ai-stats.units.sea;
+ case HELI_MOVING:
+ case AIR_MOVING:
+   return ai-stats.units.amphibious;
+ case MOVETYPE_LAST:
+   break;
+}
+  }
+  return ai-stats.units.land + ai-stats.units.sea
+ + ai-stats.units.amphibious;
+}
+
+/**
   How desirable is a particular effect for a particular city?
   Expressed as an adjustment of the base value (v)
   given the number of cities in range (c).
@@ -357,6 +398,9 @@
int v)
 {
   int amount = peffect-value;
+  struct unit_class *uclass;
+  enum unit_move_type move;
+  int num;
 
   switch (peffect-type) {
   /* These (Wonder) effects have already been evaluated in base_want() */
@@ -556,27 +600,24 @@
 /* Uhm, problem: City Wall has -50% here!! */
 break;
   case EFT_MOVE_BONUS:
-/* FIXME: check other reqs (e.g., unitclass) */
-v += (8 * v * amount + ai-stats.units.land
- + ai-stats.units.sea + ai-stats.units.amphibious);
+num = num_affected_units(peffect, ai);
+v += (8 * v * amount + num);
 break;
   case EFT_UNIT_NO_LOSE_POP:
 v += unit_list_size(pcity-tile-units) * 2;
 break;
   case EFT_HP_REGEN:
-/* FIXME: check other reqs (e.g., unitclass) */
-v += (5 * c + ai-stats.units.land
- + ai-stats.units.sea + ai-stats.units.amphibious);
+num = num_affected_units(peffect, ai);
+v += (5 * c + num);
 break;
   case EFT_VETERAN_COMBAT:
-/* FIXME: check other reqs (e.g., unitclass) */
-v += (2 * c + ai-stats.units.land + ai-stats.units.sea
- + ai-stats.units.amphibious);
+num = num_affected_units(peffect, ai);
+v += (2 * c + num);
 break;
   case EFT_VETERAN_BUILD:
-/* FIXME: check other reqs (e.g., unitclass, unitflag) */
-v += (3 * c + ai-stats.units.land + ai-stats.units.sea
- + ai-stats.units.amphibious);
+/* FIXME: check other reqs (e.g., unitflag) */
+num = num_affected_units(peffect, ai);
+v += (3 * c + num);
 break;
   case EFT_UPGRADE_UNIT:
 if (amount == 1) {
@@ -591,28 +632,38 @@
 if (ai_handicap(pplayer, H_DEFENSIVE)) {
   v += amount / 10; /* make AI slow */
 }
-if (is_ocean_tile(pcity-tile)) {
-  v += ai-threats.ocean[-tile_continent(pcity-tile)]
-   ? amount/5 : amount/20;
-} else {
-  adjc_iterate(pcity-tile, tile2) {
-   if (is_ocean_tile(tile2)) {
- if (ai-threats.ocean[-tile_continent(tile2)]) {
-   v += amount/5;
-   break;
- }
-   }
-  } adjc_iterate_end;
+uclass = affected_unit_class(peffect);
+if (uclass) {
+  move = uclass_move_type(uclass);
 }
-v += (amount/20 + ai-threats.invasions - 1) * c; /* for wonder */
-if (ai-threats.continent[tile_continent(pcity-tile)]
-   || capital
-   || (ai-threats.invasions
-is_water_adjacent_to_tile(pcity-tile))) {
-  if (ai-threats.continent[tile_continent(pcity-tile)]) {
-   v += amount;
+
+if (uclass == NULL || move == SEA_MOVING) {
+  /* Helps against sea units */
+  if (is_ocean_tile(pcity-tile)) {
+v += ai-threats.ocean[-tile_continent(pcity-tile)]
+  ? amount/5 : amount/20;
   } else {
-   v += amount / (!ai-threats.igwall ? (15 - capital * 5) : 15);
+adjc_iterate(pcity-tile, tile2) {
+  if (is_ocean_tile(tile2)) {
+if (ai-threats.ocean[-tile_continent(tile2)]) {

[Freeciv-Dev] (PR#40405) [Patch] IPv6: Use getnameinfo() to get information about incoming connections

2008-07-25 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40405 

 $subject


 - ML

diff -Nurd -X.diff_ignore freeciv/client/servers.c freeciv/client/servers.c
--- freeciv/client/servers.c2008-07-25 00:24:56.0 +0300
+++ freeciv/client/servers.c2008-07-26 00:33:14.0 +0300
@@ -642,7 +642,6 @@
 {
   socklen_t fromlen;
   union my_sockaddr fromend;
-  struct hostent *from;
   char msgbuf[128];
   int type;
   struct data_in din;
@@ -680,9 +679,40 @@
 dio_get_string(din, message, sizeof(message));
 
 if (!mystrcasecmp(none, servername)) {
+  bool nameinfo = FALSE;
+#ifdef IPV6_SUPPORT
+  char dst[INET6_ADDRSTRLEN];
+  char host[NI_MAXHOST], service[NI_MAXSERV];
+
+  if (!getnameinfo(fromend.saddr, fromlen, host, NI_MAXHOST,
+   service, NI_MAXSERV, NI_NUMERICSERV)) {
+nameinfo = TRUE;
+  }
+  if (!nameinfo) {
+if (fromend.saddr.sa_family == AF_INET6) {
+  inet_ntop(AF_INET6, fromend.saddr_in6.sin6_addr,
+dst, sizeof(dst));
+} else {
+  inet_ntop(AF_INET, fromend.saddr_in4.sin_addr, dst, sizeof(dst));;
+}
+  }
+#else  /* IPv6 support */
+  const char *dst;
+  struct hostent *from;
+  char *host = NULL;
+
   from = gethostbyaddr((char *) fromend.saddr_in4.sin_addr,
   sizeof(fromend.saddr_in4.sin_addr), AF_INET);
-  sz_strlcpy(servername, inet_ntoa(fromend.saddr_in4.sin_addr));
+  if (from) {
+host = from-h_name;
+nameinfo = TRUE;
+  }
+  if (!nameinfo) {
+dst = inet_ntoa(fromend.saddr_in4.sin_addr);
+  }
+#endif /* IPv6 support */
+
+  sz_strlcpy(servername, nameinfo ? host : dst);
 }
 
 /* UDP can send duplicate or delayed packets. */
diff -Nurd -X.diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac2008-07-18 19:24:53.0 +0300
+++ freeciv/configure.ac2008-07-26 00:29:01.0 +0300
@@ -81,7 +81,8 @@
   *)   AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
 esac], [ipv6=no])
 if test x$ipv6 != xno ; then
-  AC_CHECK_FUNCS([gethostbyname2 inet_pton inet_ntop], [ipv6_possible=true], [
+  AC_CHECK_FUNCS([gethostbyname2 inet_pton inet_ntop getnameinfo],
+[ipv6_possible=true], [
 if test x$ipv6 = xyes || x$ipv6 = xsupport ; then
   AC_MSG_ERROR([Cannot enable IPv6 functionality])
 fi ])
@@ -92,8 +93,6 @@
   AC_DEFINE([IPV6_USED], [1], [IPv6 Used])
 fi
   fi
-  dnl Non-critical functions
-  AC_CHECK_FUNCS([getnameinfo])
 fi
 
 AC_ARG_WITH(readline,
diff -Nurd -X.diff_ignore freeciv/server/sernet.c freeciv/server/sernet.c
--- freeciv/server/sernet.c 2008-07-25 00:24:56.0 +0300
+++ freeciv/server/sernet.c 2008-07-26 00:29:59.0 +0300
@@ -821,7 +821,15 @@
 
   int new_sock;
   union my_sockaddr fromend;
+  bool nameinfo = FALSE;
+#ifdef IPV6_SUPPORT
+  char host[NI_MAXHOST], service[NI_MAXSERV];
+  char dst[INET6_ADDRSTRLEN];
+#else  /* IPv6 support */
   struct hostent *from;
+  char *host = NULL;
+  const char *dst;
+#endif /* IPv6 support */
 
   fromlen = sizeof(fromend);
 
@@ -830,14 +838,30 @@
 return -1;
   }
 
+#ifdef IPV6_SUPPORT
+  if (!getnameinfo(fromend.saddr, fromlen, host, NI_MAXHOST,
+   service, NI_MAXSERV, NI_NUMERICSERV)) {
+nameinfo = TRUE;
+  }
+  if (fromend.saddr.sa_family == AF_INET6) {
+inet_ntop(AF_INET6, fromend.saddr_in6.sin6_addr,
+  dst, sizeof(dst));
+  } else {
+inet_ntop(AF_INET, fromend.saddr_in4.sin_addr, dst, sizeof(dst));
+  }
+#else  /* IPv6 support */
   from =
-  gethostbyaddr((char *) fromend.saddr_in4.sin_addr,
-   sizeof(fromend.saddr_in4.sin_addr), AF_INET);
+gethostbyaddr((char *) fromend.saddr_in4.sin_addr,
+  sizeof(fromend.saddr_in4.sin_addr), AF_INET);
+  if (from) {
+host = from-h_name;
+nameinfo = TRUE;
+  }
+  dst = inet_ntoa(fromend.saddr_in4.sin_addr);
+#endif /* IPv6 support */
 
   return server_make_connection(new_sock,
-   (from ? from-h_name
- : inet_ntoa(fromend.saddr_in4.sin_addr)),
-   inet_ntoa(fromend.saddr_in4.sin_addr));
+   (nameinfo ? host : dst), dst);
 }
 
 /
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev