[Freeciv-Dev] Freeciv and XDG_* environment variables

2007-02-01 Thread Egor Vyscrebentsov
Good daytime!

Does someone had experience in working with XDG_DATA_HOME,
XDG_CONFIG_HOME and similar environment variables?

http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html

How difficult would be to make freeciv to look for this
variables? (Does this means freeciv should think about both
$XDG_CONFIG_HOME/freeciv and $HOME/.freecivrc?)
[Default for XDG_CONFIG_HOME is $HOME/.config]

PS. If nobody will protest, I would like to see support of
XDG variables coming with other changes in rc files together.
(Like change of default port, default tileset etc)

--
Thanks, evyscr


pgpbz7IER6j5Q.pgp
Description: PGP signature
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#34566) [Patch] AI level name cleanup

2007-02-01 Thread Marko Lindqvist

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

On 1/27/07, Marko Lindqvist [EMAIL PROTECTED] wrote:

 On 1/27/07, Marko Lindqvist [EMAIL PROTECTED] wrote:
 
  On 1/26/07, Marko Lindqvist [EMAIL PROTECTED] wrote:
  
Introduced enum ai_level. Added functions find_ai_level_by_name(),
   ai_level_name() and ai_level_name_cmd() to common/player.c. Used where
   applicable.
 
   - Handle 'away' players. This required new function is_settable_ai_level()
   - Use these functions also when building gtk -client conn_menu

  - Use ai_level_name_cmd() also when writing ini file by /write command

 - ai_level_name_cmd() renamed as ai_level_cmd()


 - ML

diff -Nurd -X.diff_ignore freeciv/client/connectdlg_common.c freeciv/client/connectdlg_common.c
--- freeciv/client/connectdlg_common.c	2007-01-27 23:46:13.0 +0200
+++ freeciv/client/connectdlg_common.c	2007-02-01 21:33:42.0 +0200
@@ -75,14 +75,6 @@
 
 int internal_server_port;
 
-const char *skill_level_names[NUM_SKILL_LEVELS] = { 
-  N_(novice),
-  N_(easy), 
-  N_(normal), 
-  N_(hard)
- ,N_(experimental)
-};
-
 /** 
 The general chain of events:
 
diff -Nurd -X.diff_ignore freeciv/client/connectdlg_common.h freeciv/client/connectdlg_common.h
--- freeciv/client/connectdlg_common.h	2007-01-27 23:46:13.0 +0200
+++ freeciv/client/connectdlg_common.h	2007-02-01 21:33:42.0 +0200
@@ -34,15 +34,4 @@
 extern char player_name[MAX_LEN_NAME];
 extern char *current_filename;
 
-enum skill_levels { 
-  NOVICE, 
-  EASY, 
-  NORMAL, 
-  HARD, 
-  EXPERIMENTAL,
-  NUM_SKILL_LEVELS
-};
-
-extern const char *skill_level_names[NUM_SKILL_LEVELS];
-
 #endif  /* FC__CONNECTDLG_COMMON_H */ 
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/gui_main.c freeciv/client/gui-gtk-2.0/gui_main.c
--- freeciv/client/gui-gtk-2.0/gui_main.c	2007-01-27 23:46:13.0 +0200
+++ freeciv/client/gui-gtk-2.0/gui_main.c	2007-02-01 21:33:42.0 +0200
@@ -1522,21 +1522,9 @@
   } conn_list_iterate_end;
 
   if (pplayer-ai.control) {
-	sz_strlcpy(name, _(AI));
-	switch (pplayer-ai.skill_level) {
-	case 2:
-	  sz_strlcpy(name, _(Novice AI));
-	  break;
-	case 3:
-	  sz_strlcpy(name, _(Easy AI));
-	  break;
-	case 5:
-	  sz_strlcpy(name, _(Normal AI));
-	  break;
-	case 7:
-	  sz_strlcpy(name, _(Hard AI));
-	  break;
-	}
+/* TRANS: Novice AI */
+my_snprintf(name, sizeof(name), _(%s AI),
+ai_level_name(pplayer-ai.skill_level));
   } else if (access_level = ALLOW_INFO) {
 	sz_strlcpy(name, pplayer-username);
   } else {
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/pages.c freeciv/client/gui-gtk-2.0/pages.c
--- freeciv/client/gui-gtk-2.0/pages.c	2007-01-27 23:46:13.0 +0200
+++ freeciv/client/gui-gtk-2.0/pages.c	2007-02-01 21:37:15.0 +0200
@@ -92,7 +92,7 @@
 /* Send new game defaults. */
 send_chat(/set aifill 5);
 
-my_snprintf(buf, sizeof(buf), /%s, skill_level_names[0]);
+my_snprintf(buf, sizeof(buf), /%s, ai_level_cmd(AI_LEVEL_DEFAULT));
 send_chat(buf);
   }
 }
@@ -934,8 +934,13 @@
 {
   const char *name;
   char buf[512];
+  enum ai_level level = GPOINTER_TO_UINT(data);
 
-  name = skill_level_names[GPOINTER_TO_UINT(data)];
+  if (level == AI_LEVEL_LAST) {
+level = AI_LEVEL_DEFAULT;
+  }
+
+  name = ai_level_cmd(level);
 
   my_snprintf(buf, sizeof(buf), /%s, name);
   send_chat(buf);
@@ -1254,9 +1259,7 @@
 
   if (aconnection.access_level = ALLOW_CTRL
pplayer  pplayer-ai.control) {
-char *difficulty[] = {N_(novice), N_(easy),
-			  N_(normal), N_(hard)};
-int i;
+enum ai_level level;
 
 entry = gtk_separator_menu_item_new();
 g_object_set_data_full(G_OBJECT(menu),
@@ -1264,18 +1267,24 @@
 			   (GtkDestroyNotify) gtk_widget_unref);
 gtk_container_add(GTK_CONTAINER(menu), entry);
 
-for (i = 0; i  ARRAY_SIZE(difficulty); i++) {
-  char text[128];
+for (level = 0; level  AI_LEVEL_LAST; level++) {
+  if (is_settable_ai_level(level)) {
+const char *level_name = ai_level_name(level);
+const char *level_cmd = ai_level_cmd(level);
+static char lvl_cmd_tmp[AI_LEVEL_LAST][50];
 
-  my_snprintf(text, sizeof(text), %s, _(difficulty[i]));
-  entry = gtk_menu_item_new_with_label(text);
-  g_object_set_data_full(G_OBJECT(menu),
-			 difficulty[i], entry,
-			 (GtkDestroyNotify) gtk_widget_unref);
-  gtk_container_add(GTK_CONTAINER(menu), entry);
-  g_signal_connect(GTK_OBJECT(entry), activate,
-		   GTK_SIGNAL_FUNC(conn_menu_player_command),
-		   difficulty[i]);
+/* Copy to non-const string */
+mystrlcpy(lvl_cmd_tmp[level], level_cmd, sizeof(lvl_cmd_tmp[level]));
+
+entry = gtk_menu_item_new_with_label(level_name);
+g_object_set_data_full(G_OBJECT(menu),
+   lvl_cmd_tmp[level], entry,
+