rnd-20060723-1-src
[rocksndiamonds.git] / src / libgame / misc.c
index 154f83438daa3a83370cb8464b97b2778d64e855..c98c9d07c8b83f2d56f327f844b99bc4731215f9 100644 (file)
@@ -470,7 +470,7 @@ static char *getLastPathSeparatorPtr(char *filename)
   return last_separator;
 }
 
-static char *getBaseNamePtr(char *filename)
+char *getBaseNamePtr(char *filename)
 {
   char *last_separator = getLastPathSeparatorPtr(filename);
 
@@ -1041,17 +1041,27 @@ boolean getFileChunk(FILE *file, char *chunk_name, int *chunk_size,
   return (feof(file) || ferror(file) ? FALSE : TRUE);
 }
 
-void putFileChunk(FILE *file, char *chunk_name, int chunk_size,
-                 int byte_order)
+int putFileChunk(FILE *file, char *chunk_name, int chunk_size,
+                int byte_order)
 {
+  int num_bytes = 0;
+
   /* write chunk name */
-  fputs(chunk_name, file);
+  if (file != NULL)
+    fputs(chunk_name, file);
+
+  num_bytes += strlen(chunk_name);
 
   if (chunk_size >= 0)
   {
     /* write chunk size */
-    putFile32BitInteger(file, chunk_size, byte_order);
+    if (file != NULL)
+      putFile32BitInteger(file, chunk_size, byte_order);
+
+    num_bytes += 4;
   }
+
+  return num_bytes;
 }
 
 int getFileVersion(FILE *file)
@@ -1065,17 +1075,22 @@ int getFileVersion(FILE *file)
                       version_build);
 }
 
-void putFileVersion(FILE *file, int version)
+int putFileVersion(FILE *file, int version)
 {
-  int version_major = VERSION_MAJOR(version);
-  int version_minor = VERSION_MINOR(version);
-  int version_patch = VERSION_PATCH(version);
-  int version_build = VERSION_BUILD(version);
+  if (file != NULL)
+  {
+    int version_major = VERSION_MAJOR(version);
+    int version_minor = VERSION_MINOR(version);
+    int version_patch = VERSION_PATCH(version);
+    int version_build = VERSION_BUILD(version);
+
+    fputc(version_major, file);
+    fputc(version_minor, file);
+    fputc(version_patch, file);
+    fputc(version_build, file);
+  }
 
-  fputc(version_major, file);
-  fputc(version_minor, file);
-  fputc(version_patch, file);
-  fputc(version_build, file);
+  return 4;
 }
 
 void ReadBytesFromFile(FILE *file, byte *buffer, unsigned long bytes)
@@ -1779,6 +1794,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type)
              string_has_parameter(value, "random")     ? ANIM_RANDOM :
              string_has_parameter(value, "ce_value")   ? ANIM_CE_VALUE :
              string_has_parameter(value, "ce_score")   ? ANIM_CE_SCORE :
+             string_has_parameter(value, "ce_delay")   ? ANIM_CE_DELAY :
              string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL :
              string_has_parameter(value, "vertical")   ? ANIM_VERTICAL :
              ANIM_DEFAULT);
@@ -2067,6 +2083,10 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info,
   if (filename == NULL)
     return;
 
+#if 0
+  printf("LoadArtworkConfigFromFilename '%s' ...\n", filename);
+#endif
+
   if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
     return;
 
@@ -2433,10 +2453,6 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
   char *filename_base = UNDEFINED_FILENAME, *filename_local;
   int i, j;
 
-#if 0
-  printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename);
-#endif
-
   DrawInitText("Loading artwork config:", 120, FC_GREEN);
   DrawInitText(ARTWORKINFO_FILENAME(artwork_info->type), 150, FC_YELLOW);