rnd-20031207-1-src
authorHolger Schemel <info@artsoft.org>
Sun, 7 Dec 2003 01:51:29 +0000 (02:51 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:44:58 +0000 (10:44 +0200)
* fixed boring and sleeping sounds
* added "maze runner" and "maze hunter" movement types
* added extended collision conditions for custom elements
* added warnings for undefined token values in artwork config files

15 files changed:
ChangeLog
Makefile
src/Makefile
src/conftime.h
src/editor.c
src/events.c
src/files.c
src/game.c
src/game.h
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sound.c
src/main.h
src/screens.c
src/tools.c

index 7d4d57308141af5ffb1e4395eed1513d5f733132..b04fc9a3ec6a08263575f3c0ca17e13f02fbbd86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-12-07
+       * fixed boring and sleeping sounds
+
+2003-12-05
+       * added "maze runner" and "maze hunter" movement types
+       * added extended collision conditions for custom elements
+
+2003-12-03
+       * added warnings for undefined token values in artwork config files
+
 2003-12-02
        * added menu entry for level set information to the info screen
 
@@ -10,6 +20,7 @@
 
 2003-11-25
        * added configurable "bored" and "sleeping" animations for the player
+       * added "awakening" sound for player waking up after sleeping
 
 2003-11-22
        * added "copy" and "exchange" functions for custom elements to editor
index ddb3f97da55d64abc2f03c9524f6073da0b79dda..0c0c57f4b21fb887b3efdddc107a18ddf9ae26ef 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,8 +50,8 @@ CROSS_PATH_WIN32=/usr/local/cross-tools/i386-mingw32msvc
 SRC_DIR = src
 MAKE_CMD = $(MAKE) -C $(SRC_DIR)
 
-DEFAULT_TARGET = x11
-DEFAULT_TARGET = sdl
+DEFAULT_TARGET = x11
+DEFAULT_TARGET = sdl
 
 
 # -----------------------------------------------------------------------------
index 0512cf8029a2f6a23bdc9091624273c6b5cd8f23..16c6cd6ac003387bca848dd9a580404d65d77a88 100644 (file)
@@ -41,7 +41,6 @@ PROGNAME = ../$(PROGBASE).exe
 SYS_CFLAGS = -DTARGET_X11
 SYS_LDFLAGS = -s -lalleg
 
-
 else                           # Unix or cross-compiling for MS-DOS and Win32
 
 RM = rm -f
@@ -77,8 +76,7 @@ endif
 
 ifeq ($(TARGET),x11)
 SYS_CFLAGS  = -DTARGET_X11 $(X11_INCL)
-# SYS_LDFLAGS = $(X11_LIBS) -lX11
-SYS_LDFLAGS = $(XLIB_PATH)/libX11.a
+SYS_LDFLAGS = $(X11_LIBS) -lX11
 endif
 
 ifeq ($(TARGET),sdl)
index 2ec21bcf36243505e39553d3201cb7114bb5be01..c19e6d1dc4dd7d42d70bcdf957bdf5e40d883a51 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-12-05 00:32]"
+#define COMPILE_DATE_STRING "[2003-12-07 02:50]"
index 11259a9c91bce9de21ab547924e3c26e0a188ea8..843eb19b3146e8a9db1797f020c8561cb44f537c 100644 (file)
@@ -1071,8 +1071,10 @@ static struct ValueTextInfo options_move_pattern[] =
   { MV_TURNING_LEFT,           "turning left"                  },
   { MV_TURNING_RIGHT,          "turning right"                 },
   { MV_WHEN_PUSHED,            "when pushed"                   },
+#if 0
   { MV_MAZE_RUNNER,            "maze runner style"             },
   { MV_MAZE_HUNTER,            "maze hunter style"             },
+#endif
   { -1,                                NULL                            }
 };
 
