[Freeciv-Dev] (PR#40060) civserver core dump on debug command

2008-01-31 Thread Jason Short

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

This doesn't reliably crash for me either.  But the memory error is
obvious enough from the backtrace and shows up in valgrind.  This will
cause arbitrary memory reads every time /debug is done with no parameters.

Looks like this affects only 2.2/trunk.  This patch should fix it.

-jason

Index: server/stdinhand.c
===
--- server/stdinhand.c	(revision 14356)
+++ server/stdinhand.c	(working copy)
@@ -2390,7 +2390,7 @@
 } unit_list_iterate_end;
   } else if (ntokens  0  strcmp(arg[0], timing) == 0) {
 TIMING_RESULTS();
-  } else if (strcmp(arg[0], ferries) == 0) {
+  } else if (ntokens  0  strcmp(arg[0], ferries) == 0) {
 if (game.debug[DEBUG_FERRIES]) {
   game.debug[DEBUG_FERRIES] = FALSE;
   cmd_reply(CMD_DEBUG, caller, C_OK, _(Ferry system is no longer 
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40036) 2.1.2 savegame data loss on rapid saves

2008-01-31 Thread Martin Rubinstein

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


Further information - the problem is not in the basic Freeciv program, but in 
the Windows Vista distribution which automaticalloy sets certain defaults which 
cause errors.
   a) The switch to turn on AI after a player disconnects should default to OFF.
   b) The default to allow simultaneous player moves should be OFF.Thanks very 
much for all the help.
 
 Date: Tue, 29 Jan 2008 02:40:56 -0800
 Subject: Re: [Freeciv-Dev] (PR#40036) 2.1.2 savegame data loss on rapid 
 saves From: [EMAIL PROTECTED] To: [EMAIL PROTECTED]   URL: 
 http://bugs.freeciv.org/Ticket/Display.html?id=40036   Jason Dorje Short 
 wrote:  Unfortunately I don't seem to get this behavior anymore, though 
 people  keep reporting its symptoms. Every time I kill my client the 
 server  saves the game properly, without aitoggling the human.   That 
 supposedly was fixed, although I cannot find the PR# or the commit  
 common/game.h:297: #define GAME_DEFAULT_AUTO_AI_TOGGLE FALSE   Martin 
 Rubinstein wrote: # a) How do I set autosave to each turn. (It is hidden in 
 the easy distribution)  It's documented several ways, have you tried the 
 extensive Help menus?  The easiest is typing /saveturns 1 in the Chat 
 command line.  For the 2.1 GTK2 gui, you'll find it under menu Game - 
 Server Options - Internal - saveturns (Turns per auto-save)   # b) Is 
 there any easy wa!
 y of saving a list of further options, for use at each load.  There are 
several ways, have you tried Game - Save Options?   And while you are 
looking at Game - Server Options, you might check the value of Network - 
autotoggle (Whether AI-status toggles with connection)  We're speculating 
that you accidentally set it to On?  
_
New music from the Rogue Traders - listen now!
http://ninemsn.com.au/share/redir/adTrack.asp?mode=clickclientID=832referral=hotmailtaglineOct07URL=http://music.ninemsn.com.au/roguetraders



Further information - the problem is not in the basic Freeciv program, but in the Windows Vista distribution which automaticalloy sets certain defaults which cause errors.
 a) The switch to turn on AI after a player disconnects should default to OFF.
 b) The default to allow simultaneous player moves should be OFF.Thanks very much for all the help.

 Date: Tue, 29 Jan 2008 02:40:56 -0800
 Subject: Re: [Freeciv-Dev] (PR#40036) 2.1.2 savegame data loss on rapid saves From: [EMAIL PROTECTED] To: [EMAIL PROTECTED]   URL: http://bugs.freeciv.org/Ticket/Display.html?id=40036   Jason Dorje Short wrote:  Unfortunately I don't seem to get this behavior anymore, though people  keep reporting its symptoms. Every time I kill my client the server  saves the game properly, without aitoggling the human.   That supposedly was fixed, although I cannot find the PR# or the commit  common/game.h:297: #define GAME_DEFAULT_AUTO_AI_TOGGLE FALSE   Martin Rubinstein wrote: # a) How do I set autosave to each turn. (It is hidden in the easy distribution)  It's documented several ways, have you tried the extensive Help menus?  The easiest is typing /saveturns 1 in the Chat command line.  For the 2.1 GTK2 gui, you'll find it under menu Game - Server Options - Internal - saveturns ("Turns per auto-save")   # b) Is there any easy way of saving a list of further options, for use at each load.  There are several ways, have you tried Game - Save Options?   And while you are looking at Game - Server Options, you might check the value of Network - autotoggle ("Whether AI-status toggles with connection")  We're speculating that you accidentally set it to On?  Listen now! New music from the Rogue Traders.
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40057) strerror-mystrerror

