rnd-20051209-2-src
authorHolger Schemel <info@artsoft.org>
Fri, 9 Dec 2005 11:14:34 +0000 (12:14 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:49:41 +0000 (10:49 +0200)
src/conftime.h
src/init.c

index d9b91b984322d65d0ab376ad43d8bf91b1008cc2..5964e533f00ee7b05666af399a3e52f3b57ee795 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2005-12-09 11:01]"
+#define COMPILE_DATE_STRING "[2005-12-09 12:13]"
index f9dd0c1338bb8933f5bfeb18eb8bd7e2877ae277..afb11942fb164db6dd73c2a441f2a4c1e98e2703 100644 (file)
@@ -1067,6 +1067,51 @@ static void set_graphic_parameters(int graphic, int graphic_copy_from)
 #endif
 }
 
+static void set_cloned_graphic_parameters(int graphic)
+{
+  int fallback_graphic = IMG_CHAR_EXCLAM;
+  int max_num_images = getImageListSize();
+  int clone_graphic = graphic_info[graphic].clone_from;
+  int num_references_followed = 1;
+
+  while (graphic_info[clone_graphic].clone_from != -1 &&
+        num_references_followed < max_num_images)
+  {
+    clone_graphic = graphic_info[clone_graphic].clone_from;
+
+    num_references_followed++;
+  }
+
+  if (num_references_followed >= max_num_images)
+  {
+    Error(ERR_RETURN_LINE, "-");
+    Error(ERR_RETURN, "warning: error found in config file:");
+    Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename());
+    Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(graphic));
+    Error(ERR_RETURN, "error: loop discovered when resolving cloned graphics");
+    Error(ERR_RETURN, "custom graphic rejected for this element/action");
+
+    if (graphic == fallback_graphic)
+      Error(ERR_EXIT, "fatal error: no fallback graphic available");
+
+    Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
+    Error(ERR_RETURN_LINE, "-");
+
+    set_graphic_parameters(graphic, fallback_graphic);
+  }
+  else
+  {
+    graphic_info[graphic] = graphic_info[clone_graphic];
+    graphic_info[graphic].clone_from = clone_graphic;
+
+#if 0
+    printf("::: graphic %d ['%s'] is cloned from %d ['%s']\n",
+          i, getTokenFromImageID(i),
+          clone_graphic, getTokenFromImageID(clone_graphic));
+#endif
+  }
+}
+
 static void InitGraphicInfo()
 {
   int fallback_graphic = IMG_CHAR_EXCLAM;
@@ -1101,53 +1146,14 @@ static void InitGraphicInfo()
   }
 #endif
 
-#if 1
   /* first set all graphic paramaters ... */
   for (i = 0; i < num_images; i++)
-  {
     set_graphic_parameters(i, i);
-  }
 
   /* ... then copy these parameters for cloned graphics */
   for (i = 0; i < num_images; i++)
-  {
     if (graphic_info[i].clone_from != -1)
-    {
-      int clone_graphic = graphic_info[i].clone_from;
-
-      if (graphic_info[clone_graphic].clone_from != -1)
-      {
-       Error(ERR_RETURN_LINE, "-");
-       Error(ERR_RETURN, "warning: error found in config file:");
-       Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename());
-       Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(i));
-       Error(ERR_RETURN,
-             "error: cannot clone from already cloned graphic '%s'",
-             getTokenFromImageID(clone_graphic));
-       Error(ERR_RETURN, "custom graphic rejected for this element/action");
-
-       if (i == fallback_graphic)
-         Error(ERR_EXIT, "fatal error: no fallback graphic available");
-
-       Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
-       Error(ERR_RETURN_LINE, "-");
-
-       set_graphic_parameters(i, fallback_graphic);
-      }
-      else
-      {
-       graphic_info[i] = graphic_info[clone_graphic];
-       graphic_info[i].clone_from = clone_graphic;
-
-#if 0
-       printf("::: graphic %d ['%s'] is cloned from %d ['%s']\n",
-              i, getTokenFromImageID(i),
-              clone_graphic, getTokenFromImageID(clone_graphic));
-#endif
-      }
-    }
-  }
-#endif
+      set_cloned_graphic_parameters(i);
 
   for (i = 0; i < num_images; i++)
   {