@@ -1148,8 +1150,12 @@ static struct ValueTextInfo options_change_direct_action[] =
   { CE_LEFT_BY_PLAYER,         "left by player ..."            },
   { CE_DROPPED_BY_PLAYER,      "dropped by player"             },
   { CE_SWITCHED,               "switched ..."                  },
+#if 0
   { CE_COLLISION_ACTIVE,       "hitting something ..."         },
   { CE_COLLISION_PASSIVE,      "hit by something ..."          },
+#else
+  { CE_COLLISION_ACTIVE,       "collision ..."                 },
+#endif
   { CE_IMPACT,                 "impact (on something)"         },
   { CE_SMASHED,                        "smashed (from above)"          },
   { -1,                                NULL                            }
@@ -1166,8 +1172,10 @@ static struct ValueTextInfo options_change_other_action[] =
   { CE_OTHER_GETS_COLLECTED,   "player collects"               },
   { CE_OTHER_GETS_DROPPED,     "player drops"                  },
   { CE_OTHER_IS_TOUCHING,      "touching ..."                  },
+#if 0
   { CE_OTHER_IS_COLL_ACTIVE,   "hitting ..."                   },
   { CE_OTHER_IS_COLL_PASSIVE,  "hit by ..."                    },
+#endif
   { CE_OTHER_IS_SWITCHING,     "switch of ..."                 },
   { CE_OTHER_IS_CHANGING,      "change of"                     },
   { CE_OTHER_IS_EXPLODING,     "explosion of"                  },
index 5af02c558fccfb9dd6d5a522534e75cdeff60656..de4583dc3142235190b6c4ce7427d77f1b7528cc 100644 (file)
@@ -438,8 +438,6 @@ void HandleButton(int mx, int my, int button)
          printf("      GfxElement[%d][%d] == %d\n", x,y, GfxElement[x][y]);
          printf("      GfxAction[%d][%d] == %d\n", x,y, GfxAction[x][y]);
          printf("      GfxFrame[%d][%d] == %d\n", x,y, GfxFrame[x][y]);
-         printf("      RunnerVisit[%d][%d] == %d\n", x,y, RunnerVisit[x][y]);
-         printf("      PlayerVisit[%d][%d] == %d\n", x,y, PlayerVisit[x][y]);
          printf("\n");
        }
       }
@@ -718,7 +716,7 @@ void HandleKey(Key key, int key_status)
          }
          break;
 
-       case KSYM_s:
+       case KSYM_S:
          if (!global.fps_slowdown)
          {
            global.fps_slowdown = TRUE;
index 5ff8c06a873f0d0f14adc23d7e2258f92e36ed3d..8c268a7ba8a485fc4ca8da2fcaf87263d32fd51b 100644 (file)
@@ -2829,12 +2829,12 @@ void LoadUserDefinedEditorElementList(int **elements, int *num_elements)
 #endif
 }
 
-static struct MusicFileInfo *get_music_file_info(char *basename, int music)
+static struct MusicFileInfo *get_music_file_info_ext(char *basename, int music,
+                                                    boolean is_sound)
 {
   SetupFileHash *setup_file_hash = NULL;
   struct MusicFileInfo tmp_music_file_info, *new_music_file_info;
-  char *filename_music = getCustomMusicFilename(basename);
-  char *filename_prefix, *filename_info;
+  char *filename_music, *filename_prefix, *filename_info;
   struct
   {
     char *token;
@@ -2842,15 +2842,23 @@ static struct MusicFileInfo *get_music_file_info(char *basename, int music)
   }
   token_to_value_ptr[] =
   {
-    { "context",       &tmp_music_file_info.context    },
-    { "title",         &tmp_music_file_info.title      },
-    { "artist",                &tmp_music_file_info.artist     },
-    { "album",         &tmp_music_file_info.album      },
-    { "year",          &tmp_music_file_info.year       },
-    { NULL,            NULL                            },
+    { "title_header",  &tmp_music_file_info.title_header       },
+    { "artist_header", &tmp_music_file_info.artist_header      },
+    { "album_header",  &tmp_music_file_info.album_header       },
+    { "year_header",   &tmp_music_file_info.year_header        },
+
+    { "title",         &tmp_music_file_info.title              },
+    { "artist",                &tmp_music_file_info.artist             },
+    { "album",         &tmp_music_file_info.album              },
+    { "year",          &tmp_music_file_info.year               },
+
+    { NULL,            NULL                                    },
   };
   int i;
 
+  filename_music = (is_sound ? getCustomSoundFilename(basename) :
+                   getCustomMusicFilename(basename));
+
   if (filename_music == NULL)
     return NULL;
 
@@ -2904,7 +2912,9 @@ static struct MusicFileInfo *get_music_file_info(char *basename, int music)
       getStringCopy(value != NULL ? value : UNKNOWN_NAME);
   }
 
