From c6bdf2fa014d0a3dd50260a409704e487e73e572 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 18 Mar 2007 11:02:00 +0100 Subject: [PATCH] rnd-20070318-1-src --- src/conf_g2m.c | 88 +++------------------------------ src/conf_g2s.c | 8 +++ src/conf_mus.c | 2 + src/conf_mus.h | 60 ++++++++++++----------- src/conf_snd.c | 2 + src/conf_snd.h | 60 ++++++++++++----------- src/conftime.h | 2 +- src/init.c | 2 +- src/libgame/setup.c | 7 +-- src/screens.c | 115 ++++++++++++++++++++++++++++++++++++++++---- src/tools.c | 25 +++++++--- src/tools.h | 3 ++ 12 files changed, 213 insertions(+), 161 deletions(-) diff --git a/src/conf_g2m.c b/src/conf_g2m.c index f1ba0754..754145b8 100644 --- a/src/conf_g2m.c +++ b/src/conf_g2m.c @@ -30,10 +30,18 @@ gamemode_to_music[] = -1, MUS_BACKGROUND }, + { + GFX_SPECIAL_ARG_TITLE_INITIAL, + MUS_BACKGROUND_TITLE_INITIAL + }, { GFX_SPECIAL_ARG_TITLE, MUS_BACKGROUND_TITLE }, + { + GFX_SPECIAL_ARG_MESSAGE_INITIAL, + MUS_BACKGROUND_MESSAGE_INITIAL + }, { GFX_SPECIAL_ARG_MESSAGE, MUS_BACKGROUND_MESSAGE @@ -62,86 +70,6 @@ gamemode_to_music[] = GFX_SPECIAL_ARG_SETUP, MUS_BACKGROUND_SETUP }, - { - -1, - MUS_TITLESCREEN_INITIAL_1 - }, - { - -1, - MUS_TITLESCREEN_INITIAL_2 - }, - { - -1, - MUS_TITLESCREEN_INITIAL_3 - }, - { - -1, - MUS_TITLESCREEN_INITIAL_4 - }, - { - -1, - MUS_TITLESCREEN_INITIAL_5 - }, - { - -1, - MUS_TITLESCREEN_1 - }, - { - -1, - MUS_TITLESCREEN_2 - }, - { - -1, - MUS_TITLESCREEN_3 - }, - { - -1, - MUS_TITLESCREEN_4 - }, - { - -1, - MUS_TITLESCREEN_5 - }, - { - -1, - MUS_TITLEMESSAGE_INITIAL_1 - }, - { - -1, - MUS_TITLEMESSAGE_INITIAL_2 - }, - { - -1, - MUS_TITLEMESSAGE_INITIAL_3 - }, - { - -1, - MUS_TITLEMESSAGE_INITIAL_4 - }, - { - -1, - MUS_TITLEMESSAGE_INITIAL_5 - }, - { - -1, - MUS_TITLEMESSAGE_1 - }, - { - -1, - MUS_TITLEMESSAGE_2 - }, - { - -1, - MUS_TITLEMESSAGE_3 - }, - { - -1, - MUS_TITLEMESSAGE_4 - }, - { - -1, - MUS_TITLEMESSAGE_5 - }, { -1, -1 diff --git a/src/conf_g2s.c b/src/conf_g2s.c index f38fe7fe..6f9ba392 100644 --- a/src/conf_g2s.c +++ b/src/conf_g2s.c @@ -26,10 +26,18 @@ static struct } gamemode_to_sound[] = { + { + GFX_SPECIAL_ARG_TITLE_INITIAL, + SND_BACKGROUND_TITLE_INITIAL + }, { GFX_SPECIAL_ARG_TITLE, SND_BACKGROUND_TITLE }, + { + GFX_SPECIAL_ARG_MESSAGE_INITIAL, + SND_BACKGROUND_MESSAGE_INITIAL + }, { GFX_SPECIAL_ARG_MESSAGE, SND_BACKGROUND_MESSAGE diff --git a/src/conf_mus.c b/src/conf_mus.c index c47a5c88..ac4fa911 100644 --- a/src/conf_mus.c +++ b/src/conf_mus.c @@ -29,7 +29,9 @@ struct ConfigTypeInfo music_config_suffix[] = struct ConfigInfo music_config[] = { { "background", UNDEFINED_FILENAME }, + { "background.TITLE_INITIAL", UNDEFINED_FILENAME }, { "background.TITLE", UNDEFINED_FILENAME }, + { "background.MESSAGE_INITIAL", UNDEFINED_FILENAME }, { "background.MESSAGE", UNDEFINED_FILENAME }, { "background.MAIN", UNDEFINED_FILENAME }, { "background.LEVELS", UNDEFINED_FILENAME }, diff --git a/src/conf_mus.h b/src/conf_mus.h index ec924639..2ab1461e 100644 --- a/src/conf_mus.h +++ b/src/conf_mus.h @@ -19,35 +19,37 @@ /* values for music configuration */ #define MUS_BACKGROUND 0 -#define MUS_BACKGROUND_TITLE 1 -#define MUS_BACKGROUND_MESSAGE 2 -#define MUS_BACKGROUND_MAIN 3 -#define MUS_BACKGROUND_LEVELS 4 -#define MUS_BACKGROUND_SCORES 5 -#define MUS_BACKGROUND_EDITOR 6 -#define MUS_BACKGROUND_INFO 7 -#define MUS_BACKGROUND_SETUP 8 -#define MUS_TITLESCREEN_INITIAL_1 9 -#define MUS_TITLESCREEN_INITIAL_2 10 -#define MUS_TITLESCREEN_INITIAL_3 11 -#define MUS_TITLESCREEN_INITIAL_4 12 -#define MUS_TITLESCREEN_INITIAL_5 13 -#define MUS_TITLESCREEN_1 14 -#define MUS_TITLESCREEN_2 15 -#define MUS_TITLESCREEN_3 16 -#define MUS_TITLESCREEN_4 17 -#define MUS_TITLESCREEN_5 18 -#define MUS_TITLEMESSAGE_INITIAL_1 19 -#define MUS_TITLEMESSAGE_INITIAL_2 20 -#define MUS_TITLEMESSAGE_INITIAL_3 21 -#define MUS_TITLEMESSAGE_INITIAL_4 22 -#define MUS_TITLEMESSAGE_INITIAL_5 23 -#define MUS_TITLEMESSAGE_1 24 -#define MUS_TITLEMESSAGE_2 25 -#define MUS_TITLEMESSAGE_3 26 -#define MUS_TITLEMESSAGE_4 27 -#define MUS_TITLEMESSAGE_5 28 +#define MUS_BACKGROUND_TITLE_INITIAL 1 +#define MUS_BACKGROUND_TITLE 2 +#define MUS_BACKGROUND_MESSAGE_INITIAL 3 +#define MUS_BACKGROUND_MESSAGE 4 +#define MUS_BACKGROUND_MAIN 5 +#define MUS_BACKGROUND_LEVELS 6 +#define MUS_BACKGROUND_SCORES 7 +#define MUS_BACKGROUND_EDITOR 8 +#define MUS_BACKGROUND_INFO 9 +#define MUS_BACKGROUND_SETUP 10 +#define MUS_TITLESCREEN_INITIAL_1 11 +#define MUS_TITLESCREEN_INITIAL_2 12 +#define MUS_TITLESCREEN_INITIAL_3 13 +#define MUS_TITLESCREEN_INITIAL_4 14 +#define MUS_TITLESCREEN_INITIAL_5 15 +#define MUS_TITLESCREEN_1 16 +#define MUS_TITLESCREEN_2 17 +#define MUS_TITLESCREEN_3 18 +#define MUS_TITLESCREEN_4 19 +#define MUS_TITLESCREEN_5 20 +#define MUS_TITLEMESSAGE_INITIAL_1 21 +#define MUS_TITLEMESSAGE_INITIAL_2 22 +#define MUS_TITLEMESSAGE_INITIAL_3 23 +#define MUS_TITLEMESSAGE_INITIAL_4 24 +#define MUS_TITLEMESSAGE_INITIAL_5 25 +#define MUS_TITLEMESSAGE_1 26 +#define MUS_TITLEMESSAGE_2 27 +#define MUS_TITLEMESSAGE_3 28 +#define MUS_TITLEMESSAGE_4 29 +#define MUS_TITLEMESSAGE_5 30 -#define NUM_MUSIC_FILES 29 +#define NUM_MUSIC_FILES 31 #endif /* CONF_MUS_H */ diff --git a/src/conf_snd.c b/src/conf_snd.c index b3761601..ea26f961 100644 --- a/src/conf_snd.c +++ b/src/conf_snd.c @@ -256,7 +256,9 @@ struct ConfigInfo sound_config[] = { "menu.item.activating", "empty.wav" }, { "menu.item.selecting", "base.wav" }, + { "background.TITLE_INITIAL", UNDEFINED_FILENAME }, { "background.TITLE", UNDEFINED_FILENAME }, + { "background.MESSAGE_INITIAL", UNDEFINED_FILENAME }, { "background.MESSAGE", UNDEFINED_FILENAME }, { "background.MAIN", UNDEFINED_FILENAME }, { "background.LEVELS", UNDEFINED_FILENAME }, diff --git a/src/conf_snd.h b/src/conf_snd.h index 860ac5ca..f6059d73 100644 --- a/src/conf_snd.h +++ b/src/conf_snd.h @@ -214,35 +214,37 @@ #define SND_DOOR_CLOSING 193 #define SND_MENU_ITEM_ACTIVATING 194 #define SND_MENU_ITEM_SELECTING 195 -#define SND_BACKGROUND_TITLE 196 -#define SND_BACKGROUND_MESSAGE 197 -#define SND_BACKGROUND_MAIN 198 -#define SND_BACKGROUND_LEVELS 199 -#define SND_BACKGROUND_SCORES 200 -#define SND_BACKGROUND_EDITOR 201 -#define SND_BACKGROUND_INFO 202 -#define SND_BACKGROUND_SETUP 203 -#define SND_TITLESCREEN_INITIAL_1 204 -#define SND_TITLESCREEN_INITIAL_2 205 -#define SND_TITLESCREEN_INITIAL_3 206 -#define SND_TITLESCREEN_INITIAL_4 207 -#define SND_TITLESCREEN_INITIAL_5 208 -#define SND_TITLESCREEN_1 209 -#define SND_TITLESCREEN_2 210 -#define SND_TITLESCREEN_3 211 -#define SND_TITLESCREEN_4 212 -#define SND_TITLESCREEN_5 213 -#define SND_TITLEMESSAGE_INITIAL_1 214 -#define SND_TITLEMESSAGE_INITIAL_2 215 -#define SND_TITLEMESSAGE_INITIAL_3 216 -#define SND_TITLEMESSAGE_INITIAL_4 217 -#define SND_TITLEMESSAGE_INITIAL_5 218 -#define SND_TITLEMESSAGE_1 219 -#define SND_TITLEMESSAGE_2 220 -#define SND_TITLEMESSAGE_3 221 -#define SND_TITLEMESSAGE_4 222 -#define SND_TITLEMESSAGE_5 223 +#define SND_BACKGROUND_TITLE_INITIAL 196 +#define SND_BACKGROUND_TITLE 197 +#define SND_BACKGROUND_MESSAGE_INITIAL 198 +#define SND_BACKGROUND_MESSAGE 199 +#define SND_BACKGROUND_MAIN 200 +#define SND_BACKGROUND_LEVELS 201 +#define SND_BACKGROUND_SCORES 202 +#define SND_BACKGROUND_EDITOR 203 +#define SND_BACKGROUND_INFO 204 +#define SND_BACKGROUND_SETUP 205 +#define SND_TITLESCREEN_INITIAL_1 206 +#define SND_TITLESCREEN_INITIAL_2 207 +#define SND_TITLESCREEN_INITIAL_3 208 +#define SND_TITLESCREEN_INITIAL_4 209 +#define SND_TITLESCREEN_INITIAL_5 210 +#define SND_TITLESCREEN_1 211 +#define SND_TITLESCREEN_2 212 +#define SND_TITLESCREEN_3 213 +#define SND_TITLESCREEN_4 214 +#define SND_TITLESCREEN_5 215 +#define SND_TITLEMESSAGE_INITIAL_1 216 +#define SND_TITLEMESSAGE_INITIAL_2 217 +#define SND_TITLEMESSAGE_INITIAL_3 218 +#define SND_TITLEMESSAGE_INITIAL_4 219 +#define SND_TITLEMESSAGE_INITIAL_5 220 +#define SND_TITLEMESSAGE_1 221 +#define SND_TITLEMESSAGE_2 222 +#define SND_TITLEMESSAGE_3 223 +#define SND_TITLEMESSAGE_4 224 +#define SND_TITLEMESSAGE_5 225 -#define NUM_SOUND_FILES 224 +#define NUM_SOUND_FILES 226 #endif /* CONF_SND_H */ diff --git a/src/conftime.h b/src/conftime.h index 5791a874..cdb199ce 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2007-03-16 01:17" +#define COMPILE_DATE_STRING "2007-03-17 21:32" diff --git a/src/init.c b/src/init.c index c78a3420..7ec7446a 100644 --- a/src/init.c +++ b/src/init.c @@ -1640,7 +1640,7 @@ static void set_sound_parameters(int sound, char **parameter_raw) sound_info[sound].volume = parameter[SND_ARG_VOLUME]; /* sound priority to give certain sounds a higher or lower priority */ - sound_info[sound].volume = parameter[SND_ARG_VOLUME]; + sound_info[sound].priority = parameter[SND_ARG_PRIORITY]; } static void InitSoundInfo() diff --git a/src/libgame/setup.c b/src/libgame/setup.c index bc8a1a34..373ffe33 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1773,8 +1773,7 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, void *insert_ptr = NULL; boolean read_continued_line = FALSE; FILE *file; - int line_nr = 0; - int token_count = 0; + int line_nr = 0, token_count = 0, include_count = 0; #if CHECK_TOKEN_VALUE_SEPARATOR__WARN_IF_MISSING token_value_separator_warning = FALSE; @@ -1873,6 +1872,8 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, free(basepath); free(basename); free(filename_include); + + include_count++; } else { @@ -1928,7 +1929,7 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, Error(ERR_INFO_LINE, "-"); #endif - if (token_count == 0) + if (token_count == 0 && include_count == 0) Error(ERR_WARN, "configuration file '%s' is empty", filename); if (top_recursion_level) diff --git a/src/screens.c b/src/screens.c index 5c194180..5ae63dad 100644 --- a/src/screens.c +++ b/src/screens.c @@ -494,6 +494,13 @@ static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial) return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]); } +#if 0 +static int getTitleScreenGameMode(boolean initial) +{ + return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE); +} +#endif + static int getTitleMessageGameMode(boolean initial) { return (initial ? GAME_MODE_MESSAGE_INITIAL : GAME_MODE_MESSAGE); @@ -509,6 +516,62 @@ static int getTitleMessageBackground(boolean initial) return (initial ? IMG_BACKGROUND_MESSAGE_INITIAL : IMG_BACKGROUND_MESSAGE); } +static int getTitleSound(int nr, boolean initial, boolean is_image) +{ + int mode = (is_image ? + (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE) : + (initial ? GAME_MODE_MESSAGE_INITIAL : GAME_MODE_MESSAGE)); + int base = (is_image ? + (initial ? SND_TITLESCREEN_INITIAL_1 : SND_TITLESCREEN_1) : + (initial ? SND_TITLEMESSAGE_INITIAL_1 : SND_TITLEMESSAGE_1)); + + int sound_global = menu.sound[mode]; + int sound_local = base + nr; + +#if 0 + printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n", + nr, initial, is_image, + sound_global, getSoundListEntry(sound_global)->filename, + sound_local, getSoundListEntry(sound_local)->filename); +#endif + + if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME)) + return sound_local; + + if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME)) + return sound_global; + + return SND_UNDEFINED; +} + +static int getTitleMusic(int nr, boolean initial, boolean is_image) +{ + int mode = (is_image ? + (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE) : + (initial ? GAME_MODE_MESSAGE_INITIAL : GAME_MODE_MESSAGE)); + int base = (is_image ? + (initial ? MUS_TITLESCREEN_INITIAL_1 : MUS_TITLESCREEN_1) : + (initial ? MUS_TITLEMESSAGE_INITIAL_1 : MUS_TITLEMESSAGE_1)); + + int music_global = menu.music[mode]; + int music_local = base + nr; + +#if 0 + printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n", + nr, initial, is_image, + music_global, getMusicListEntry(music_global)->filename, + music_local, getMusicListEntry(music_local)->filename); +#endif + + if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME)) + return music_local; + + if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME)) + return music_global; + + return MUS_UNDEFINED; +} + static int compareTitleControlInfo(const void *object1, const void *object2) { const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1; @@ -1307,6 +1370,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) { static unsigned long title_delay = 0; static int title_screen_nr = 0; + static int last_sound = -1, last_music = -1; boolean return_to_main_menu = FALSE; boolean use_fading_main_menu = TRUE; #if 1 @@ -1315,15 +1379,21 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) boolean use_cross_fading = !show_title_initial; /* default */ #endif struct TitleControlInfo *tci; + int sound, music; if (button == MB_MENU_INITIALIZE) { +#if 0 int last_game_status = game_status; /* save current game status */ +#endif title_delay = 0; title_screen_nr = 0; tci = &title_controls[title_screen_nr]; + last_sound = SND_UNDEFINED; + last_music = MUS_UNDEFINED; + #if 0 /* determine number of title screens to display (images and messages) */ InitializeTitleControls(); @@ -1346,14 +1416,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeOut(REDRAW_ALL); } - /* force TITLE music on title info screen */ - game_status = GAME_MODE_TITLE; - - PlayMenuSound(); - PlayMenuMusic(); - - game_status = last_game_status; /* restore current game status */ - if (tci->is_image) { DrawTitleScreenImage(tci->local_nr, tci->initial); @@ -1367,6 +1429,19 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) title.auto_delay_final = -1; } +#if 1 + sound = getTitleSound(tci->local_nr, tci->initial, tci->is_image); + music = getTitleMusic(tci->local_nr, tci->initial, tci->is_image); + + if (sound != last_sound) + PlayMenuSoundExt(sound); + if (music != last_music) + PlayMenuMusicExt(music); + + last_sound = sound; + last_music = music; +#endif + SetMouseCursor(CURSOR_NONE); FadeIn(REDRAW_ALL); @@ -1415,17 +1490,37 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) if (title_screen_nr < num_title_screens) { - if (!use_cross_fading) - FadeOut(REDRAW_ALL); + sound = getTitleSound(tci->local_nr, tci->initial, tci->is_image); + music = getTitleMusic(tci->local_nr, tci->initial, tci->is_image); + + if (sound == SND_UNDEFINED || sound != last_sound) + FadeSounds(); + if (music == MUS_UNDEFINED || music != last_music) + FadeMusic(); if (use_cross_fading) FadeCrossSaveBackbuffer(); + else + FadeOut(REDRAW_ALL); if (tci->is_image) DrawTitleScreenImage(tci->local_nr, tci->initial); else DrawTitleScreenMessage(tci->local_nr, tci->initial); +#if 1 + sound = getTitleSound(tci->local_nr, tci->initial, tci->is_image); + music = getTitleMusic(tci->local_nr, tci->initial, tci->is_image); + + if (sound != last_sound) + PlayMenuSoundExt(sound); + if (music != last_music) + PlayMenuMusicExt(music); + + last_sound = sound; + last_music = music; +#endif + if (use_cross_fading) FadeCross(REDRAW_ALL); else diff --git a/src/tools.c b/src/tools.c index 6529d447..1c261a00 100644 --- a/src/tools.c +++ b/src/tools.c @@ -6445,10 +6445,8 @@ void InitGraphicInfo_EM(void) #endif } -void PlayMenuSound() +void PlayMenuSoundExt(int sound) { - int sound = menu.sound[game_status]; - if (sound == SND_UNDEFINED) return; @@ -6462,6 +6460,11 @@ void PlayMenuSound() PlaySound(sound); } +void PlayMenuSound() +{ + PlayMenuSoundExt(menu.sound[game_status]); +} + void PlayMenuSoundStereo(int sound, int stereo_position) { if (sound == SND_UNDEFINED) @@ -6477,10 +6480,8 @@ void PlayMenuSoundStereo(int sound, int stereo_position) PlaySoundStereo(sound, stereo_position); } -void PlayMenuSoundIfLoop() +void PlayMenuSoundIfLoopExt(int sound) { - int sound = menu.sound[game_status]; - if (sound == SND_UNDEFINED) return; @@ -6492,10 +6493,13 @@ void PlayMenuSoundIfLoop() PlaySoundLoop(sound); } -void PlayMenuMusic() +void PlayMenuSoundIfLoop() { - int music = menu.music[game_status]; + PlayMenuSoundIfLoopExt(menu.sound[game_status]); +} +void PlayMenuMusicExt(int music) +{ if (music == MUS_UNDEFINED) return; @@ -6505,6 +6509,11 @@ void PlayMenuMusic() PlayMusic(music); } +void PlayMenuMusic() +{ + PlayMenuMusicExt(menu.music[game_status]); +} + void PlaySoundActivating() { #if 0 diff --git a/src/tools.h b/src/tools.h index 149d63da..7cdd23a5 100644 --- a/src/tools.h +++ b/src/tools.h @@ -189,9 +189,12 @@ int getBeltSwitchElementFromBeltNrAndBeltDir(int, int); unsigned int InitRND(long); void InitGraphicInfo_EM(void); +void PlayMenuSoundExt(int); void PlayMenuSound(); void PlayMenuSoundStereo(int, int); +void PlayMenuSoundIfLoopExt(int); void PlayMenuSoundIfLoop(); +void PlayMenuMusicExt(int); void PlayMenuMusic(); void PlaySoundActivating(); void PlaySoundSelecting(); -- 2.34.1