Re: [Freeciv-Dev] (PR#40672) Configure fails on recent trunk

2009-01-22 Thread Marko Lindqvist

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

2009/1/22 Daniel Markstedt:
>
> trunk r15434 on OSX 10.3.9 fails with:
>
> "configure: error: Did not find math lib!"
>
> Full output attached as text file.

 config.log would be helpful.
 Also, can you pinpoint a bit which revision has broken this?


 - ML



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


[Freeciv-Dev] (PR#40674) [Patch] Fix: configure fails to find mysql libs from /usr/lib/mysql/

2009-01-22 Thread Marko Lindqvist

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

 If mysql libraries are not found from standard library directories,
configure never proceeds to searching them from alternative locations.

 Fix attached


 - ML

diff -Nurd -X.diff_ignore freeciv/m4/auth.m4 freeciv/m4/auth.m4
--- freeciv/m4/auth.m4  2009-01-22 11:38:32.0 +0200
+++ freeciv/m4/auth.m4  2009-01-22 17:54:45.0 +0200
@@ -33,20 +33,19 @@
[AC_MSG_WARN([couldn't find mysql libs in normal 
locations]);
 auth=false])
 
-  if test x$auth = x$true ; then
+  if test x$auth = xfalse ; then
 fc_preauth_LDFLAGS="$LDFLAGS"
 fc_mysql_lib_loc="-L/usr/lib/mysql -L/usr/local/lib/mysql"
 
 for __ldpath in $fc_mysql_lib_loc; do
   unset ac_cv_lib_mysqlclient_mysql_query
   LDFLAGS="$LDFLAGS $__ldpath"
-  auth=true
 
   AC_CHECK_LIB(mysqlclient, mysql_query,
[AUTH_LIBS="-lmysqlclient $AUTH_LIBS";
-AC_MSG_WARN([had to add $__ldpath to LDFLAGS])],
-[AC_MSG_WARN([couldn't find mysql libs in $__ldpath]);
- auth=false])
+AC_MSG_WARN([had to add $__ldpath to LDFLAGS])
+auth=true],
+[AC_MSG_WARN([couldn't find mysql libs in $__ldpath])])
 
   if test x$auth = xtrue; then
 break
@@ -54,6 +53,10 @@
 LDFLAGS="$fc_preauth_LDFLAGS"
   fi
 done
+
+if test x$auth = xfalse ; then
+  AC_MSG_ERROR([couldn't find mysql libs at all])
+fi
   fi
 else
   AUTH_CFLAGS="-I$mysql_prefix/include $AUTH_CFLAGS"
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40675) [Patch] Fix city dialog shortcut conflicts

2009-01-22 Thread Madeline Book

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

Conflicts in the gtk2 city dialog shortcuts were reported by
Susanna Björverud on freeciv-i18n. The attached patch fixes
all conflicts I could find within the city dialog and its
sub-tabs by re-assigning the mnemonic keys.


---
都市には、衝突がよくある。
 client/gui-gtk-2.0/citydlg.c |8 
 client/gui-gtk-2.0/cma_fe.c  |   15 +--
 client/gui-gtk-2.0/wldlg.c   |2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/client/gui-gtk-2.0/citydlg.c b/client/gui-gtk-2.0/citydlg.c
index 986a630..071afc9 100644
--- a/client/gui-gtk-2.0/citydlg.c
+++ b/client/gui-gtk-2.0/citydlg.c
@@ -842,7 +842,7 @@ static void create_and_append_overview_page(struct city_dialog *pdialog)
   label = g_object_new(GTK_TYPE_LABEL,
 		   "use-underline", TRUE,
 		   "mnemonic-widget", view,
-		   "label", _("_Improvements:"),
+		   "label", _("I_mprovements:"),
 		   "xalign", 0.0, "yalign", 0.5, NULL);
   gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
@@ -901,7 +901,7 @@ target_drag_data_received(GtkWidget *w, GdkDragContext *context,
 */
 static void create_and_append_worklist_page(struct city_dialog *pdialog)
 {
-  const char *tab_title = _("_Production");
+  const char *tab_title = _("P_roduction");
   GtkWidget *label = gtk_label_new_with_mnemonic(tab_title);
   GtkWidget *page, *hbox, *editor, *bar;
 
@@ -952,7 +952,7 @@ static void create_and_append_worklist_page(struct city_dialog *pdialog)
 static void create_and_append_happiness_page(struct city_dialog *pdialog)
 {
   GtkWidget *page, *vbox, *label, *table, *align;
-  const char *tab_title = _("_Happiness");
+  const char *tab_title = _("Happ_iness");
 
   page = gtk_hbox_new(FALSE, 6);
   gtk_container_set_border_width(GTK_CONTAINER(page), 8);
@@ -1119,7 +1119,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog)
   vbox2 = gtk_vbox_new(TRUE, 0);
   gtk_container_add(GTK_CONTAINER(frame), vbox2);
 
-  button = gtk_button_new_with_mnemonic(_("_Rename..."));
+  button = gtk_button_new_with_mnemonic(_("R_ename..."));
   pdialog->misc.rename_command = button;
   gtk_container_add(GTK_CONTAINER(vbox2), button);
   g_signal_connect(button, "clicked",
diff --git a/client/gui-gtk-2.0/cma_fe.c b/client/gui-gtk-2.0/cma_fe.c
index 14af71a..9b740c4 100644
--- a/client/gui-gtk-2.0/cma_fe.c
+++ b/client/gui-gtk-2.0/cma_fe.c
@@ -209,7 +209,7 @@ struct cma_dialog *create_cma_dialog(struct city *pcity)
   struct cma_dialog *pdialog;
   struct cm_parameter param;
   GtkWidget *frame, *page, *hbox, *label, *table;
-  GtkWidget *vbox, *sw, *hscale, *button, *align;
+  GtkWidget *vbox, *sw, *hscale, *button, *align, *image;
   GtkListStore *store;
   GtkCellRenderer *rend;
   GtkWidget *view;
@@ -268,7 +268,7 @@ struct cma_dialog *create_cma_dialog(struct city *pcity)
   label = g_object_new(GTK_TYPE_LABEL,
"use-underline", TRUE,
"mnemonic-widget", view,
-   "label", _("_Presets:"),
+   "label", _("Prese_ts:"),
"xalign", 0.0, "yalign", 0.5, NULL);
   gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
@@ -284,10 +284,13 @@ struct cma_dialog *create_cma_dialog(struct city *pcity)
   gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
   gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
 
-  pdialog->add_preset_command = gtk_button_new_from_stock(GTK_STOCK_NEW);
-  gtk_container_add(GTK_CONTAINER(hbox), pdialog->add_preset_command);
-  g_signal_connect(pdialog->add_preset_command, "clicked",
-		   G_CALLBACK(cma_add_preset_callback), pdialog);
+  button = gtk_button_new_with_mnemonic(_("Ne_w"));
+  image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON);
+  gtk_button_set_image(GTK_BUTTON(button), image);
+  gtk_container_add(GTK_CONTAINER(hbox), button);
+  g_signal_connect(button, "clicked",
+   G_CALLBACK(cma_add_preset_callback), pdialog);
+  pdialog->add_preset_command = button;
 
   pdialog->del_preset_command = gtk_button_new_from_stock(GTK_STOCK_DELETE);
   gtk_container_add(GTK_CONTAINER(hbox), pdialog->del_preset_command);
diff --git a/client/gui-gtk-2.0/wldlg.c b/client/gui-gtk-2.0/wldlg.c
index d10ca04..8580ca1 100644
--- a/client/gui-gtk-2.0/wldlg.c
+++ b/client/gui-gtk-2.0/wldlg.c
@@ -1249,7 +1249,7 @@ GtkWidget *create_worklist(void)
   ptr->help_cmd = button;
   gtk_widget_set_sensitive(ptr->help_cmd, FALSE);
 
-  button = gtk_button_new_with_mnemonic(_("Chan_ge Production"));
+  button = gtk_button_new_with_mnemonic(_("Change Prod_uction"));
   gtk_container_add(GTK_CONTAINER(bbox), button);
   g_signal_connect(button, "clicked",
 		   G_CALLBACK(change_callback), ptr);
___
Freeciv-dev mailing 

[Freeciv-Dev] (PR#40618) randomize genlist

2009-01-22 Thread Madeline Book

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

> [matthias.pfaffer...@mapfa.de - Sat Jan 03 12:50:40 2009]:
> 
> Am Saturday 03 January 2009 02:27:31 schrieb Madeline Book:
> > http://bugs.freeciv.org/Ticket/Display.html?id=40618 >
> >
> > > [matthias.pfaffer...@mapfa.de - Fri Jan 02 21:15:47 2009]:
> > >
> > > This patch adds the possibility to randomize the lists used by
> > > freeciv.
> >
> > I think array_shuffle() would be better placed in utility/
> > shared.[ch], since it is useful for more than just genlists,
> > and shared.h already has some array related stuff.
> 
> done
> 
> > Also, it should probably use myrand() from utility/rand.[ch]
> > instead of the system rand(). This will make it possible to
> > reproduce the same "random" behavior via seed parameters
> > (e.g. mapseed, gameseed), which helps in debugging.
> 
> done
> 
> > Lastly, the two "for" lines in genlist_shuffle() are missing
> > some spaces. ;)
> 
> done; I just copied the line from the function above ...
> 
> The patch is only compile tested.

Attached version 3 just makes some minor style fixes and
makes compilation work with --enable-debug.


---
おっと。切り直すね。
 server/plrhand.c   |   18 ++
 utility/genlist.c  |   34 ++
 utility/genlist.h  |1 +
 utility/shared.c   |   18 ++
 utility/shared.h   |3 +++
 utility/speclist.h |6 ++
 6 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/server/plrhand.c b/server/plrhand.c
index 507444a..2aa8f1f 100644
--- a/server/plrhand.c
+++ b/server/plrhand.c
@@ -1311,22 +1311,24 @@ void maybe_make_contact(struct tile *ptile, struct player *pplayer)
 **/
 void shuffle_players(void)
 {
-  int i, pos, tmp;
+  /* shuffled_order is defined global */
+  int n = player_slot_count();
+  int i;
 
   freelog(LOG_DEBUG, "shuffle_players: creating shuffled order");
 
-  for (i = 0; i < player_slot_count(); i++) {
+  for (i = 0; i < n; i++) {
 shuffled_order[i] = i;
   }
 
-  for (i = 0; i < player_slot_count() - 1; i++) {
-/* for each run: shuffled[ dataptr = sortbuf[i];
   }
 }
+
+/
+  Randomize the elements of a genlist using the Fisher-Yates shuffle.
+
+  see: genlist_sort() and shared.c:array_shuffle()
+/
+void genlist_shuffle(struct genlist *pgenlist)
+{
+  const int n = genlist_size(pgenlist);
+  void *sortbuf[n];
+  struct genlist_link *myiter;
+  int i, shuffle[n];
+
+  if (n <= 1) {
+return;
+  }
+
+  myiter = find_genlist_position(pgenlist, 0);
+  for (i = 0; i < n; i++, ITERATOR_NEXT(myiter)) {
+sortbuf[i] = ITERATOR_PTR(myiter);
+/* also create the shuffle list */
+shuffle[i] = i;
+  }
+
+  /* randomize it */
+  array_shuffle(shuffle, n);
+
+  /* create the shuffled list */
+  myiter = find_genlist_position(pgenlist, 0);
+  for (i = 0; i < n; i++, ITERATOR_NEXT(myiter)) {
+myiter->dataptr = sortbuf[shuffle[i]];
+  }
+}
diff --git a/utility/genlist.h b/utility/genlist.h
index 7090b00..415c699 100644
--- a/utility/genlist.h
+++ b/utility/genlist.h
@@ -84,6 +84,7 @@ bool genlist_search(struct genlist *pgenlist, const void *data);
 
 void genlist_sort(struct genlist *pgenlist,
 		  int (*compar)(const void *, const void *));
+void genlist_shuffle(struct genlist *pgenlist);
 
 #define ITERATOR_PTR(iter) ((iter) ? ((iter)->dataptr) : NULL)
 #define ITERATOR_NEXT(iter) (iter = (iter)->next)
diff --git a/utility/shared.c b/utility/shared.c
index dc29a9e..9abccca 100644
--- a/utility/shared.c
+++ b/utility/shared.c
@@ -1797,3 +1797,21 @@ char scanin(char **buf, char *delimiters, char *dest, int size)
 
   return found;
 }
+
+/
+  Randomize the elements of an array using the Fisher-Yates shuffle.
+
+  see: http://benpfaff.org/writings/clc/shuffle.html
+/
+void array_shuffle(int *array, int n)
+{
+  if (n > 1 && array != NULL) {
+int i, j, t;
+for (i = 0; i < n - 1; i++) {
+  j = i + myrand(n - i);
+  t = array[j];
+  array[j] = array[i];
+  array[i] = t;
+}
+  }
+}
diff --git a/utility/shared.h b/utility/shared.h
index df20992..eada885 100644
--- a/utility/shared.h
+++ b/utility/shared.h
@@ -244,4 +244,7 @@ bool make_dir(const char *pathname);
 bool path_is_absolute(const char *filename);
 
 char scanin(char **buf, char *delimiters, char *dest, int size);
+
+void array_shuffle(int *array, int n);
+
 #endif  /* FC__SHARED_H */
diff --git a/utility/speclist.h b/utility/speclist.h
index b1c1540..4894905 100644
--- a/utility/speclist.h
+++ b/utility/speclist.h
@@ -41,6 +41,7 @@
   bool foo_list_search(struct foo_list *this, foo_t *pfoo)