Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18756) [Patch] Be verbose why loading of user defined
Home

[Freeciv-Dev] (PR#18756) [Patch] Be verbose why loading of user defined

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18756) [Patch] Be verbose why loading of user defined tileset failed
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Thu, 20 Jul 2006 11:58:50 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18756 >


  If tileset specified in client command line cannot be loaded, client 
*silently* ignores it and loads default tileset instead. This can be 
highly annoying. I want to know why tileset I requested was not loaded, 
so I can fix it.
  This patch makes client to output error messages if tileset defined in 
command line cannot be loaded. Client still fallbacks to default tileset.
  Meant for both trunk and S2_1.


  - ML

diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c  2006-07-20 21:38:40.421875000 +0300
+++ freeciv/client/civclient.c  2006-07-20 21:22:02.046875000 +0300
@@ -168,6 +168,7 @@
   int ui_options = 0;
   bool ui_separator = FALSE;
   char *option=NULL;
+  bool user_tileset = FALSE;
 
   /* Load win32 post-crash debugger */
 #ifdef WIN32_NATIVE
@@ -275,6 +276,7 @@
     } else if ((option = get_option_malloc("--tiles", argv, &i, argc))) {
       sz_strlcpy(tileset_name, option);
       free(option);
+      user_tileset = TRUE;
     } else if (is_option("--", argv[i])) {
       ui_separator = TRUE;
     } else {
@@ -346,7 +348,7 @@
   helpdata_init();
   boot_help_texts();
 
-  tilespec_try_read(tileset_name);
+  tilespec_try_read(tileset_name, user_tileset);
 
   audio_real_init(sound_set_name, sound_plugin_name);
   audio_play_music("music_start", NULL);
diff -Nurd -X.diff_ignore freeciv/client/tilespec.c freeciv/client/tilespec.c
--- freeciv/client/tilespec.c   2006-07-20 21:39:36.828125000 +0300
+++ freeciv/client/tilespec.c   2006-07-20 21:56:15.171875000 +0300
@@ -665,7 +665,7 @@
     int i, count = 0;
 
     for (i = 0; list[i]; i++) {
-      struct tileset *t = tileset_read_toplevel(list[i]);
+      struct tileset *t = tileset_read_toplevel(list[i], FALSE);
 
       if (t) {
        tilesets = fc_realloc(tilesets, (count + 1) * sizeof(*tilesets));
@@ -718,21 +718,24 @@
 static bool check_tilespec_capabilities(struct section_file *file,
                                        const char *which,
                                        const char *us_capstr,
-                                       const char *filename)
+                                       const char *filename,
+                                        bool verbose)
 {
+  int log_level = verbose ? LOG_ERROR : LOG_DEBUG;
+
   char *file_capstr = secfile_lookup_str(file, "%s.options", which);
   
   if (!has_capabilities(us_capstr, file_capstr)) {
-    freelog(LOG_DEBUG, _("%s file appears incompatible:\n"
-                        "file: \"%s\"\n"
-                        "file options: %s\n"
-                        "supported options: %s"),
+    freelog(log_level, _("%s file appears incompatible:\n"
+                         "file: \"%s\"\n"
+                         "file options: %s\n"
+                         "supported options: %s"),
            which, filename, file_capstr, us_capstr);
     return FALSE;
   }
   if (!has_capabilities(file_capstr, us_capstr)) {
-    freelog(LOG_DEBUG, _("%s file claims required option(s)"
-                        " which we don't support:\n"
+    freelog(log_level, _("%s file requires option(s)"
+                        " which client doesn't support:\n"
                         "file: \"%s\"\n"
                         "file options: %s\n"
                         "supported options: %s"),
@@ -831,14 +834,14 @@
   Call this function with the (guessed) name of the tileset, when
   starting the client.
 ***********************************************************************/
-void tilespec_try_read(const char *tileset_name)
+void tilespec_try_read(const char *tileset_name, bool verbose)
 {
-  if (!(tileset = tileset_read_toplevel(tileset_name))) {
+  if (!(tileset = tileset_read_toplevel(tileset_name, verbose))) {
     char **list = datafilelist(TILESPEC_SUFFIX);
     int i;
 
     for (i = 0; list[i]; i++) {
-      struct tileset *t = tileset_read_toplevel(list[i]);
+      struct tileset *t = tileset_read_toplevel(list[i], FALSE);
 
       if (t) {
        if (!tileset || t->priority > tileset->priority) {
@@ -903,8 +906,8 @@
    *
    * We read in the new tileset.  This should be pretty straightforward.
    */
-  if (!(tileset = tileset_read_toplevel(tileset_name))) {
-    if (!(tileset = tileset_read_toplevel(old_name))) {
+  if (!(tileset = tileset_read_toplevel(tileset_name, FALSE))) {
+    if (!(tileset = tileset_read_toplevel(old_name, FALSE))) {
       die("Failed to re-read the currently loaded tileset.");
     }
   }
@@ -1042,7 +1045,7 @@
   }
 
   if (!check_tilespec_capabilities(file, "spec",
-                                  SPEC_CAPSTR, sf->file_name)) {
+                                  SPEC_CAPSTR, sf->file_name, TRUE)) {
     exit(EXIT_FAILURE);
   }
 
@@ -1075,7 +1078,7 @@
     exit(EXIT_FAILURE);
   }
   if (!check_tilespec_capabilities(file, "spec",
-                                  SPEC_CAPSTR, sf->file_name)) {
+                                  SPEC_CAPSTR, sf->file_name, TRUE)) {
     exit(EXIT_FAILURE);
   }
 
@@ -1231,7 +1234,7 @@
   Sets global variables, including tile sizes and full names for
   intro files.
 ***********************************************************************/
-struct tileset *tileset_read_toplevel(const char *tileset_name)
+struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose)
 {
   struct section_file the_file, *file = &the_file;
   char *fname, *c;
@@ -1245,6 +1248,9 @@
 
   fname = tilespec_fullname(tileset_name);
   if (!fname) {
+    if (verbose) {
+      freelog(LOG_ERROR, _("Can't find tileset \"%s\"."), tileset_name); 
+    }
     tileset_free(t);
     return NULL;
   }
@@ -1259,7 +1265,7 @@
   }
 
   if (!check_tilespec_capabilities(file, "tilespec",
-                                  TILESPEC_CAPSTR, fname)) {
+                                  TILESPEC_CAPSTR, fname, verbose)) {
     section_file_free(file);
     free(fname);
     tileset_free(t);
@@ -1571,6 +1577,9 @@
     sf->big_sprite = NULL;
     dname = datafilename(spec_filenames[i]);
     if (!dname) {
+      if (verbose) {
+        freelog(LOG_ERROR, _("Can't find spec file \"%s\"."), 
spec_filenames[i]);
+      }
       section_file_free(file);
       free(fname);
       tileset_free(t);
diff -Nurd -X.diff_ignore freeciv/client/tilespec.h freeciv/client/tilespec.h
--- freeciv/client/tilespec.h   2006-07-20 21:39:36.828125000 +0300
+++ freeciv/client/tilespec.h   2006-07-20 21:33:15.656250000 +0300
@@ -112,12 +112,12 @@
 
 const char **get_tileset_list(void);
 
-struct tileset *tileset_read_toplevel(const char *tileset_name);
+struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose);
 void tileset_free(struct tileset *tileset);
 void tileset_load_tiles(struct tileset *t);
 void tileset_free_tiles(struct tileset *t);
 
-void tilespec_try_read(const char *tileset_name);
+void tilespec_try_read(const char *tileset_name, bool verbose);
 void tilespec_reread(const char *tileset_name);
 void tilespec_reread_callback(struct client_option *option);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18756) [Patch] Be verbose why loading of user defined tileset failed, Marko Lindqvist <=