2008-01-31 Thread Marko Lindqvist

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

On 27/01/2008, Jason Dorje Short [EMAIL PROTECTED] wrote:

 mystrerror is included in support.c.  Two places don't use this but
 access strerror directly.  This patch fixes it (for 2.1).

 That broke compilation.
 mystrerror() takes no arguments, but just uses errno  directly. I'll
fix compilation ASAP.


 I'd vote for changing mystrerror() to take error number as argument,
so it is possibly for caller to store errno and postpone mystrerror()
call without risking errno overwrite. All this in a fashion compatible
with Windows version of mystrerror(), of course.


 - ML



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


Re: [Freeciv-Dev] (PR#40063) RFE: increase historian levels to prime number

2008-01-31 Thread William Allen Simpson

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

Added +1 to ensure only top rank is rated Supreme (unless tied).
Added clamp to final entry.

Committed S2_2 revision 14364.
Committed trunk revision 14365.

Index: server/report.c
===
--- server/report.c (revision 14363)
+++ server/report.c (working copy)
@@ -149,39 +149,52 @@
   char key;
 } coltable[] = {{'q'}, {'r'}, {'b'}}; /* Corresponds to dem_flag enum */
 
-/**
-...
-**/
-static int secompare(const void *a, const void *b)
-{
-  return (((const struct player_score_entry *)b)-value -
- ((const struct player_score_entry *)a)-value);
-}
-
-static const char *greatness[] = {
-  /* TRANS: 1: The ranking Poles */
+/* prime number of entries makes for better scaling */
+static const char *ranking[] = {
+  /* TRANS: #: The ranking Poles */
+  N_(%2d: The Supreme %s),
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Magnificent %s),
-  /* TRANS: 2: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Great %s),
-  /* TRANS: 3: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Glorious %s),
-  /* TRANS: 4: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Excellent %s),
-  /* TRANS: 5: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
+  N_(%2d: The Eminent %s),
+  /* TRANS: #: The ranking Poles */
+  N_(%2d: The Distinguished %s),
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Average %s),
-  /* TRANS: 6: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Mediocre %s),
-  /* TRANS: 7: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
+  N_(%2d: The Ordinary %s),
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Pathetic %s),
-  /* TRANS: 8: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Useless %s),
-  /* TRANS: 9: The ranking Poles */
+  /* TRANS: #: The ranking Poles */
+  N_(%2d: The Valueless %s),
+  /* TRANS: #: The ranking Poles */
   N_(%2d: The Worthless %s),
+  /* TRANS: #: The ranking Poles */
+  N_(%2d: The Wretched %s),
 };
 
 /**
 ...
 **/