+  tmp_music_file_info.basename = basename;
   tmp_music_file_info.music = music;
+  tmp_music_file_info.is_sound = is_sound;
 
   new_music_file_info = checked_malloc(sizeof(struct MusicFileInfo));
   *new_music_file_info = tmp_music_file_info;
@@ -2912,14 +2922,45 @@ static struct MusicFileInfo *get_music_file_info(char *basename, int music)
   return new_music_file_info;
 }
 
+static struct MusicFileInfo *get_music_file_info(char *basename, int music)
+{
+  return get_music_file_info_ext(basename, music, FALSE);
+}
+
+static struct MusicFileInfo *get_sound_file_info(char *basename, int sound)
+{
+  return get_music_file_info_ext(basename, sound, TRUE);
+}
+
+static boolean music_info_listed_ext(struct MusicFileInfo *list,
+                                    char *basename, boolean is_sound)
+{
+  for (; list != NULL; list = list->next)
+    if (list->is_sound == is_sound && strcmp(list->basename, basename) == 0)
+      return TRUE;
+
+  return FALSE;
+}
+
+static boolean music_info_listed(struct MusicFileInfo *list, char *basename)
+{
+  return music_info_listed_ext(list, basename, FALSE);
+}
+
+static boolean sound_info_listed(struct MusicFileInfo *list, char *basename)
+{
+  return music_info_listed_ext(list, basename, TRUE);
+}
+
 void LoadMusicInfo()
 {
   char *music_directory = getCustomMusicDirectory();
   int num_music = getMusicListSize();
   int num_music_noconf = 0;
+  int num_sounds = getSoundListSize();
   DIR *dir;
   struct dirent *dir_entry;
-  struct FileInfo *music;
+  struct FileInfo *music, *sound;
   struct MusicFileInfo *next, **new;
   int i;
 
@@ -2927,8 +2968,15 @@ void LoadMusicInfo()
   {
     next = music_file_info->next;
 
-    if (music_file_info->context)
-      free(music_file_info->context);
+    if (music_file_info->title_header)
+      free(music_file_info->title_header);
+    if (music_file_info->artist_header)
+      free(music_file_info->artist_header);
+    if (music_file_info->album_header)
+      free(music_file_info->album_header);
+    if (music_file_info->year_header)
+      free(music_file_info->year_header);
+
     if (music_file_info->title)
       free(music_file_info->title);
     if (music_file_info->artist)
@@ -2945,7 +2993,9 @@ void LoadMusicInfo()
 
   new = &music_file_info;
 
+#if 0
   printf("::: num_music == %d\n", num_music);
+#endif
 
   for (i = 0; i < num_music; i++)
   {
@@ -2969,9 +3019,12 @@ void LoadMusicInfo()
     printf("::: -> '%s' (configured)\n", music->filename);
 #endif
 
-    *new = get_music_file_info(music->filename, i);
-    if (*new != NULL)
-      new = &(*new)->next;
+    if (!music_info_listed(music_file_info, music->filename))
+    {
+      *new = get_music_file_info(music->filename, i);
+      if (*new != NULL)
+       new = &(*new)->next;
+    }
   }
 
   if ((dir = opendir(music_directory)) == NULL)
@@ -3010,15 +3063,44 @@ void LoadMusicInfo()
     printf("::: -> '%s' (found in directory)\n", basename);
 #endif
 
-    *new = get_music_file_info(basename, MAP_NOCONF_MUSIC(num_music_noconf));
-    if (*new != NULL)
-      new = &(*new)->next;
+    if (!music_info_listed(music_file_info, basename))
+    {
+      *new = get_music_file_info(basename, MAP_NOCONF_MUSIC(num_music_noconf));
+      if (*new != NULL)
+       new = &(*new)->next;
+    }
 
     num_music_noconf++;
   }
 
   closedir(dir);
 
+  for (i = 0; i < num_sounds; i++)
+  {
+    sound = getSoundListEntry(i);
+
+    if (sound->filename == NULL)
+      continue;
+
+    if (strcmp(sound->filename, UNDEFINED_FILENAME) == 0)
+      continue;
+
+    /* a configured file may be not recognized as sound */
+    if (!FileIsSound(sound->filename))
+      continue;
+
+#if 0
+    printf("::: -> '%s' (configured)\n", sound->filename);
+#endif
+
+    if (!sound_info_listed(music_file_info, sound->filename))
+    {
+      *new = get_sound_file_info(sound->filename, i);
+      if (*new != NULL)
+       new = &(*new)->next;
+    }
+  }
+
 #if 0
   /* TEST-ONLY */
   for (next = music_file_info; next != NULL; next = next->next)
index 855e331ab1f5d54b359e3d10b9869dd70048397d..06ec792cab37203c118dfb216c6899e5507e519a 100644 (file)
@@ -1075,6 +1075,7 @@ void InitGame()
     player->anim_delay_counter = 0;
     player->post_delay_counter = 0;
 
+    player->action_waiting = ACTION_DEFAULT;
     player->special_action_bored = ACTION_DEFAULT;
     player->special_action_sleeping = ACTION_DEFAULT;
 
@@ -4878,6 +4879,7 @@ void ContinueMoving(int x, int y)
     CheckElementSideChange(newx, newy, Feld[newx][newy],
                           direction, CE_COLLISION_ACTIVE, -1);
 
+#if 0
     if (IN_LEV_FIELD(nextx, nexty))
     {
       static int opposite_directions[] =
@@ -4945,6 +4947,7 @@ void ContinueMoving(int x, int y)
        }
       }
     }
+#endif
   }
 
   TestIfPlayerTouchesCustomElement(newx, newy);
@@ -6172,6 +6175,110 @@ static boolean CheckElementChange(int x, int y, int element, int trigger_event)
   return CheckElementSideChange(x, y, element, CH_SIDE_ANY, trigger_event, -1);
 }
 
+int GetPlayerAction(struct PlayerInfo *player, int move_dir)
+{
+  int jx = player->jx, jy = player->jy;
+  int element = player->element_nr;
+  int action = (player->is_pushing    ? ACTION_PUSHING    :
+               player->is_digging    ? ACTION_DIGGING    :
+               player->is_collecting ? ACTION_COLLECTING :
+               player->is_moving     ? ACTION_MOVING     :
+               player->is_snapping   ? ACTION_SNAPPING   :
+               player->is_sleeping   ? ACTION_SLEEPING   :
+               player->is_bored      ? ACTION_BORING     :
+               player->is_waiting    ? ACTION_WAITING    : ACTION_DEFAULT);
+
+  if (player->is_sleeping)
+  {
+    if (player->num_special_action_sleeping > 0)
+    {
+      int last_action = player->action_waiting;
+
+      if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
+      {
+       int last_special_action = player->special_action_sleeping;
+       int num_special_action = player->num_special_action_sleeping;
+       int special_action =
+         (last_special_action == ACTION_DEFAULT ? ACTION_SLEEPING_1 :
+          last_special_action == ACTION_SLEEPING ? ACTION_SLEEPING :
+          last_special_action < ACTION_SLEEPING_1 + num_special_action - 1 ?
+          last_special_action + 1 : ACTION_SLEEPING);
+       int special_graphic =
+         el_act_dir2img(player->element_nr, special_action, move_dir);
+
+       player->anim_delay_counter =
+         graphic_info[special_graphic].anim_delay_fixed +
+         SimpleRND(graphic_info[special_graphic].anim_delay_random);
+       player->post_delay_counter =
+         graphic_info[special_graphic].post_delay_fixed +
+         SimpleRND(graphic_info[special_graphic].post_delay_random);
+
+       player->special_action_sleeping = special_action;
+      }
+
+      if (player->anim_delay_counter > 0)
+      {
+       action = player->special_action_sleeping;
+       player->anim_delay_counter--;
+      }
+      else if (player->post_delay_counter > 0)
+      {
+       player->post_delay_counter--;
+      }
+
+      player->action_waiting = action;
+
+      if (last_action != action)
+       PlayLevelSoundElementAction(jx, jy, element, action);
+      else
+       PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
+    }
+  }
+  else if (player->is_bored)
+  {
+    if (player->num_special_action_bored > 0)
+    {
+      int last_action = player->action_waiting;
+
+      if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
+      {
+       int special_action =
+         ACTION_BORING_1 + SimpleRND(player->num_special_action_bored);
+       int special_graphic =
+         el_act_dir2img(player->element_nr, special_action, move_dir);
+
+       player->anim_delay_counter =
+         graphic_info[special_graphic].anim_delay_fixed +
+         SimpleRND(graphic_info[special_graphic].anim_delay_random);
+       player->post_delay_counter =
+         graphic_info[special_graphic].post_delay_fixed +
+         SimpleRND(graphic_info[special_graphic].post_delay_random);
+
+       player->special_action_bored = special_action;
+      }
+
+      if (player->anim_delay_counter > 0)
+      {
+       action = player->special_action_bored;
+       player->anim_delay_counter--;
+      }
+      else if (player->post_delay_counter > 0)
+      {
+       player->post_delay_counter--;
+      }
+
+      player->action_waiting = action;
+
+      if (last_action != action)
+       PlayLevelSoundElementAction(jx, jy, element, action);
+      else
+       PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
+    }
+  }
+
+  return action;
+}
+
 static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
 {
   int jx = player->jx, jy = player->jy;
@@ -6180,7 +6287,11 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
 
   if (is_waiting)
   {
-    int action;
+    int last_action, action;
+    boolean play_sound;
+
+    last_action = (player->is_sleeping ? ACTION_SLEEPING :
+                  player->is_bored ? ACTION_BORING : ACTION_WAITING);
 
     if (!was_waiting)          /* not waiting -> waiting */
     {
@@ -6198,21 +6309,26 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
       InitPlayerGfxAnimation(player, ACTION_WAITING, player->MovDir);
     }
 
-    if (game.player_sleeping_delay_fixed != -1 &&
-       game.player_sleeping_delay_random != -1 &&
+    if (game.player_sleeping_delay_fixed +
+       game.player_sleeping_delay_random > 0 &&
        player->anim_delay_counter == 0 &&
        player->post_delay_counter == 0 &&
        FrameCounter >= player->frame_counter_sleeping)
       player->is_sleeping = TRUE;
-    else if (game.player_boring_delay_fixed != -1 &&
-            game.player_boring_delay_random != -1 &&
+    else if (game.player_boring_delay_fixed +
+            game.player_boring_delay_random > 0 &&
             FrameCounter >= player->frame_counter_bored)
       player->is_bored = TRUE;
 
     action = (player->is_sleeping ? ACTION_SLEEPING :
              player->is_bored ? ACTION_BORING : ACTION_WAITING);
 
-    if (!was_waiting)
+    play_sound =
+      ((player->is_sleeping && player->num_special_action_sleeping == 0) ||
+       (player->is_bored    && player->num_special_action_bored == 0) ||
+       (player->is_waiting && !player->is_sleeping && !player->is_bored));
+
+    if (play_sound && action != last_action)
       PlayLevelSoundElementAction(jx, jy, element, action);
     else
       PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
index 519c6fc3d3692ae33d9965a342eb529b3fbd142b..554fc952787d18500c8b91877d380dd80385ca15 100644 (file)
@@ -72,6 +72,9 @@ void AusgangstuerBlinken(int, int);
 void EdelsteinFunkeln(int, int);
 void MauerWaechst(int, int);
 void MauerAbleger(int, int);
+
+int GetPlayerAction(struct PlayerInfo *, int);
+
 void GameActions(void);
 void ScrollLevel(int, int);
 
index a13212094599ee5e9197f648423d59d9021a7ec3..0c4547e04782a096e6b72865cda4274bb47b42c7 100644 (file)
@@ -283,48 +283,6 @@ void WaitUntilDelayReached(unsigned long *counter_var, unsigned long delay)
 /* random generator functions                                                */
 /* ------------------------------------------------------------------------- */
 
-#if 0
-unsigned int SimpleRND(unsigned int max)
-{
-  return (random_linux_libc(RND_FREE) % max);
-}
-
-unsigned int InitSimpleRND(long seed)
-{
-  if (seed == NEW_RANDOMIZE)
-  {
-    struct timeval current_time;
-
-    gettimeofday(&current_time, NULL);
-    seed = (long)current_time.tv_usec;
-  }
-
-  srandom_linux_libc(RND_FREE, (unsigned int) seed);
-
-  return (unsigned int) seed;
-}
-
-unsigned int RND(unsigned int max)
-{
-  return (random_linux_libc(RND_GAME) % max);
-}
-
-unsigned int InitRND(long seed)
-{
-  if (seed == NEW_RANDOMIZE)
-  {
-    struct timeval current_time;
-
-    gettimeofday(&current_time, NULL);
-    seed = (long)current_time.tv_usec;
-  }
-
-  srandom_linux_libc(RND_GAME, (unsigned int) seed);
-
-  return (unsigned int) seed;
-}
-#endif
-
 unsigned int init_random_number(int nr, long seed)
 {
   if (seed == NEW_RANDOMIZE)
@@ -344,27 +302,10 @@ unsigned int init_random_number(int nr, long seed)
   return (unsigned int) seed;
 }
 
-#if 1
-unsigned int get_random_number(int nr, unsigned int max)
+unsigned int get_random_number(int nr, int max)
 {
   return (max > 0 ? random_linux_libc(nr) % max : 0);
 }
-#else
-unsigned int get_random_number(int nr, unsigned int max)
-{
-  unsigned int rnd = (max > 0 ? random_linux_libc(nr) % max : 0);
-
-  if (nr == 0 && FrameCounter < 2)
-    printf("::: %d [%d]\n", rnd, FrameCounter);
-
-#if 0
-  if (nr == 0 && FrameCounter < 2 && rnd == 8)
-    rnd /= 0;
-#endif
-
-  return rnd;
-}
-#endif
 
 
 /* ------------------------------------------------------------------------- */
index 968837bd5aa211f2029c7bd708363778920b2a0a..0e771902b7dc156e31ef29342f44b5e08cb3438c 100644 (file)
@@ -87,7 +87,7 @@ unsigned int InitRND(long);
 #endif
 
 unsigned int init_random_number(int, long);
-unsigned int get_random_number(int, unsigned int);
+unsigned int get_random_number(int, int);
 
 char *getLoginName(void);
 char *getRealName(void);
index c8d61a828abbd877fee2c5d641132d970089a470..ea4e8463501efadeca90f46fc3670288a9bf411f 100644 (file)
@@ -1885,15 +1885,6 @@ void LoadCustomMusic_NoConf(void)
   struct dirent *dir_entry;
   int num_music = getMusicListSize();
 
-#if 0
-  int ii;
-  for (ii = 0; ii < num_music; ii++)
-  {
-    struct FileInfo *music = getMusicListEntry(ii);
-    printf("sound process: music %d: '%s'\n", ii, music->filename);
-  }
-#endif
-
   if (!audio.sound_available)
     return;
 
@@ -1929,10 +1920,6 @@ void LoadCustomMusic_NoConf(void)
     {
       struct FileInfo *music = getMusicListEntry(i);
 
-#if 0
-      printf("sound process: '%s'\n", music->filename);
-#endif
-
       if (strcmp(basename, music->filename) == 0)
       {
        music_already_used = TRUE;
index 0ed5442c24d24f33728a0b7b4cb8b4e31f44ef37..32e7e3a779968528d7e5fb443dde5425e402f443 100644 (file)
 #define PROGRAM_VERSION_MAJOR  3
 #define PROGRAM_VERSION_MINOR  0
 #define PROGRAM_VERSION_PATCH  8
-#define PROGRAM_VERSION_BUILD  0
+#define PROGRAM_VERSION_BUILD  1
 
 #define PROGRAM_TITLE_STRING   "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING  "Holger Schemel"
@@ -1217,6 +1217,7 @@ struct PlayerInfo
   int anim_delay_counter;
   int post_delay_counter;
 
+  int action_waiting;
   int special_action_bored;
   int special_action_sleeping;
 
@@ -1545,7 +1546,12 @@ struct MusicPrefixInfo
 
 struct MusicFileInfo
 {
-  char *context;
+  char *basename;
+
+  char *title_header;
+  char *artist_header;
+  char *album_header;
+  char *year_header;
 
   char *title;
   char *artist;
@@ -1554,6 +1560,8 @@ struct MusicFileInfo
 
   int music;
 
+  boolean is_sound;
+
   struct MusicFileInfo *next;
 };
 
index d3a0552923b5241810bd9c936b568ad3f89023d6..c7fd1da47d3774cfab6204228677651904eccde9 100644 (file)
@@ -961,7 +961,7 @@ void DrawInfoScreen_Music()
 void HandleInfoScreen_Music(int button)
 {
   static struct MusicFileInfo *list = NULL;
-  int ystart = 150, ystep = 30;
+  int ystart = 150, dy = 30;
   int ybottom = SYSIZE - 20;
   int button_released = !button;
 
@@ -994,6 +994,8 @@ void HandleInfoScreen_Music(int button)
 
   if (button_released || button == MB_MENU_INITIALIZE)
   {
+    int y = 0;
+
     if (list == NULL)
     {
       info_mode = INFO_MODE_MAIN;
@@ -1007,20 +1009,60 @@ void HandleInfoScreen_Music(int button)
     ClearWindow();
     DrawHeadline();
 
-    DrawTextSCentered(100, FONT_TEXT_1, "The Game Background Music:");
+    if (list->is_sound)
+    {
+      PlaySound(list->music);
+
+      DrawTextSCentered(100, FONT_TEXT_1, "The Game Background Sounds:");
+    }
+    else
+    {
+      PlayMusic(list->music);
+
+      DrawTextSCentered(100, FONT_TEXT_1, "The Game Background Music:");
+    }
+
+    if (strcmp(list->title, UNKNOWN_NAME) != 0)
+    {
+      if (strcmp(list->title_header, UNKNOWN_NAME) != 0)
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->title_header);
+
+      DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
+    }
+
+    if (strcmp(list->artist, UNKNOWN_NAME) != 0)
+    {
+      if (strcmp(list->artist_header, UNKNOWN_NAME) != 0)
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->artist_header);
+      else
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "by");
+
+      DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "%s", list->artist);
+    }
+
+    if (strcmp(list->album, UNKNOWN_NAME) != 0)
+    {
+      if (strcmp(list->album_header, UNKNOWN_NAME) != 0)
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->album_header);
+      else
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "from the album");
 
-    DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from");
-    DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", list->title);
-    DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_2, "by");
-    DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "%s", list->artist);
-    DrawTextSCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album");
-    DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3, "\"%s\"", list->album);
+      DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
+    }
+
+    if (strcmp(list->year, UNKNOWN_NAME) != 0)
+    {
+      if (strcmp(list->year_header, UNKNOWN_NAME) != 0)
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->year_header);
+      else
+       DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "from the year");
+
+      DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "%s", list->year);
+    }
 
     DrawTextSCentered(ybottom, FONT_TEXT_4,
                      "Press any key or button for next page");
 
