Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12385) encapsulate NORMAL_TILE_WIDTH
Home

[Freeciv-Dev] (PR#12385) encapsulate NORMAL_TILE_WIDTH

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12385) encapsulate NORMAL_TILE_WIDTH
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 28 Feb 2005 16:11:54 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch encapsulates NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT, 
UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, SMALL_SPRITE_WIDTH, and 
SMALL_SPRITE_HEIGHT into tilespec.c.  The old names are left in place 
but are #defined to be the accessor functions.  The new names are 
changed slightly.  Instead of "unit tile" it is "full tile" (this is 
used for cities and terrains as well) and instead of "small tile" it is 
"small sprite" (since these aren't "tiles" at all but just theme graphics).

-jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.248
diff -u -r1.248 tilespec.c
--- client/tilespec.c   28 Feb 2005 20:24:38 -0000      1.248
+++ client/tilespec.c   1 Mar 2005 00:10:56 -0000
@@ -68,18 +68,15 @@
 static const int DIR4_TO_DIR8[4] =
     { DIR8_NORTH, DIR8_SOUTH, DIR8_EAST, DIR8_WEST };
 
-int NORMAL_TILE_WIDTH;
-int NORMAL_TILE_HEIGHT;
-int UNIT_TILE_WIDTH;
-int UNIT_TILE_HEIGHT;
-int SMALL_TILE_WIDTH;
-int SMALL_TILE_HEIGHT;
-
 int OVERVIEW_TILE_SIZE = 2;
 
 static bool is_isometric;
 static int hex_width, hex_height;
 
+static int normal_tile_width, normal_tile_height;
+static int full_tile_width, full_tile_height;
+static int small_sprite_width, small_sprite_height;
+
 static int city_names_font_size, city_productions_font_size;
 
 int num_tiles_explode_unit=0;
@@ -218,6 +215,64 @@
 {
   return hex_width;
 }
+/****************************************************************************
+  Return the tile width of the current tileset.  This is the tesselation
+  width of the tiled plane.
+****************************************************************************/
+int tileset_tile_width(void)
+{
+  return normal_tile_width;
+}
+
+/****************************************************************************
+  Return the tile height of the current tileset.  This is the tesselation
+  height of the tiled plane.
+****************************************************************************/
+int tileset_tile_height(void)
+{
+  return normal_tile_height;
+}
+
+/****************************************************************************
+  Return the full tile width of the current tileset.  This is the maximum
+  width that any mapview sprite will have.
+
+  Note: currently this is always equal to the tile width.
+****************************************************************************/
+int tileset_full_tile_width(void)
+{
+  return full_tile_width;
+}
+
+/****************************************************************************
+  Return the full tile height of the current tileset.  This is the maximum
+  height that any mapview sprite will have.  This may be greater than the
+  tile width in which case the extra area is above the "normal" tile.
+****************************************************************************/
+int tileset_full_tile_height(void)
+{
+  return full_tile_height;
+}
+
+/****************************************************************************
+  Return the small sprite width of the current tileset.  The small sprites
+  are used for various theme graphics (e.g., citymap citizens/specialists
+  as well as panel indicator icons).
+****************************************************************************/
+int tileset_small_sprite_width(void)
+{
+  return small_sprite_width;
+}
+
+/****************************************************************************
+  Return the small sprite height of the current tileset.  The small sprites
+  are used for various theme graphics (e.g., citymap citizens/specialists
+  as well as panel indicator icons).
+****************************************************************************/
+int tileset_small_sprite_height(void)
+{
+  return small_sprite_height;
+}
 
 /****************************************************************************
   Return the hex_height of the current tileset.  For isohex tilesets this
@@ -872,17 +927,19 @@
   num_index_valid = 1 << num_valid_tileset_dirs;
   num_index_cardinal = 1 << num_cardinal_tileset_dirs;
 
-  NORMAL_TILE_WIDTH = secfile_lookup_int(file, "tilespec.normal_tile_width");
-  NORMAL_TILE_HEIGHT = secfile_lookup_int(file, "tilespec.normal_tile_height");
+  normal_tile_width = secfile_lookup_int(file, "tilespec.normal_tile_width");
+  normal_tile_height = secfile_lookup_int(file, "tilespec.normal_tile_height");
   if (is_isometric) {
-    UNIT_TILE_WIDTH = NORMAL_TILE_WIDTH;
-    UNIT_TILE_HEIGHT = 3 * NORMAL_TILE_HEIGHT/2;
+    full_tile_width = NORMAL_TILE_WIDTH;
+    full_tile_height = 3 * NORMAL_TILE_HEIGHT / 2;
   } else {
-    UNIT_TILE_WIDTH = NORMAL_TILE_WIDTH;
-    UNIT_TILE_HEIGHT = NORMAL_TILE_HEIGHT;
+    full_tile_width = NORMAL_TILE_WIDTH;
+    full_tile_height = NORMAL_TILE_HEIGHT;
   }
-  SMALL_TILE_WIDTH = secfile_lookup_int(file, "tilespec.small_tile_width");
-  SMALL_TILE_HEIGHT = secfile_lookup_int(file, "tilespec.small_tile_height");
+  small_sprite_width
+    = secfile_lookup_int(file, "tilespec.small_tile_width");
+  small_sprite_height
+    = secfile_lookup_int(file, "tilespec.small_tile_height");
   freelog(LOG_VERBOSE, "tile sizes %dx%d, %d%d unit, %d%d small",
          NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
          UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.112
diff -u -r1.112 tilespec.h
--- client/tilespec.h   28 Feb 2005 20:24:38 -0000      1.112
+++ client/tilespec.h   1 Mar 2005 00:10:56 -0000
@@ -387,12 +387,12 @@
  *     - NORMAL_TILE_WIDTH and NORMAL_TILE_HEIGHT are even
  */
 
-extern int NORMAL_TILE_WIDTH;
-extern int NORMAL_TILE_HEIGHT;
-extern int UNIT_TILE_WIDTH;
-extern int UNIT_TILE_HEIGHT;
-extern int SMALL_TILE_WIDTH;
-extern int SMALL_TILE_HEIGHT;
+#define NORMAL_TILE_WIDTH tileset_tile_width()
+#define NORMAL_TILE_HEIGHT tileset_tile_height()
+#define UNIT_TILE_WIDTH tileset_full_tile_width()
+#define UNIT_TILE_HEIGHT tileset_full_tile_height()
+#define SMALL_TILE_WIDTH tileset_small_sprite_width()
+#define SMALL_TILE_HEIGHT tileset_small_sprite_height()
 
 /* The overview tile width and height are defined in terms of the base
  * size.  For iso-maps the width is twice the height since "natural"
@@ -408,6 +408,12 @@
 bool tileset_is_isometric(void);
 int tileset_hex_width(void);
 int tileset_hex_height(void);
+int tileset_tile_width(void);
+int tileset_tile_height(void);
+int tileset_full_tile_width(void);
+int tileset_full_tile_height(void);
+int tileset_small_sprite_width(void);
+int tileset_small_sprite_height(void);
 
 struct Sprite *load_sprite(const char *tag_name);
 void unload_sprite(const char *tag_name);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12385) encapsulate NORMAL_TILE_WIDTH, Jason Short <=