Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13231) a tileset priority
Home

[Freeciv-Dev] (PR#13231) a tileset priority

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13231) a tileset priority
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Jun 2005 14:55:09 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch adds a priority number to each tileset.

When loading for the first time, the highest-priority tileset is used.
This replaces the old method of hard-coding the preferred tileset's
name.  It'll work better with add-on tilesets (but only if they're added
on before the first time the game is run...).

-jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.310
diff -u -r1.310 tilespec.c
--- client/tilespec.c   7 Jun 2005 16:18:53 -0000       1.310
+++ client/tilespec.c   7 Jun 2005 21:53:05 -0000
@@ -334,6 +334,7 @@
 
 struct tileset {
   char name[512];
+  int priority;
 
   bool is_isometric;
   int hex_width, hex_height;
@@ -780,20 +781,29 @@
 void tilespec_try_read(const char *tileset_name)
 {
   if (!(tileset = tileset_read_toplevel(tileset_name))) {
-    const char *tileset_default;
+    char **list = datafilelist(TILESPEC_SUFFIX);
+    int i;
 
-    if (isometric_view_supported()) {
-      tileset_default = "isotrident"; /* Do not i18n! --dwp */
-    } else {
-      tileset_default = "trident";    /* Do not i18n! --dwp */
-    }
+    for (i = 0; list[i]; i++) {
+      struct tileset *t = tileset_read_toplevel(list[i]);
 
-    freelog(LOG_ERROR, _("Trying \"%s\" tileset."), tileset_default);
+      if (t) {
+       if (!tileset || t->priority > tileset->priority) {
+         tileset = t;
+       } else {
+         tileset_free(t);
+       }
+      }
+      free(list[i]);
+    }
+    free(list);
 
-    if (!(tileset = tileset_read_toplevel(tileset_default))) {
+    if (!tileset) {
       freelog(LOG_FATAL, _("No usable default tileset found, aborting!"));
       exit(EXIT_FAILURE);
     }
+
+    freelog(LOG_NORMAL, _("Trying \"%s\" tileset."), tileset->name);
   }
   sz_strlcpy(default_tileset_name, tileset_get_name(tileset));
 }
@@ -1212,6 +1222,7 @@
   (void) section_file_lookup(file, "tilespec.name"); /* currently unused */
 
   sz_strlcpy(t->name, tileset_name);
+  t->priority = secfile_lookup_int_default(file, 0, "tilespec.priority");
 
   t->is_isometric = secfile_lookup_bool_default(file, FALSE,
                                                "tilespec.is_isometric");
Index: data/isophex.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isophex.tilespec,v
retrieving revision 1.18
diff -u -r1.18 isophex.tilespec
--- data/isophex.tilespec       7 Jun 2005 16:18:53 -0000       1.18
+++ data/isophex.tilespec       7 Jun 2005 21:53:05 -0000
@@ -6,6 +6,7 @@
 
 ; A simple name for the tileset specified by this file:
 name = "isophex"
+priority = 3
 
 ; TODO: add more overall information fields on tiles, 
 ; eg, description, authors, colors, etc.
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.41
diff -u -r1.41 isotrident.tilespec
--- data/isotrident.tilespec    7 Jun 2005 16:18:53 -0000       1.41
+++ data/isotrident.tilespec    7 Jun 2005 21:53:05 -0000
@@ -6,6 +6,7 @@
 
 ; A simple name for the tileset specified by this file:
 name = "MacroIsoTrident"
+priority = 10
 
 ; TODO: add more overall information fields on tiles, 
 ; eg, description, authors, colors, etc.
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.42
diff -u -r1.42 trident.tilespec
--- data/trident.tilespec       7 Jun 2005 16:18:53 -0000       1.42
+++ data/trident.tilespec       7 Jun 2005 21:53:05 -0000
@@ -6,6 +6,7 @@
 
 ; A simple name for the tileset specified by this file:
 name = "Trident"
+priority = 5
 
 ; TODO: add more overall information fields on tiles, 
 ; eg, description, authors, colors, etc.

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13231) a tileset priority, Jason Short <=