+static int secompare(const void *a, const void *b)
+{
+  return (((const struct player_score_entry *)b)-value -
+ ((const struct player_score_entry *)a)-value);
+}
+
+/**
+...
+**/
 static void historian_generic(enum historian_type which_news)
 {
   int i, j = 0, rank = 0;
@@ -219,18 +232,17 @@
   qsort(size, j, sizeof(size[0]), secompare);
   buffer[0] = '\0';
   for (i = 0; i  j; i++) {
-if (i == 0 || size[i].value  size[i - 1].value) {
-  if (i = sizeof(greatness)) {
-rank = sizeof(greatness) - 1;
-  } else if (j = sizeof(greatness)) {
-rank = i;
-  } else {
-rank = (i * sizeof(greatness)) / j;
-  }
+if (i  0  size[i].value  size[i - 1].value) {
+  /* since i  j, only top entry reigns Supreme */
+  rank = ((i * sizeof(ranking)) / j) + 1;
 }
+if (rank = sizeof(ranking)) {
+  /* clamp to final entry */
+  rank = sizeof(ranking) - 1;
+}
 cat_snprintf(buffer, sizeof(buffer),
-_(greatness[rank]),
-rank + 1,
+_(ranking[rank]),
+i + 1,
 nation_plural_for_player(size[i].player));
 mystrlcat(buffer, \n, sizeof(buffer));
   }
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40064) historian report passes NULL format to cat_snprintf()

2008-01-31 Thread William Allen Simpson

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

Jason Short wrote:
 Looks like this is cause by 40063.
 
That would be highly surprising, as PR#40063 had not been committed yet!

Anyway, I've just committed it minutes ago, and I'll do some testing now
with the savegame provided  Thanks!



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


Re: [Freeciv-Dev] (PR#40064) historian report passes NULL format to cat_snprintf()

2008-01-31 Thread William Allen Simpson

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

My trivial patch was only meant to change an existing array from sentence
fragments for easier translation.  Then, it ballooned from fixed size to
variable, and fancier, and

Used sizeof() instead of ARRAY_SIZE().  Fixed.

Excellent report with savegame!  Thanks!

Committed S2_2 revision 14366.
Committed trunk revision 14367.

Index: server/report.c
===
--- server/report.c (revision 14365)
+++ server/report.c (working copy)
@@ -234,11 +234,11 @@
   for (i = 0; i  j; i++) {
 if (i  0  size[i].value  size[i - 1].value) {
   /* since i  j, only top entry reigns Supreme */
-  rank = ((i * sizeof(ranking)) / j) + 1;
+  rank = ((i * ARRAY_SIZE(ranking)) / j) + 1;
 }
-if (rank = sizeof(ranking)) {
+if (rank = ARRAY_SIZE(ranking)) {
   /* clamp to final entry */
-  rank = sizeof(ranking) - 1;
+  rank = ARRAY_SIZE(ranking) - 1;
 }
 cat_snprintf(buffer, sizeof(buffer),
 _(ranking[rank]),
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40057) strerror-mystrerror

2008-01-31 Thread Jason Dorje Short

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

On Jan 31, 2008 8:35 AM, Marko Lindqvist [EMAIL PROTECTED] wrote:

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

 On 27/01/2008, Jason Dorje Short [EMAIL PROTECTED] wrote:
 
  mystrerror is included in support.c.  Two places don't use this but
  access strerror directly.  This patch fixes it (for 2.1).

  That broke compilation.
  mystrerror() takes no arguments, but just uses errno  directly. I'll
 fix compilation ASAP.


  I'd vote for changing mystrerror() to take error number as argument,
 so it is possibly for caller to store errno and postpone mystrerror()
 call without risking errno overwrite. All this in a fashion compatible
 with Windows version of mystrerror(), of course.

Wow, quite a typo for a 2-line patch.  My bad.

And yes, I agree with you; mystrerror should be a drop-in for
strerror.  The drawback is as you can see in mystrerror that windows
does not have the errno token IIRC.  At best we'd be looking at
something like myerrno and another poisoned token.

-jason



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


Re: [Freeciv-Dev] (PR#40062) server/stdinhand.c duplicates server/command.c text

2008-01-31 Thread William Allen Simpson

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

I looked at cmd_reply_prefix(), and chose not to use it for the Usage: lines.
It really isn't multi-lingual friendly.  Saved for another ticket.

I looked at command_named().  It should be re-written to be more like
find_player_by_name_prefix().  Saved for another ticket.

Committed trunk revision 14368.
Committed S2_2 revision 14369.



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


[Freeciv-Dev] (PR#40066) i18n: commands and settings text should work for LtR and RtL, and wordwrap

2008-01-31 Thread William Allen Simpson

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

In PR#40043, the disfunctional wordwrap was removed for server/stdinhand.c
(stdout) and others.

In PR#40062, the Usage: could sometimes use some wordwrap and prettifying.

Ideally, the server/commands.c and server/settings.c text should not have
their own \n, and should rely on the cmd_reply() and cmd_reply_prefix()
mechanisms to handle lines.

In civmanual, any \n should to be changed to br for html, but should
primarily rely on the browser for wordwrap.



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