rnd-20030108-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 8 Jan 2003 00:18:14 +0000 (01:18 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:39:35 +0000 (10:39 +0200)
src/conf_gfx.c
src/conftime.h
src/init.c
src/libgame/misc.c

index 0a6beead20fd0fa68f11ca1f87e6a3bf39777b07..d6aff2313eeca0b3984d7d9ff480e77da850d1bb 100644 (file)
 #include "main.h"
 
 
+/* List values that are not defined in the configuration file are set to
+   reliable default values. If that value is GFX_ARG_UNDEFINED, it will
+   be dynamically determined, using some of the other list values. */
+
 struct ConfigInfo image_config_suffix[] =
 {
   { ".xpos",                           "0",                    TYPE_INTEGER },
@@ -23,7 +27,7 @@ struct ConfigInfo image_config_suffix[] =
   { ".vertical",                       "false",                TYPE_BOOLEAN },
   { ".xoffset",                                GFX_ARG_UNDEFINED,      TYPE_INTEGER },
   { ".yoffset",                                GFX_ARG_UNDEFINED,      TYPE_INTEGER },
-  { ".frames",                         "1",                    TYPE_INTEGER },
+  { ".frames",                         GFX_ARG_UNDEFINED,      TYPE_INTEGER },
   { ".start_frame",                    GFX_ARG_UNDEFINED,      TYPE_INTEGER },
   { ".delay",                          "1",                    TYPE_INTEGER },
   { ".mode_loop",                      "false",                TYPE_BOOLEAN },
index 0412a164a2040fa1cc723d6468654c3c11d26d60..4a631944a903fd871f64458c4b7962244aa494fa 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-01-07 04:02]"
+#define COMPILE_DATE_STRING "[2003-01-08 01:08]"
index f497ec242599e9ff0e34c6605405b944da15dd74..ce1e9298915dd5e75a493517477e2cd68c48504b 100644 (file)
@@ -777,7 +777,6 @@ static void InitGraphicInfo()
 {
   static boolean clipmasks_initialized = FALSE;
   static int gfx_action[NUM_IMAGE_FILES];
-  Bitmap *src_bitmap;
   int src_x, src_y;
   int first_frame, last_frame;
   int i;
@@ -827,9 +826,12 @@ static void InitGraphicInfo()
 
   for (i=0; i<NUM_IMAGE_FILES; i++)
   {
+    Bitmap *src_bitmap = getBitmapFromImageID(i);
+    int num_xtiles = (src_bitmap ? src_bitmap->width          : TILEX) / TILEX;
+    int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
     int *parameter = image_files[i].parameter;
 
-    new_graphic_info[i].bitmap = getBitmapFromImageID(i);
+    new_graphic_info[i].bitmap = src_bitmap;
 
     new_graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
     new_graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
@@ -849,7 +851,15 @@ static void InitGraphicInfo()
     if (parameter[GFX_ARG_YOFFSET] != GFX_ARG_UNDEFINED_VALUE)
       new_graphic_info[i].offset_y = parameter[GFX_ARG_YOFFSET];
 
-    new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
+    /* automatically determine correct number of frames, if not defined */
+    if (parameter[GFX_ARG_FRAMES] != GFX_ARG_UNDEFINED_VALUE)
+      new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
+    else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
+      new_graphic_info[i].anim_frames =        num_xtiles;
+    else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
+      new_graphic_info[i].anim_frames =        num_ytiles;
+    else
+      new_graphic_info[i].anim_frames = 1;
 
     new_graphic_info[i].anim_delay = parameter[GFX_ARG_DELAY];
     if (new_graphic_info[i].anim_delay == 0)   /* delay must be at least 1 */
@@ -864,7 +874,7 @@ static void InitGraphicInfo()
       new_graphic_info[i].anim_mode = ANIM_PINGPONG;
     else if (parameter[GFX_ARG_MODE_PINGPONG2])
       new_graphic_info[i].anim_mode = ANIM_PINGPONG2;
-    else if (parameter[GFX_ARG_FRAMES] > 1)
+    else if (new_graphic_info[i].anim_frames > 1)
       new_graphic_info[i].anim_mode = ANIM_LOOP;
     else
       new_graphic_info[i].anim_mode = ANIM_NONE;
@@ -930,8 +940,8 @@ static void InitGraphicInfo()
            getTokenFromImageID(i));
       Error(ERR_RETURN, "- image file: '%s'",
            src_bitmap->source_filename);
-      Error(ERR_EXIT, "error: last animation frame out of bounds (%d,%d)",
-           src_x, src_y);
+      Error(ERR_EXIT, "error: last animation frame (%d) out of bounds (%d,%d)",
+           last_frame, src_x, src_y);
     }
 
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
index 7caaa3af88251b1601ff0abe0864058c6fe31c7c..30399620e59c209ebb670a7445136d3427662e3f 100644 (file)
@@ -1566,8 +1566,13 @@ static void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
     {
       char *filename = getTokenValue(setup_file_list, file_list[i].token);
 
-      if (filename == NULL)
+      if (filename)
+       for (j=0; j<num_suffix_list_entries; j++)
+         file_list[i].parameter[j] =
+           get_parameter_value(suffix_list[j].type, suffix_list[j].value);
+      else
        filename = file_list[i].default_filename;
+
       file_list[i].filename = getStringCopy(filename);
 
       for (j=0; j<num_suffix_list_entries; j++)