-    PlayMusic(list->music);
-
     list = list->next;
   }
 }
index 068afdef8b6fa22003b984360fc6213366455718..106d251ed5c7d45d01c0dcde7be7d1324f4e43b7 100644 (file)
@@ -529,90 +529,6 @@ void DrawLevelElementAnimationIfNeeded(int x, int y, int element)
     DrawLevelFieldCrumbledSand(x, y);
 }
 
-static int getPlayerAction(struct PlayerInfo *player, int move_dir)
-{
-  int action = (player->is_pushing    ? ACTION_PUSHING    :
-               player->is_digging    ? ACTION_DIGGING    :
-               player->is_collecting ? ACTION_COLLECTING :
-               player->is_moving     ? ACTION_MOVING     :
-               player->is_snapping   ? ACTION_SNAPPING   :
-               player->is_sleeping   ? ACTION_SLEEPING   :
-               player->is_bored      ? ACTION_BORING     :
-               player->is_waiting    ? ACTION_WAITING    : ACTION_DEFAULT);
-
-  if (player->is_sleeping)
-  {
-    if (player->num_special_action_sleeping > 0)
-    {
-      if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
-      {
-       int last_special_action = player->special_action_sleeping;
-       int num_special_action = player->num_special_action_sleeping;
-       int special_action =
-         (last_special_action == ACTION_DEFAULT ? ACTION_SLEEPING_1 :
-          last_special_action == ACTION_SLEEPING ? ACTION_SLEEPING :
-          last_special_action < ACTION_SLEEPING_1 + num_special_action - 1 ?
-          last_special_action + 1 : ACTION_SLEEPING);
-       int special_graphic =
-         el_act_dir2img(player->element_nr, special_action, move_dir);
-
-       player->anim_delay_counter =
-         graphic_info[special_graphic].anim_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].anim_delay_random);
-       player->post_delay_counter =
-         graphic_info[special_graphic].post_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].post_delay_random);
-
-       player->special_action_sleeping = special_action;
-      }
-
-      if (player->anim_delay_counter > 0)
-      {
-       action = player->special_action_sleeping;
-       player->anim_delay_counter--;
-      }
-      else if (player->post_delay_counter > 0)
-      {
-       player->post_delay_counter--;
-      }
-    }
-  }
-  else if (player->is_bored)
-  {
-    if (player->num_special_action_bored > 0)
-    {
-      if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
-      {
-       int special_action =
-         ACTION_BORING_1 + SimpleRND(player->num_special_action_bored);
-       int special_graphic =
-         el_act_dir2img(player->element_nr, special_action, move_dir);
-
-       player->anim_delay_counter =
-         graphic_info[special_graphic].anim_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].anim_delay_random);
-       player->post_delay_counter =
-         graphic_info[special_graphic].post_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].post_delay_random);
-
-       player->special_action_bored = special_action;
-      }
-
-      if (player->anim_delay_counter > 0)
-      {
-       action = player->special_action_bored;
-       player->anim_delay_counter--;
-      }
-      else if (player->post_delay_counter > 0)
-      {
-       player->post_delay_counter--;
-      }
-    }
-  }
-
-  return action;
-}
-
 static int getPlayerGraphic(struct PlayerInfo *player, int move_dir)
 {
   if (player->use_murphy_graphic)
@@ -714,7 +630,7 @@ void DrawPlayer(struct PlayerInfo *player)
 
 #if 1
 
-  action = getPlayerAction(player, move_dir);
+  action = GetPlayerAction(player, move_dir);
 
 #else