Re: [Freeciv-Dev] (PR#38558) [patch] client segfault during automove with 30 players and 2 pirates

2007-08-12 Thread Marko Lindqvist

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

On 21/03/07, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 If the player list is full (all player and pirate slots full) the client may 
 crash during automove phase.  This is caused by the server reporting phase 32 
 (which is invalid).

 So far I have been unable to reproduce this. Found no errors by
looking server sources either.
 Can you give me more detailed instructions on how to reproduce. If
you have savegame from which this can be reproduced, please send it to
me.
 Of course we should add client end sanity check for phase number, but
core bug here is that server is sending illegal phase number in the
first place.


 - ML



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


Re: [Freeciv-Dev] (PR#38558) [patch] client segfault during automove with 30 players and 2 pirates

2007-08-12 Thread Marko Lindqvist

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

On 12/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote:

  So far I have been unable to reproduce this. Found no errors by
 looking server sources either.
  Can you give me more detailed instructions on how to reproduce. If
 you have savegame from which this can be reproduced, please send it to
 me.

 Attached related patches for S2_1 and trunk. S2_1 just adds client
side legality check for phase number. Trunk version adds several
asserts to help finding root cause bug.
 These do not remove need to find root cause bug.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-06 18:09:20.0 +0300
+++ freeciv/client/packhand.c	2007-08-07 11:47:08.0 +0300
@@ -861,6 +861,14 @@
 **/
 void handle_start_phase(int phase)
 {
+  assert(phase = 0  phase  game.info.nplayers);
+
+  if (phase  0 || phase = game.info.nplayers) {
+/* Illegal phase */
+freelog(LOG_ERROR, Illegal phase %d received from server!, phase);
+return;
+  }
+
   game.info.phase = phase;
 
   if (game.player_ptr  is_player_phase(game.player_ptr, phase)) {
@@ -1382,6 +1390,7 @@
   bool boot_help;
   bool update_aifill_button = FALSE;
 
+  assert(game.info.nplayers = MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS);
 
   if (game.info.aifill != pinfo-aifill) {
 update_aifill_button = TRUE;
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c	2007-08-07 00:07:45.0 +0300
+++ freeciv/server/srv_main.c	2007-08-07 11:47:44.0 +0300
@@ -557,6 +557,7 @@
   if (game.info.simultaneous_phases) {
 game.info.num_phases = 1;
   } else {
+assert(game.info.nplayers = MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS);
 game.info.num_phases = game.info.nplayers;
   }
   send_game_info(NULL);
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-11 12:17:15.0 +0300
+++ freeciv/client/packhand.c	2007-08-12 12:46:16.0 +0300
@@ -881,6 +881,13 @@
 **/
 void handle_start_phase(int phase)
 {
+
+  if (phase  0 || phase = game.info.nplayers) {
+/* Illegal phase */
+freelog(LOG_ERROR, Illegal phase %d received from server!, phase);
+return;
+  }
+
   game.info.phase = phase;
 
   if (game.player_ptr  is_player_phase(game.player_ptr, phase)) {
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#10416) RT does not show search results

2007-08-12 Thread Marko Lindqvist

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

At times this can be very annoying

Following search founds currently 104 results. By clicking 'Next page'
you should get results 50-99. None of them is visible (it claims to be
showing results 50-99, though)
http://bugs.freeciv.org/Search/Listing.html?Bookmark=FrT%3B%402%7C%252%7C%242%7C20%2510%7C%2411%7CDESCRIPTION%245%7CFIELD%248%7COPERATOR%244%7CTYPE%245%7CVALUE%2419%7CRequestor%20LIKE%20book%249%7CRequestor%244%7CLIKE%249%7CRequestor%244%7Cbook%242%7C21TicketsSortBy=idTicketsSortOrder=ASCRowsPerPage=50


 - ML



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


[Freeciv-Dev] (PR#39542) Cities Build too Many Expensive Buildings

2007-08-12 Thread [EMAIL PROTECTED]

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

Hi

Ive noticed that later on in a game, the AI's start to build Airports,
lots of Airports, and other expensive buildings - especially in rndCiv
where there can be so many more expensive buildings available.

This is ok, until the Nation has put one Airport in every town, even
when the towns are 3 squares away and connected by railway, in the
middle of a island, a very long way away from any enemy.

Ive found that this causes taxes to overtime got to 100% and science
output disappears.  The effect of this is that the AI's get to a certain
tech level and then stagnate.

The solution is prolly quite complex, but the AI needs to penalize
building too many expensive to maintain buildings.  This means taking
into account what other cities are doing.

Rough suggestions...
  * (where C = yearly building maintenance cost)
allow AI to build in 1/C cities, So All cities can build 1gold
buildings, but only 1/3 of cities build a 3gold airport.
This is fairly arbitrary, but may get the AI out of the trap.

  * decrease want by some formula, that takes into account...
 - how useful building is
 - how expensive the building is to maintain
 - how much income the city produces
 - how may other cities nearby have this building

-billy



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


[Freeciv-Dev] (PR#39543) Cities compete over Small Wonders

2007-08-12 Thread [EMAIL PROTECTED]

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

Hi

rndCiv uses Small Wonders, for things like Colleges of Magic
that can produce Magicians etc.  Often these units are Unique.

What ive found is that the AI will build a Small Wonder, build
the specialty unit, and then other cities in the same nation
will start building that Small Wonder, If they succeed the new
Small Wonder destroys the old one.

What often ends up happening is that many cities spend huge amounts
of resources rebuilding the Small Wonder, that they a) never really
build anything else, and b) the units that the Small Wonder allows
never have a chance to get built.

My suggestion for the AI code...  If a Nation already has a Small
Wonder, don't rebuild it anywhere else, that's the easy fix, and it'll
prolly be right 99% of the time.

-billy



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


[Freeciv-Dev] (PR#39546) [Bug] Internal server crashes for chatline save with path

2007-08-12 Thread Marko Lindqvist

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

 Server started internally crash for chatline '/save ~/.freeciv/test'.
 (Client says Lost connection to server)

 - Standalone server does not crash in similar situation.
 - Internal server does not crash with '/save test'



 - ML



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


Re: [Freeciv-Dev] (PR#38245) [Bug] Sun Tzu always marked redundant

2007-08-12 Thread Marko Lindqvist

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

On 04/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote:

 On 16/03/07, Marko Lindqvist [EMAIL PROTECTED] wrote:
 
   Sun Tzu's War Academy is always displayed as redundant.
 
   I think this relates to the fact that its effects have nreq UnitFlag 
  Diplomat.

 This new version for S2_1 keeps changes to AI behavior minimal.

 In other words: We fix user visible part of the Sun Tzu problem
(client marking it as redundant), but not AI part (AI still thinks Sun
Tzu redundant). It is simply too risky to introduce such AI changes to
S2_1. Even in this reduced form AI behavior has been changed more than
is good for stable branch.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c	2007-07-04 14:04:26.0 +0300
+++ freeciv/ai/aicity.c	2007-08-12 14:47:34.0 +0300
@@ -310,7 +310,10 @@
 
 if (is_effect_disabled(pplayer, pcity, pimpr,
 			   NULL, NULL, NULL, NULL,
-			   peffect)) {
+ 			   peffect, RPT_POSSIBLE)) {
+
+  /* TODO: Select between RPT_POSSIBLE and RPT_CERTAIN dynamically
+   * depending how much AI can take risks. */
   CITY_LOG(LOG_DEBUG, pcity, %s has a disabled effect: %s, 
improvement_rule_name(id),
effect_type_name(peffect-type));
@@ -328,7 +331,7 @@
 continue;
   }
   if (!is_req_active(pplayer, pcity, pimpr, NULL, NULL, NULL, NULL,
-			 preq)) {
+			 preq, RPT_POSSIBLE)) {
 	useful = FALSE;
 	break;
   }
@@ -830,7 +833,8 @@
  wonder_city-production.value)
  !improvement_obsolete(pplayer, wonder_city-production.value)
  !is_building_replaced(wonder_city, 
- wonder_city-production.value))
+ wonder_city-production.value,
+ RPT_POSSIBLE))
   || wonder_city == NULL) {
 /* Find a new wonder city! */
 int best_candidate_value = 0;
@@ -899,7 +903,7 @@
   }
   if (city_got_building(pcity, id)
   || !can_build_improvement(pcity, id)
-  || is_building_replaced(pcity, id)) {
+  || is_building_replaced(pcity, id, RPT_POSSIBLE)) {
 continue; /* Don't build redundant buildings */
   }
   adjust_building_want_by_effects(pcity, id);
@@ -1363,7 +1367,7 @@
 if(can_city_sell_building(pcity, i) 
 !building_has_effect(i, EFT_DEFEND_BONUS)
 	  /* selling city walls is really, really dumb -- Syela */
-(is_building_replaced(pcity, i)
+(is_building_replaced(pcity, i, RPT_CERTAIN)
 	   || building_unwanted(city_owner(pcity), i))) {
   do_sell_building(pplayer, pcity, i);
   notify_player(pplayer, pcity-tile, E_IMP_SOLD,
diff -Nurd -X.diff_ignore freeciv/client/citydlg_common.c freeciv/client/citydlg_common.c
--- freeciv/client/citydlg_common.c	2007-07-04 14:04:27.0 +0300
+++ freeciv/client/citydlg_common.c	2007-08-12 14:09:37.0 +0300
@@ -321,7 +321,7 @@
   my_snprintf(buf[0], column_size, improvement_name_translation(target.value));
 
   /* from city.c get_impr_name_ex() */
-  if (pcity  is_building_replaced(pcity, target.value)) {
+  if (pcity  is_building_replaced(pcity, target.value, RPT_CERTAIN)) {
 	my_snprintf(buf[1], column_size, *);
   } else {
 	const char *state = ;
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/wldlg.c freeciv/client/gui-gtk-2.0/wldlg.c
--- freeciv/client/gui-gtk-2.0/wldlg.c	2007-07-04 14:04:26.0 +0300
+++ freeciv/client/gui-gtk-2.0/wldlg.c	2007-08-12 14:09:37.0 +0300
@@ -1013,7 +1013,9 @@
 if (!target.is_unit  *pcity) {
   plr = city_owner(*pcity);
   useless = improvement_obsolete(plr, target.value)
-	|| is_building_replaced(*pcity, target.value);
+	|| is_building_replaced(*pcity, target.value, RPT_CERTAIN);
+  /* Mark building redundant if we are really certain that there is
+   * no use for it. */
   g_object_set(rend, strikethrough, useless, NULL);
 } else {
   g_object_set(rend, strikethrough, FALSE, NULL);
diff -Nurd -X.diff_ignore freeciv/client/repodlgs_common.c freeciv/client/repodlgs_common.c
--- freeciv/client/repodlgs_common.c	2007-07-04 14:04:27.0 +0300
+++ freeciv/client/repodlgs_common.c	2007-08-12 14:09:37.0 +0300
@@ -334,7 +334,7 @@
 if (!pcity-did_sell  city_got_building(pcity, impr)
 	 (!obsolete_only
 	|| improvement_obsolete(game.player_ptr, impr)
-	|| is_building_replaced(pcity, impr))) {
+	|| is_building_replaced(pcity, impr, RPT_CERTAIN))) {
   count++;
   gold += impr_sell_gold(impr);
   city_sell_improvement(pcity, impr);
diff -Nurd -X.diff_ignore freeciv/common/city.c freeciv/common/city.c
--- freeciv/common/city.c	2007-07-04 14:04:25.0 +0300
+++ freeciv/common/city.c	2007-08-12 14:09:37.0 +0300
@@ -347,7 +347,8 @@
 
 if (improvement_obsolete(pplayer, id)) {
   state = Q_(?obsolete:O);
- 

Re: [Freeciv-Dev] (PR#39542) Cities Build too Many Expensive Buildings

2007-08-12 Thread Marko Lindqvist

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

On 12/08/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 This is ok, until the Nation has put one Airport in every town, even
 when the towns are 3 squares away and connected by railway, in the
 middle of a island, a very long way away from any enemy.

 Known bug with Airports is that AI considers them Barracks - and yet
it does not think them redundant if city already has Barracks and Port
Facility (another building considered Barracks).

 There is FIXME: comment in aicity.c:improvement_effect_value():562:
  case EFT_VETERAN_BUILD:
/* FIXME: check other reqs (e.g., unitclass, unitflag) */


 - ML



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


Re: [Freeciv-Dev] (PR#39543) Cities compete over Small Wonders

2007-08-12 Thread Marko Lindqvist

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

On 12/08/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 My suggestion for the AI code...  If a Nation already has a Small
 Wonder, don't rebuild it anywhere else, that's the easy fix, and it'll
 prolly be right 99% of the time.

 Attached patch should do just that. Untested.

 This of course prevents moving palace in default ruleset. I don't
know how good decisions AI has been doing about moving palace. If it
has been random thing, this patch would actually be improvement for
default ruleset too...
 Per?


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c	2007-08-11 00:20:33.0 +0300
+++ freeciv/ai/aicity.c	2007-08-12 16:44:12.0 +0300
@@ -219,7 +219,8 @@
 return 0; /* Nothing to calculate here. */
   }
 
-  if (!can_build_improvement(pcity, id)) {
+  if (!can_build_improvement(pcity, id)
+  || (is_small_wonder(id)  find_city_from_small_wonder(pplayer, id))) {
 return 0;
   }
 
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39548) [Patch] Fix sernet.c compiler warning

2007-08-12 Thread Marko Lindqvist

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

 This fixes warning when neither SOCKET_ZERO_ISNT_STDIN nor
HAVE_READLINE is defined.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/sernet.c freeciv/server/sernet.c
--- freeciv/server/sernet.c	2007-08-04 18:36:24.0 +0300
+++ freeciv/server/sernet.c	2007-08-12 20:15:54.0 +0300
@@ -131,6 +131,9 @@
 
 static bool no_input = FALSE;
 
+/* Avoid compiler warning about defined, but unused function
+ * by defining it only when needed */
+#if !defined(SOCKET_ZERO_ISNT_STDIN)  !defined(HAVE_READLINE)
 /*
   This happens if you type an EOF character with nothing on the current line.
 */
@@ -142,9 +145,11 @@
 #ifndef SOCKET_ZERO_ISNT_STDIN
   freelog(LOG_NORMAL, _(Server cannot read standard input. Ignoring input.));
   no_input = TRUE;
-#endif
+#endif /* SOCKET_ZERO_ISNT_STDIN */
 }
 
+#endif /* !SOCKET_ZERO_ISNT_STDIN  !HAVE_READLINE */
+
 #ifdef HAVE_LIBREADLINE
 //
 
@@ -574,11 +579,11 @@
 if (!no_input) {
 #ifdef SOCKET_ZERO_ISNT_STDIN
   my_init_console();
-#else
+#else /* SOCKET_ZERO_ISNT_STDIN */
 #   if !defined(__VMS)
   FD_SET(0, readfs);
-#   endif	
-#endif
+#   endif /* VMS */	
+#endif /* SOCKET_ZERO_ISNT_STDIN */
 }
 
 if (with_ggz) {
@@ -587,7 +592,7 @@
 
   FD_SET(ggz_sock, readfs);
   max_desc = MAX(sock, ggz_sock);
-#endif
+#endif /* GGZ_SERVER */
 } else {
   FD_SET(sock, readfs);
   FD_SET(sock, exceptfs);
@@ -680,7 +685,7 @@
 	input_from_ggz(ggz_sock);
   }
 }
-#endif
+#endif /* GGZ_SERVER */
 
 #ifdef SOCKET_ZERO_ISNT_STDIN
 if (!no_input  (bufptr = my_read_console())) {
@@ -800,9 +805,9 @@
* it should be done with a configure check not a platform check. */
 #ifdef HAVE_SOCKLEN_T
   socklen_t fromlen;
-#else
+#else /* HAVE_SOCKLEN_T */
   int fromlen;
-#endif
+#endif /* HAVE_SOCKLEN_T */
 
   int new_sock;
   union my_sockaddr fromend;
@@ -977,7 +982,7 @@
 status = sys$assign(tt_desc,tt_chan,0,0);
 if (!$VMS_STATUS_SUCCESS(status)) lib$stop(status);
   }
-#endif
+#endif /* VMS */
 }
 
 /**
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39550) [Patch] Resurrect --disable-nls

2007-08-12 Thread Marko Lindqvist

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

 AM_GLIB_GNU_GETTEXT does not provide --disable-nls. Attached patch
adds it to our own configure.ac.
 Not tested in any system where gettext is not available at all.


 - ML

diff -Nurd -X.diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac	2007-08-09 11:35:00.0 +0300
+++ freeciv/configure.ac	2007-08-12 21:04:43.0 +0300
@@ -190,14 +190,23 @@
 dnl I18n support
 ALL_LINGUAS=ar cs ca da de el en_GB es et fa fi fr he hu it ja lt nl nb 
 no pl pt pt_BR ro ru sv uk zh_CN
-AM_GLIB_GNU_GETTEXT
 
-dnl AM_GLIB_GNU_GETTEXT doesn't have all features we want
-dnl or they don't behave correctly.
-dnl Old gettext binaries don't understand plurals. (ngettext, msgid_plural)
-dnl and there are some problems with missing ngettext.
+AC_ARG_ENABLE([nls],
+[  --disable-nlsdo not use add localization support],
+[case ${enableval} in
+  yes) USE_NLS=yes ;;
+  no)  USE_NLS=no ;;
+  *)   AC_MSG_ERROR([bad value ${enableval} for --disable-nls]) ;;
+esac], [USE_NLS=yes])
 
-if test $USE_NLS = yes; then
+if test $USE_NLS = yes ; then
+  AM_GLIB_GNU_GETTEXT
+
+  dnl AM_GLIB_GNU_GETTEXT doesn't have all features we want
+  dnl or they don't behave correctly.
+  dnl Old gettext binaries don't understand plurals. (ngettext, msgid_plural)
+  dnl and there are some problems with missing ngettext.
+  dnl Is that ngettext part still true? AM_GLIB_GNU_GETTEXT does check for it
 
   have_working_ngettext=0
   AC_CHECK_LIB(c, ngettext,
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#17793) Wait cursor and non-simultaneous movement (gtk2 client, trunk)

2007-08-12 Thread Marko Lindqvist

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

On 05/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote:
 On 10/06/06, Andreas Røsdal [EMAIL PROTECTED] wrote:
 
  On Sat, 10 Jun 2006, Per I. Mathisen wrote:
set simultaneousphases 0
  
   Now the wait cursor appears whenever you press 'end turn' to indicate that
   you are done moving. However, you may still want to set gotos or change
   city production, which it would be nice to have a normal cursor for.
 
  This patch sets the wait cursor to only replace the default cursor
  between turns.

  Um, no.

 But this patch does.

 I had to introduce new packets END_TURN and BEGIN_TURN. So this one
is suitable for trunk only, for S2_1 version capability checks have to
be added.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c	2007-08-12 21:14:05.0 +0300
+++ freeciv/client/civclient.c	2007-08-12 22:59:43.0 +0300
@@ -99,6 +99,11 @@
  */
 bool turn_done_sent = FALSE;
 
+/*
+ * TRUE between receiving PACKET_END_TURN and PACKET_BEGIN_TURN
+ */
+static bool server_busy = FALSE;
+
 /**
   Convert a text string from the internal to the data encoding, when it
   is written to the network.
@@ -758,3 +763,26 @@
 	   (get_client_state() == CLIENT_GAME_RUNNING_STATE
 	  || get_client_state() == CLIENT_GAME_OVER_STATE));
 }
+
+/**
+  Sets if server is considered busy. Currently it is considered busy
+  between turns.
+**/
+void set_server_busy(bool busy)
+{
+  if (busy != server_busy) {
+/* server_busy value will change */
+server_busy = busy;
+
+/* This may mean that we have to change from or to wait cursor */
+handle_mouse_cursor(NULL);
+  }
+}
+
+/**
+  Returns if server is considered busy at the moment
+**/
+bool is_server_busy(void)
+{
+  return server_busy;
+}
diff -Nurd -X.diff_ignore freeciv/client/civclient.h freeciv/client/civclient.h
--- freeciv/client/civclient.h	2007-08-04 18:39:15.0 +0300
+++ freeciv/client/civclient.h	2007-08-12 22:56:33.0 +0300
@@ -36,6 +36,8 @@
 
 void set_client_state(enum client_states newstate);
 enum client_states get_client_state(void);
+void set_server_busy(bool busy);
+bool is_server_busy(void);
 
 void client_remove_cli_conn(struct connection *pconn);
 void client_remove_all_cli_conn(void);
diff -Nurd -X.diff_ignore freeciv/client/control.c freeciv/client/control.c
--- freeciv/client/control.c	2007-08-05 16:40:59.0 +0300
+++ freeciv/client/control.c	2007-08-12 23:00:23.0 +0300
@@ -890,7 +890,8 @@
 return;
   }
 
-  if (turn_done_sent || waiting_for_end_turn) {
+  if (is_server_busy()) {
+/* Server will not accept any commands. */
 update_mouse_cursor(CURSOR_WAIT);
 return;
   }
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-12 21:14:05.0 +0300
+++ freeciv/client/packhand.c	2007-08-12 22:55:16.0 +0300
@@ -183,7 +183,8 @@
 aconnection.id = conn_id;
 agents_game_joined();
 update_menus();
-
+
+set_server_busy(FALSE);
 
 if (get_client_page() == PAGE_MAIN
 	|| get_client_page() == PAGE_NETWORK
@@ -388,8 +389,13 @@
 update_unit_info_label(NULL); 
   }
 
-  if (changed  can_client_change_view()) {
-update_map_canvas_visible();
+  if (changed) {
+if (can_client_change_view()) {
+  update_map_canvas_visible();
+}
+
+/* If turn was going to change, that is now aborted. */
+set_server_busy(FALSE);
   }
 }
 
@@ -893,6 +899,30 @@
 }
 
 /**
+  Called when begin-turn packet is received. Server has finished processing
+  turn change.
+**/
+void handle_begin_turn(void)
+{
+  freelog(LOG_DEBUG, handle_begin_turn());
+
+  /* Possibly replace wait cursor with something else */
+  set_server_busy(FALSE);
+}
+
+/**
+  Called when end-turn packet is received. Server starts processing turn
+  change.
+**/
+void handle_end_turn(void)
+{
+  freelog(LOG_DEBUG, handle_end_turn());
+
+  /* Make sure wait cursor is in use */
+  set_server_busy(TRUE);
+}
+
+/**
 ...
 **/
 void play_sound_for_event(enum event_type type)
diff -Nurd -X.diff_ignore freeciv/common/packets.def 

Re: [Freeciv-Dev] (PR#17793) Wait cursor and non-simultaneous movement (gtk2 client, trunk)

2007-08-12 Thread Marko Lindqvist

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

On 12/08/07, Marko Lindqvist [EMAIL PROTECTED] wrote:

  I had to introduce new packets END_TURN and BEGIN_TURN. So this one
 is suitable for trunk only, for S2_1 version capability checks have to
 be added.

 Here is version with capability checks.

 As our capability string is getting rather long even before first
release from this stable branch, I made capability just two letter
abbreviation.

 It turns out that cursor handling has changed a lot between S2_1 and
trunk. In S2_1 this patch does only bad things without additional
support code to every client.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c	2007-07-04 14:04:27.0 +0300
+++ freeciv/client/civclient.c	2007-08-12 23:09:46.0 +0300
@@ -101,6 +101,11 @@
  */
 bool turn_done_sent = FALSE;
 
+/*
+ * TRUE between receiving PACKET_END_TURN and PACKET_BEGIN_TURN
+ */
+static bool server_busy = FALSE;
+
 /**
   Convert a text string from the internal to the data encoding, when it
   is written to the network.
@@ -757,3 +762,26 @@
 	   (get_client_state() == CLIENT_GAME_RUNNING_STATE
 	  || get_client_state() == CLIENT_GAME_OVER_STATE));
 }
+
+/**
+  Sets if server is considered busy. Currently it is considered busy
+  between turns.
+**/
+void set_server_busy(bool busy)
+{
+  if (busy != server_busy) {
+/* server_busy value will change */
+server_busy = busy;
+
+/* This may mean that we have to change from or to wait cursor */
+handle_mouse_cursor(NULL);
+  }
+}
+
+/**
+  Returns if server is considered busy at the moment
+**/
+bool is_server_busy(void)
+{
+  return server_busy;
+}
diff -Nurd -X.diff_ignore freeciv/client/civclient.h freeciv/client/civclient.h
--- freeciv/client/civclient.h	2007-03-05 19:14:36.0 +0200
+++ freeciv/client/civclient.h	2007-08-12 23:09:46.0 +0300
@@ -34,6 +34,8 @@
 
 void set_client_state(enum client_states newstate);
 enum client_states get_client_state(void);
+void set_server_busy(bool busy);
+bool is_server_busy(void);
 
 void client_remove_cli_conn(struct connection *pconn);
 void client_remove_all_cli_conn(void);
diff -Nurd -X.diff_ignore freeciv/client/control.c freeciv/client/control.c
--- freeciv/client/control.c	2007-07-04 14:04:27.0 +0300
+++ freeciv/client/control.c	2007-08-12 23:36:14.0 +0300
@@ -884,6 +884,13 @@
   struct city *pcity = NULL;
   struct unit_list *active_units = get_units_in_focus();
 
+  if (is_server_busy()) {
+/* Server will not accept any commands. */
+action_state = CURSOR_ACTION_WAIT;
+update_unit_info_label(active_units);
+return;
+  }
+
   if (!ptile) {
 if (hover_tile) {
   /* hover_tile is the tile which is currently under the mouse cursor. */
diff -Nurd -X.diff_ignore freeciv/client/control.h freeciv/client/control.h
--- freeciv/client/control.h	2007-03-05 19:14:36.0 +0200
+++ freeciv/client/control.h	2007-08-12 23:26:14.0 +0300
@@ -31,7 +31,8 @@
   CURSOR_ACTION_INVALID,
   CURSOR_ACTION_ATTACK,
   CURSOR_ACTION_NUKE,
-  CURSOR_ACTION_PARATROOPER
+  CURSOR_ACTION_PARATROOPER,
+  CURSOR_ACTION_WAIT
 };
 
 /* Selecting unit from a stack without popup. */
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-11 12:17:15.0 +0300
+++ freeciv/client/packhand.c	2007-08-12 23:09:46.0 +0300
@@ -184,7 +184,8 @@
 aconnection.id = conn_id;
 agents_game_joined();
 update_menus();
-
+
+set_server_busy(FALSE);
 
 if (get_client_page() == PAGE_MAIN
 	|| get_client_page() == PAGE_NETWORK
@@ -389,8 +390,13 @@
 update_unit_info_label(NULL); 
   }
 
-  if (changed  can_client_change_view()) {
-update_map_canvas_visible();
+  if (changed) {
+if (can_client_change_view()) {
+  update_map_canvas_visible();
+}
+
+/* If turn was going to change, that is now aborted. */
+set_server_busy(FALSE);
   }
 }
 
@@ -913,6 +919,30 @@
 }
 
 /**
+  Called when begin-turn packet is received. Server has finished processing
+  turn change.
+**/
+void handle_begin_turn(void)
+{
+  freelog(LOG_DEBUG, handle_begin_turn());
+
+  /* Possibly replace wait cursor with something else */
+  set_server_busy(FALSE);
+}
+
+/**
+  Called when end-turn packet is received. Server starts processing turn
+  

[Freeciv-Dev] (PR#39551) [Patch] Fix ai_gothere_bodyguard() crash

2007-08-12 Thread Marko Lindqvist

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

 Another instance where enemy's inability to build anything caused crash.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aitools.c freeciv/ai/aitools.c
--- freeciv/ai/aitools.c	2007-07-04 14:04:26.0 +0300
+++ freeciv/ai/aitools.c	2007-08-13 00:17:33.0 +0300
@@ -238,9 +238,12 @@
 /* Assume enemy will build another defender, add it's attack strength */
 struct unit_type *d_type = ai_choose_defender_versus(dcity, unit_type(punit));
 
-danger += 
-  unittype_att_rating(d_type, do_make_unit_veteran(dcity, d_type), 
-  SINGLE_MOVE, d_type-hp);
+if (d_type) {
+  /* Enemy really can build something */
+  danger += 
+unittype_att_rating(d_type, do_make_unit_veteran(dcity, d_type), 
+SINGLE_MOVE, d_type-hp);
+}
   }
   danger *= POWER_DIVIDER;
 
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev