rnd-20020519-1-src
authorHolger Schemel <info@artsoft.org>
Sun, 19 May 2002 12:09:52 +0000 (14:09 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:37:41 +0000 (10:37 +0200)
src/game.c
src/init.c
src/libgame/misc.c
src/libgame/setup.c
src/libgame/sound.c
src/libgame/system.h
src/main.c
src/timestamp.h

index 0312c695cccb3ba28d2a893c667d9ecadd79b058..89d556d3a057070deb4f8ceb6fdfdd32d52778fa 100644 (file)
 #define DX_TIME                        (DX + XX_TIME)
 #define DY_TIME                        (DY + YY_TIME)
 
 #define DX_TIME                        (DX + XX_TIME)
 #define DY_TIME                        (DY + YY_TIME)
 
-#if 0
-#define IS_LOOP_SOUND(s)       ((s) == SND_BD_MAGIC_WALL_RUNNING ||    \
-                                (s) == SND_BD_BUTTERFLY_MOVING ||      \
-                                (s) == SND_BD_FIREFLY_MOVING ||        \
-                                (s) == SND_SP_SNIKSNAK_MOVING ||       \
-                                (s) == SND_SP_ELECTRON_MOVING ||       \
-                                (s) == SND_DYNAMITE_BURNING || \
-                                (s) == SND_BUG_MOVING ||       \
-                                (s) == SND_SPACESHIP_MOVING || \
-                                (s) == SND_YAMYAM_MOVING ||    \
-                                (s) == SND_YAMYAM_WAITING ||   \
-                                (s) == SND_ROBOT_WHEEL_RUNNING ||      \
-                                (s) == SND_MAGIC_WALL_RUNNING ||       \
-                                (s) == SND_BALLOON_MOVING ||   \
-                                (s) == SND_MOLE_MOVING ||      \
-                                (s) == SND_TIMEGATE_WHEEL_RUNNING ||   \
-                                (s) == SND_CONVEYOR_BELT_RUNNING ||    \
-                                (s) == SND_DYNABOMB_BURNING || \
-                                (s) == SND_PACMAN_MOVING ||    \
-                                (s) == SND_PENGUIN_MOVING ||   \
-                                (s) == SND_PIG_MOVING ||       \
-                                (s) == SND_DRAGON_MOVING ||    \
-                                (s) == SND_DRAGON_BREATHING_FIRE)
-#endif
-
 /* values for player movement speed (which is in fact a delay value) */
 #define MOVE_DELAY_NORMAL_SPEED        8
 #define MOVE_DELAY_HIGH_SPEED  4
 /* values for player movement speed (which is in fact a delay value) */
 #define MOVE_DELAY_NORMAL_SPEED        8
 #define MOVE_DELAY_HIGH_SPEED  4
@@ -4404,6 +4379,9 @@ static void DrawBeltAnimation(int x, int y, int element)
     int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7);
 
     DrawGraphicAnimation(x, y, graphic, 8, delay, mode);
     int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7);
 
     DrawGraphicAnimation(x, y, graphic, 8, delay, mode);
+
+    if (!(FrameCounter % 2))
+      PlaySoundLevel(x, y, SND_CONVEYOR_BELT_RUNNING);
   }
 }
 
   }
 }
 
@@ -4754,11 +4732,7 @@ void GameActions()
     else if (element == EL_SP_TERMINAL_ACTIVE)
       DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL);
     else if (IS_BELT(element))
     else if (element == EL_SP_TERMINAL_ACTIVE)
       DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL);
     else if (IS_BELT(element))
-    {
       DrawBeltAnimation(x, y, element);
       DrawBeltAnimation(x, y, element);
-      if (!(FrameCounter % 2))
-       PlaySoundLevel(x, y, SND_CONVEYOR_BELT_RUNNING);
-    }
     else if (element == EL_SWITCHGATE_OPENING)
       OpenSwitchgate(x, y);
     else if (element == EL_SWITCHGATE_CLOSING)
     else if (element == EL_SWITCHGATE_OPENING)
       OpenSwitchgate(x, y);
     else if (element == EL_SWITCHGATE_CLOSING)
index a8bac24c6a44865422a2c3e44d55389631f8fb96..08069f4afa83dd1d9c217157411b20b15ba3c19d 100644 (file)
@@ -51,9 +51,17 @@ static void InitGfx(void);
 static void InitGfxBackground(void);
 static void InitGadgets(void);
 static void InitElementProperties(void);
 static void InitGfxBackground(void);
 static void InitGadgets(void);
 static void InitElementProperties(void);
+static void Execute_Debug_Command(char *);
 
 void OpenAll(void)
 {
 
 void OpenAll(void)
 {
+  if (options.debug_command)
+  {
+    Execute_Debug_Command(options.debug_command);
+
+    exit(0);
+  }
+
   if (options.serveronly)
   {
 #if defined(PLATFORM_UNIX)
   if (options.serveronly)
   {
 #if defined(PLATFORM_UNIX)
@@ -318,7 +326,7 @@ void FreeTileClipmasks()
 
   for(i=0; i<NUM_BITMAPS; i++)
   {
 
   for(i=0; i<NUM_BITMAPS; i++)
   {
-    if (pix[i]->stored_clip_gc)
+    if (pix[i] != NULL && pix[i]->stored_clip_gc)
     {
       XFreeGC(display, pix[i]->stored_clip_gc);
       pix[i]->stored_clip_gc = None;
     {
       XFreeGC(display, pix[i]->stored_clip_gc);
       pix[i]->stored_clip_gc = None;
@@ -357,7 +365,7 @@ void InitGfx()
   DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE);
   rest(200);
 #endif
   DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE);
   rest(200);
 #endif
-  DrawInitText("Loading graphics:",120,FC_GREEN);
+  DrawInitText("Loading graphics:", 120, FC_GREEN);
 
   for(i=0; i<NUM_PICTURES; i++)
   {
 
   for(i=0; i<NUM_PICTURES; i++)
   {
@@ -1589,6 +1597,23 @@ void InitElementProperties()
     Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
 }
 
     Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
 }
 
+void Execute_Debug_Command(char *command)
+{
+  if (strcmp(command, "create soundinfo.conf") == 0)
+  {
+    int i;
+
+    printf("# You can configure additional/alternative sound effects here\n");
+    printf("# (The sounds below are default and therefore commented out.)\n");
+    printf("\n");
+
+    for (i=0; i<NUM_SOUND_EFFECTS; i++)
+      printf("# %s\n",
+            getFormattedSetupEntry(sound_effects[i].text,
+                                   sound_effects[i].default_filename));
+  }
+}
+
 void CloseAllAndExit(int exit_value)
 {
   int i;
 void CloseAllAndExit(int exit_value)
 {
   int i;
index 4f201d97fd015712dafd2cd555fe8a03edd44623..9fa1153550d80a6df83737e2a80a3e4f71c1591c 100644 (file)
@@ -14,9 +14,6 @@
 #include <time.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <time.h>
 #include <sys/time.h>
 #include <sys/types.h>
-/*
-#include <sys/stat.h>
-*/
 #include <stdarg.h>
 #include <ctype.h>
 #include <string.h>
 #include <stdarg.h>
 #include <ctype.h>
 #include <string.h>
@@ -437,6 +434,7 @@ void GetOptions(char *argv[])
   options.network = FALSE;
   options.verbose = FALSE;
   options.debug = FALSE;
   options.network = FALSE;
   options.verbose = FALSE;
   options.debug = FALSE;
+  options.debug_command = NULL;
 
   while (*options_left)
   {
 
   while (*options_left)
   {
@@ -474,19 +472,23 @@ void GetOptions(char *argv[])
       Error(ERR_EXIT_HELP, "unrecognized option '%s'", option);
     else if (strncmp(option, "-help", option_len) == 0)
     {
       Error(ERR_EXIT_HELP, "unrecognized option '%s'", option);
     else if (strncmp(option, "-help", option_len) == 0)
     {
-      printf("Usage: %s [options] [server.name [port]]\n"
+      printf("Usage: %s [options] [<server host> [<server port>]]\n"
             "Options:\n"
             "  -d, --display <host>[:<scr>]  X server display\n"
             "  -b, --basepath <directory>    alternative base directory\n"
             "  -l, --level <directory>       alternative level directory\n"
             "  -g, --graphics <directory>    alternative graphics directory\n"
             "Options:\n"
             "  -d, --display <host>[:<scr>]  X server display\n"
             "  -b, --basepath <directory>    alternative base directory\n"
             "  -l, --level <directory>       alternative level directory\n"
             "  -g, --graphics <directory>    alternative graphics directory\n"
-            "  -s, --sounds <directory>      alternative graphics directory\n"
-            "  -m, --music <directory>       alternative graphics directory\n"
+            "  -s, --sounds <directory>      alternative sounds directory\n"
+            "  -m, --music <directory>       alternative music directory\n"
             "  -n, --network                 network multiplayer game\n"
             "      --serveronly              only start network server\n"
             "  -v, --verbose                 verbose mode\n"
             "      --debug                   display debugging information\n",
             program.command_basename);
             "  -n, --network                 network multiplayer game\n"
             "      --serveronly              only start network server\n"
             "  -v, --verbose                 verbose mode\n"
             "      --debug                   display debugging information\n",
             program.command_basename);
+
+      if (options.debug)
+       printf("      --debug-command <command> execute special command\n");
+
       exit(0);
     }
     else if (strncmp(option, "-display", option_len) == 0)
       exit(0);
     }
     else if (strncmp(option, "-display", option_len) == 0)
@@ -565,6 +567,15 @@ void GetOptions(char *argv[])
     {
       options.debug = TRUE;
     }
     {
       options.debug = TRUE;
     }
+    else if (strncmp(option, "-debug-command", option_len) == 0)
+    {
+      if (option_arg == NULL)
+       Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+
+      options.debug_command = option_arg;
+      if (option_arg == next_option)
+       options_left++;
+    }
     else if (*option == '-')
     {
       Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str);
     else if (*option == '-')
     {
       Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str);
index 7b0189b880f3744e0ff6a0d85137cc7b261bf233..cc66a554d37a928471da13ca22c29b8d9d47b372 100644 (file)
@@ -984,11 +984,12 @@ char *getFormattedSetupEntry(char *token, char *value)
   int i;
   static char entry[MAX_LINE_LEN];
 
   int i;
   static char entry[MAX_LINE_LEN];
 
+  /* start with the token and some spaces to format output line */
   sprintf(entry, "%s:", token);
   for (i=strlen(entry); i<TOKEN_VALUE_POSITION; i++)
   sprintf(entry, "%s:", token);
   for (i=strlen(entry); i<TOKEN_VALUE_POSITION; i++)
-    entry[i] = ' ';
-  entry[i] = '\0';
+    strcat(entry, " ");
 
 
+  /* continue with the token's value */
   strcat(entry, value);
 
   return entry;
   strcat(entry, value);
 
   return entry;
@@ -1809,6 +1810,12 @@ void LoadArtworkInfo()
   artwork.sounds_set_current = artwork.snd_current->name;
   artwork.music_set_current = artwork.mus_current->name;
 
   artwork.sounds_set_current = artwork.snd_current->name;
   artwork.music_set_current = artwork.mus_current->name;
 
+#if 0
+  printf("graphics set == %s\n\n", artwork.graphics_set_current);
+  printf("sounds set == %s\n\n", artwork.sounds_set_current);
+  printf("music set == %s\n\n", artwork.music_set_current);
+#endif
+
   sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
   sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries);
   sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries);
   sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
   sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries);
   sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries);
@@ -1905,19 +1912,18 @@ char *getSetupValue(int type, void *value)
 char *getSetupLine(struct TokenInfo *token_info, char *prefix, int token_nr)
 {
   int i;
 char *getSetupLine(struct TokenInfo *token_info, char *prefix, int token_nr)
 {
   int i;
-  static char entry[MAX_LINE_LEN];
+  char *line;
+  static char token_string[MAX_LINE_LEN];
   int token_type = token_info[token_nr].type;
   void *setup_value = token_info[token_nr].value;
   char *token_text = token_info[token_nr].text;
   char *value_string = getSetupValue(token_type, setup_value);
 
   int token_type = token_info[token_nr].type;
   void *setup_value = token_info[token_nr].value;
   char *token_text = token_info[token_nr].text;
   char *value_string = getSetupValue(token_type, setup_value);
 
-  /* start with the prefix, token and some spaces to format output line */
-  sprintf(entry, "%s%s:", prefix, token_text);
-  for (i=strlen(entry); i<TOKEN_VALUE_POSITION; i++)
-    strcat(entry, " ");
+  /* build complete token string */
+  sprintf(token_string, "%s%s", prefix, token_text);
 
 
-  /* continue with the token's value (which can have different types) */
-  strcat(entry, value_string);
+  /* build setup entry line */
+  line = getFormattedSetupEntry(token_string, value_string);
 
   if (token_type == TYPE_KEY_X11)
   {
 
   if (token_type == TYPE_KEY_X11)
   {
@@ -1929,16 +1935,16 @@ char *getSetupLine(struct TokenInfo *token_info, char *prefix, int token_nr)
        strcmp(keyname, "(unknown)") != 0)
     {
       /* add at least one whitespace */
        strcmp(keyname, "(unknown)") != 0)
     {
       /* add at least one whitespace */
-      strcat(entry, " ");
-      for (i=strlen(entry); i<TOKEN_COMMENT_POSITION; i++)
-       strcat(entry, " ");
+      strcat(line, " ");
+      for (i=strlen(line); i<TOKEN_COMMENT_POSITION; i++)
+       strcat(line, " ");
 
 
-      strcat(entry, "# ");
-      strcat(entry, keyname);
+      strcat(line, "# ");
+      strcat(line, keyname);
     }
   }
 
     }
   }
 
-  return entry;
+  return line;
 }
 
 void LoadLevelSetup_LastSeries()
 }
 
 void LoadLevelSetup_LastSeries()
index 00919d38b9ef604cd384fe06c22628170a9d72fa..22f4fb9695fda5514f3c57f309ff21ab31f70ffb 100644 (file)
 #include "sound.h"
 #include "misc.h"
 #include "setup.h"
 #include "sound.h"
 #include "misc.h"
 #include "setup.h"
+#include "text.h"
 
 
 /* expiration time (in milliseconds) for sound loops */
 #define SOUND_LOOP_EXPIRATION_TIME     200
 
 
 
 /* expiration time (in milliseconds) for sound loops */
 #define SOUND_LOOP_EXPIRATION_TIME     200
 
-#if defined(TARGET_SDL)
 /* one second fading interval == 1000 ticks (milliseconds) */
 #define SOUND_FADING_INTERVAL          1000
 /* one second fading interval == 1000 ticks (milliseconds) */
 #define SOUND_FADING_INTERVAL          1000
+
+#if defined(TARGET_SDL)
 #define SOUND_MAX_VOLUME               SDL_MIX_MAXVOLUME
 #endif
 
 #define SOUND_MAX_VOLUME               SDL_MIX_MAXVOLUME
 #endif
 
@@ -1643,6 +1645,10 @@ static void LoadCustomSound(SoundInfo **snd_info, char *basename)
 {
   char *filename = getCustomSoundFilename(basename);
 
 {
   char *filename = getCustomSoundFilename(basename);
 
+#if 0
+  printf("GOT CUSTOM SOUND FILE '%s'\n", filename);
+#endif
+
   if (strcmp(basename, SND_FILE_UNDEFINED) == 0)
   {
     deleteSoundEntry(snd_info);
   if (strcmp(basename, SND_FILE_UNDEFINED) == 0)
   {
     deleteSoundEntry(snd_info);
@@ -1713,6 +1719,7 @@ static MusicInfo *Load_MOD(char *filename)
 
 void LoadCustomMusic(void)
 {
 
 void LoadCustomMusic(void)
 {
+  static boolean draw_init_text = TRUE;                /* only draw at startup */
   char *music_directory = getCustomMusicDirectory();
   DIR *dir;
   struct dirent *dir_entry;
   char *music_directory = getCustomMusicDirectory();
   DIR *dir;
   struct dirent *dir_entry;
@@ -1727,12 +1734,18 @@ void LoadCustomMusic(void)
     return;
   }
 
     return;
   }
 
+  if (draw_init_text)
+    DrawInitText("Loading music:", 120, FC_GREEN);
+
   while ((dir_entry = readdir(dir)) != NULL)   /* loop until last dir entry */
   {
     char *basename = dir_entry->d_name;
     char *filename = getPath2(music_directory, basename);
     MusicInfo *mus_info = NULL;
 
   while ((dir_entry = readdir(dir)) != NULL)   /* loop until last dir entry */
   {
     char *basename = dir_entry->d_name;
     char *filename = getPath2(music_directory, basename);
     MusicInfo *mus_info = NULL;
 
+    if (draw_init_text)
+      DrawInitText(basename, 150, FC_YELLOW);
+
     if (FileIsSound(basename))
       mus_info = Load_WAV(filename);
     else if (FileIsMusic(basename))
     if (FileIsSound(basename))
       mus_info = Load_WAV(filename);
     else if (FileIsMusic(basename))
@@ -1750,6 +1763,8 @@ void LoadCustomMusic(void)
 
   closedir(dir);
 
 
   closedir(dir);
 
+  draw_init_text = FALSE;
+
   if (num_music == 0)
     Error(ERR_WARN, "cannot find any valid music files in directory '%s'",
          music_directory);
   if (num_music == 0)
     Error(ERR_WARN, "cannot find any valid music files in directory '%s'",
          music_directory);
@@ -1944,6 +1959,10 @@ static void LoadSoundsInfo()
   struct SetupFileList *setup_file_list;
   int i;
 
   struct SetupFileList *setup_file_list;
   int i;
 
+#if 0
+  printf("GOT CUSTOM SOUND CONFIG FILE '%s'\n", filename);
+#endif
+
   /* always start with reliable default values */
   for (i=0; i<num_sounds; i++)
     sound_effect[i].filename = NULL;
   /* always start with reliable default values */
   for (i=0; i<num_sounds; i++)
     sound_effect[i].filename = NULL;
@@ -1959,7 +1978,7 @@ static void LoadSoundsInfo()
 
     freeSetupFileList(setup_file_list);
 
 
     freeSetupFileList(setup_file_list);
 
-#if 1
+#if 0
     for (i=0; i<num_sounds; i++)
     {
       printf("'%s' ", sound_effect[i].text);
     for (i=0; i<num_sounds; i++)
     {
       printf("'%s' ", sound_effect[i].text);
@@ -1974,6 +1993,7 @@ static void LoadSoundsInfo()
 
 static void ReloadCustomSounds()
 {
 
 static void ReloadCustomSounds()
 {
+  static boolean draw_init_text = TRUE;                /* only draw at startup */
   int i;
 
 #if 0
   int i;
 
 #if 0
@@ -1982,18 +2002,26 @@ static void ReloadCustomSounds()
 
   LoadSoundsInfo();
 
 
   LoadSoundsInfo();
 
+  if (draw_init_text)
+    DrawInitText("Loading sounds:", 120, FC_GREEN);
+
 #if 0
   printf("DEBUG: reloading %d sounds ...\n", num_sounds);
 #endif
 
   for(i=0; i<num_sounds; i++)
   {
 #if 0
   printf("DEBUG: reloading %d sounds ...\n", num_sounds);
 #endif
 
   for(i=0; i<num_sounds; i++)
   {
+    if (draw_init_text)
+      DrawInitText(sound_effect[i].text, 150, FC_YELLOW);
+
     if (sound_effect[i].filename)
       LoadSoundToList(sound_effect[i].filename, i);
     else
       LoadSoundToList(sound_effect[i].default_filename, i);
   }
 
     if (sound_effect[i].filename)
       LoadSoundToList(sound_effect[i].filename, i);
     else
       LoadSoundToList(sound_effect[i].default_filename, i);
   }
 
+  draw_init_text = FALSE;
+
   /*
   printf("list size == %d\n", getNumNodes(SoundFileList));
   */
   /*
   printf("list size == %d\n", getNumNodes(SoundFileList));
   */
index 0a54fe23112dc007f02696e5505b25b7d6cb421f..1a130ee0843c6fa9d22c91c1eadbbce2b476400e 100644 (file)
@@ -221,6 +221,7 @@ struct OptionInfo
   boolean network;
   boolean verbose;
   boolean debug;
   boolean network;
   boolean verbose;
   boolean debug;
+  char *debug_command;
 };
 
 struct VideoSystemInfo
 };
 
 struct VideoSystemInfo
index 971c97cac31c0d96e38a65efa06d52f157731119..a7cc5858fdb9bff09810f9ccb682b1b1bf13062a 100644 (file)
@@ -168,7 +168,7 @@ struct SoundEffectInfo sound_effects[] =
   { "sp_disk_orange.pushing",          "zonkpush.wav"          },
   { "sp_disk_yellow.pushing",          "pusch.wav"             },
   { "sp_port.passing",                 "gate.wav"              },
   { "sp_disk_orange.pushing",          "zonkpush.wav"          },
   { "sp_disk_yellow.pushing",          "pusch.wav"             },
   { "sp_port.passing",                 "gate.wav"              },
-  { "sp_exit.entering",                        "buing.wav"             },
+  { "sp_exit.entering",                        "exit.wav"              },
   { "sp_element.exploding",            "booom.wav"             },
   { "sp_sniksnak.moving",              SND_FILE_UNDEFINED      },
   { "sp_electron.moving",              SND_FILE_UNDEFINED      },
   { "sp_element.exploding",            "booom.wav"             },
   { "sp_sniksnak.moving",              SND_FILE_UNDEFINED      },
   { "sp_electron.moving",              SND_FILE_UNDEFINED      },
@@ -330,7 +330,6 @@ struct SoundEffectInfo sound_effects[] =
   { "[not used]",                      "warnton.wav"           },
   { "[not used]",                      "whoosh.wav"            },
   { "[not used]",                      "boom.wav"              },
   { "[not used]",                      "warnton.wav"           },
   { "[not used]",                      "whoosh.wav"            },
   { "[not used]",                      "boom.wav"              },
-  { "[not used]",                      "exit.wav"              },
 #endif
 };
 
 #endif
 };
 
index 91e08e56d2e347b75fb0326d074a71233b3c25f4..1e92361f76729ddc7513f71f8a001398ef36106f 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-05-13 21:42]"
+#define COMPILE_DATE_STRING "[2002-05-19 14:04]"