projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git]
/
src
/
libgame
/
sound.c
diff --git
a/src/libgame/sound.c
b/src/libgame/sound.c
index 21c21fddeebb8e0aba8fa20366e16e20251e9611..473850ddaa729d7121aeaaf5873d658703df51e4 100644
(file)
--- a/
src/libgame/sound.c
+++ b/
src/libgame/sound.c
@@
-48,10
+48,10
@@
#define SOUND_VOLUME_LEFT(x) (stereo_volume[x])
#define SOUND_VOLUME_RIGHT(x) (stereo_volume[SOUND_MAX_LEFT2RIGHT-x])
#define SOUND_VOLUME_LEFT(x) (stereo_volume[x])
#define SOUND_VOLUME_RIGHT(x) (stereo_volume[SOUND_MAX_LEFT2RIGHT-x])
-#define SAME_SOUND_NR(x,
y)
((x).nr == (y).nr)
-#define SAME_SOUND_DATA(x,
y)
((x).data_ptr == (y).data_ptr)
+#define SAME_SOUND_NR(x,
y)
((x).nr == (y).nr)
+#define SAME_SOUND_DATA(x,
y)
((x).data_ptr == (y).data_ptr)
-#define SOUND_VOLUME_FROM_PERCENT(v,
p)
((p) < 0 ? SOUND_MIN_VOLUME : \
+#define SOUND_VOLUME_FROM_PERCENT(v,
p)
((p) < 0 ? SOUND_MIN_VOLUME : \
(p) > 100 ? (v) : \
(p) * (v) / 100)
(p) > 100 ? (v) : \
(p) * (v) / 100)
@@
-59,7
+59,7
@@
#define SOUND_VOLUME_LOOPS(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_loops)
#define SOUND_VOLUME_MUSIC(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_music)
#define SOUND_VOLUME_LOOPS(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_loops)
#define SOUND_VOLUME_MUSIC(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_music)
-#define SETUP_SOUND_VOLUME(v,
s)
((s) & SND_CTRL_MUSIC ? \
+#define SETUP_SOUND_VOLUME(v,
s)
((s) & SND_CTRL_MUSIC ? \
SOUND_VOLUME_MUSIC(v) : \
(s) & SND_CTRL_LOOP ? \
SOUND_VOLUME_LOOPS(v) : \
SOUND_VOLUME_MUSIC(v) : \
(s) & SND_CTRL_LOOP ? \
SOUND_VOLUME_LOOPS(v) : \
@@
-587,11
+587,19
@@
static void *Load_WAV_or_MOD(char *filename)
return NULL;
}
return NULL;
}
+static int compareMusicInfo(const void *object1, const void *object2)
+{
+ const MusicInfo *mi1 = *((MusicInfo **)object1);
+ const MusicInfo *mi2 = *((MusicInfo **)object2);
+
+ return strcmp(mi1->source_filename, mi2->source_filename);
+}
+
static void LoadCustomMusic_NoConf(void)
{
static boolean draw_init_text = TRUE; // only draw at startup
static char *last_music_directory = NULL;
static void LoadCustomMusic_NoConf(void)
{
static boolean draw_init_text = TRUE; // only draw at startup
static char *last_music_directory = NULL;
- char *music_directory = getCustomMusicDirectory();
+ char *music_directory = getCustomMusicDirectory
_NoConf
();
Directory *dir;
DirectoryEntry *dir_entry;
int num_music = getMusicListSize();
Directory *dir;
DirectoryEntry *dir_entry;
int num_music = getMusicListSize();
@@
-609,11
+617,15
@@
static void LoadCustomMusic_NoConf(void)
FreeAllMusic_NoConf();
FreeAllMusic_NoConf();
- if (
(dir = openDirectory(music_directory))
== NULL)
+ if (
music_directory
== NULL)
{
{
- Warn("cannot
read music directory '%s'", music_directory
);
+ Warn("cannot
find music directory with unconfigured music"
);
- audio.music_available = FALSE;
+ return;
+ }
+ else if ((dir = openDirectory(music_directory)) == NULL)
+ {
+ Warn("cannot read music directory '%s'", music_directory);
return;
}
return;
}
@@
-660,6
+672,9
@@
static void LoadCustomMusic_NoConf(void)
closeDirectory(dir);
closeDirectory(dir);
+ // sort music files by filename
+ qsort(Music_NoConf, num_music_noconf, sizeof(MusicInfo *), compareMusicInfo);
+
draw_init_text = FALSE;
}
draw_init_text = FALSE;
}
@@
-675,6
+690,11
@@
int getMusicListSize(void)
music_info->num_dynamic_file_list_entries);
}
music_info->num_dynamic_file_list_entries);
}
+int getMusicListSize_NoConf(void)
+{
+ return num_music_noconf;
+}
+
struct FileInfo *getSoundListEntry(int pos)
{
int num_sounds = getSoundListSize();
struct FileInfo *getSoundListEntry(int pos)
{
int num_sounds = getSoundListSize();
@@
-741,6
+761,16
@@
static MusicInfo *getMusicInfoEntryFromMusicID(int pos)
return mus_info[list_pos];
}
return mus_info[list_pos];
}
+char *getSoundInfoEntryFilename(int pos)
+{
+ SoundInfo *snd_info = getSoundInfoEntryFromSoundID(pos);
+
+ if (snd_info == NULL)
+ return NULL;
+
+ return getBaseNamePtr(snd_info->source_filename);
+}
+
char *getMusicInfoEntryFilename(int pos)
{
MusicInfo *mus_info = getMusicInfoEntryFromMusicID(pos);
char *getMusicInfoEntryFilename(int pos)
{
MusicInfo *mus_info = getMusicInfoEntryFromMusicID(pos);