From 20414a1c99e248151e43daf6ef5433e943afddd6 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 1 May 2002 20:06:32 +0200 Subject: [PATCH] rnd-20020501-1-src --- src/game.c | 11 --- src/libgame/sound.c | 99 ++++++++++++-------- src/main.c | 223 +++++++++++++++++++++++++------------------- src/timestamp.h | 2 +- 4 files changed, 192 insertions(+), 143 deletions(-) diff --git a/src/game.c b/src/game.c index 06d84b98..457748b3 100644 --- a/src/game.c +++ b/src/game.c @@ -2050,17 +2050,6 @@ void Impact(int x, int y) case EL_SP_ZONK: sound = SND_SP_ZONKDOWN; break; - case EL_SCHLUESSEL: - case EL_SCHLUESSEL1: - case EL_SCHLUESSEL2: - case EL_SCHLUESSEL3: - case EL_SCHLUESSEL4: - case EL_EM_KEY_1: - case EL_EM_KEY_2: - case EL_EM_KEY_3: - case EL_EM_KEY_4: - sound = SND_KINK; - break; case EL_ZEIT_VOLL: case EL_ZEIT_LEER: sound = SND_DENG; diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 4b62e341..55a6c74b 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -651,6 +651,7 @@ static void sound_handler(struct SoundControl snd_ctrl) #if !defined(PLATFORM_WIN32) static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl) { + SoundInfo *snd_info; int i, k; if (snd_ctrl.music) @@ -658,6 +659,15 @@ static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl) else if (snd_ctrl.nr >= num_sounds) return; + snd_info = (snd_ctrl.music ? Music[snd_ctrl.nr] : Sound[snd_ctrl.nr]); + if (snd_info == NULL) + { +#if 1 + printf("sound/music %d undefined\n", snd_ctrl.nr); +#endif + return; + } + /* if playlist is full, remove oldest sound */ if (playing_sounds == MAX_SOUNDS_PLAYING) { @@ -752,9 +762,6 @@ static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl) if (!playlist[i].active || (snd_ctrl.music && i == audio.music_channel)) { - SoundInfo *snd_info = - (snd_ctrl.music ? Music[snd_ctrl.nr] : Sound[snd_ctrl.nr]); - snd_ctrl.data_ptr = snd_info->data_ptr; snd_ctrl.data_len = snd_info->data_len; snd_ctrl.format = snd_info->format; @@ -1230,54 +1237,55 @@ static SoundInfo *Load_WAV(char *filename) return snd_info; } -static void LoadCustomSound(SoundInfo **snd_info, char *basename) +static void deleteSoundEntry(SoundInfo **snd_info) { - char *filename = getCustomSoundFilename(basename); - ListNode *node; - - if (filename == NULL) /* (should never happen) */ - { - Error(ERR_WARN, "cannot find sound file '%s'", basename); - return; - } - if (*snd_info) { - char *filename_old = (*snd_info)->source_filename; - - if (strcmp(filename, filename_old) == 0) - { - /* The old and new sound are the same (have the same filename and path). - This usually means that this sound does not exist in this sound set - and a fallback to the existing sound is done. */ - -#if 1 - printf("[sound '%s' already exists (same list entry)]\n", filename); -#endif - - return; - } + char *filename = (*snd_info)->source_filename; #if 1 - printf("[decrementing reference counter of sound '%s']\n", filename_old); + printf("[decrementing reference counter of sound '%s']\n", filename); #endif if (--(*snd_info)->num_references <= 0) { #if 1 - printf("[deleting sound '%s']\n", filename_old); + printf("[deleting sound '%s']\n", filename); #endif /* FreeSound(*snd_info); */ - deleteNodeFromList(&SoundFileList, filename_old, FreeSound); + deleteNodeFromList(&SoundFileList, filename, FreeSound); } + + *snd_info = NULL; } +} - /* check if this sound already exists in the list of sounds */ - node = getNodeFromKey(SoundFileList, filename); - if (node) +static void replaceSoundEntry(SoundInfo **snd_info, char *filename) +{ + ListNode *node; + + /* check if the old and the new sound file are the same */ + if (*snd_info && strcmp((*snd_info)->source_filename, filename) == 0) + { + /* The old and new sound are the same (have the same filename and path). + This usually means that this sound does not exist in this sound set + and a fallback to the existing sound is done. */ + +#if 1 + printf("[sound '%s' already exists (same list entry)]\n", filename); +#endif + + return; + } + + /* delete existing sound file entry */ + deleteSoundEntry(snd_info); + + /* check if the new sound file already exists in the list of sounds */ + if ((node = getNodeFromKey(SoundFileList, filename)) != NULL) { #if 1 printf("[sound '%s' already exists (other list entry)]\n", filename); @@ -1285,14 +1293,31 @@ static void LoadCustomSound(SoundInfo **snd_info, char *basename) *snd_info = (SoundInfo *)node->content; (*snd_info)->num_references++; + } + else if ((*snd_info = Load_WAV(filename)) != NULL) /* load new sound */ + { + (*snd_info)->num_references = 1; + addNodeToList(&SoundFileList, (*snd_info)->source_filename, *snd_info); + } +} - return; +static void LoadCustomSound(SoundInfo **snd_info, char *basename) +{ + char *filename = getCustomSoundFilename(basename); + + if (strcmp(basename, "NONE") == 0) + { + deleteSoundEntry(snd_info); + return; } - *snd_info = Load_WAV(filename); - (*snd_info)->num_references = 1; + if (filename == NULL) + { + Error(ERR_WARN, "cannot find sound file '%s'", basename); + return; + } - addNodeToList(&SoundFileList, (*snd_info)->source_filename, *snd_info); + replaceSoundEntry(snd_info, filename); } void InitSoundList(struct SoundEffectInfo *sounds_list, int num_list_entries) diff --git a/src/main.c b/src/main.c index 9a1b0a8b..2b0716e2 100644 --- a/src/main.c +++ b/src/main.c @@ -140,106 +140,140 @@ char *sound_name[NUM_SOUNDS] = struct SoundEffectInfo sound_effects[NUM_SOUND_EFFECTS] = { { "infotron_collecting", "infotron.wav" }, - { "zonk_falling", "zonkdown.wav" }, + { "zonk_falling", "NONE" }, { "zonk_pushing", "zonkpush.wav" }, { "player_screaming", "autsch.wav" } }; struct SoundEffectInfo sound_effects_NEW[] = { - { "amoeba_growing", "amoebe.wav" }, - { "player_screaming", "autsch.wav" }, - { "acid_splashing", "blurb.wav" }, - { "mole_eating_amoeba", "blurb.wav" }, - { "penguin_entering_exit", "buing.wav" }, - { "player_entering_exit", "buing.wav" }, - { "player_solving_sokoban", "buing.wav" }, - { "time_orb_full_impact", "deng.wav" }, - { "time_orb_empty_impact", "deng.wav" }, - { "electric_bulb_light", "deng.wav" }, - { "sokoban_field_filling", "deng.wav" }, - { "leveltime_running_out", "gong.wav" }, - { "extra_time_collecting", "gong.wav" }, - { "time_orb_full_collecting", "gong.wav" }, - { "menu_hall_of_fame", "halloffame.wav"}, - { "key_impact", "kink.wav" }, - { "em_key_impact", "kink.wav" }, - { "bug_moving", "klapper.wav" }, - { "butterfly_moving", "klapper.wav" }, - { "rock_impact", "klopf.wav" }, - { "bd_rock_impact", "klopf.wav" }, - { "amoeba_turns_to_rock", "klopf.wav" }, - { "nut_impact", "klumpf.wav" }, - { "pearl_breaking", "knack.wav" }, - { "nut_cracking", "knack.wav" }, - { "nut_pushing", "knurk.wav" }, - { "player_laughing_at", "lachen.wav" }, - { "robot_wheel_running", "miep.wav" }, - { "timegate_wheel_running", "miep.wav" }, - { "magic_wall_running", "miep.wav" }, - { "yamyam_waiting", "njam.wav" }, - { "menu_door", "oeffnen.wav" }, - { "switchgate_opening", "oeffnen.wav" }, - { "switchgate_closing", "oeffnen.wav" }, - { "timegate_opening", "oeffnen.wav" }, - { "timegate_closing", "oeffnen.wav" }, - { "exit_opening", "oeffnen.wav" }, - { "emerald_impact", "pling.wav" }, - { "bd_diamond_impact", "pling.wav" }, - { "diamond_impact", "pling.wav" }, - { "infotron_impact", "pling.wav" }, - { "amoeba_turns_to_gem", "pling.wav" }, - { "emerald_collecting", "pong.wav" }, - { "bd_diamond_collecting", "pong.wav" }, - { "diamond_collecting", "pong.wav" }, - { "pearl_collecting", "pong.wav" }, - { "crystal_collecting", "pong.wav" }, - { "speed_pill_collecting", "pong.wav" }, - { "envelope_collecting", "pong.wav" }, - { "shield_passive_collecting","pong.wav" }, - { "shield_active_collecting", "pong.wav" }, - { "dynamite_collecting", "pong.wav" }, - { "dynabomb_nr_collecting", "pong.wav" }, - { "dynabomb_sz_collecting", "pong.wav" }, - { "dynabomb_xl_collecting", "pong.wav" }, - { "key_collecting", "pong.wav" }, - { "em_key_collecting", "pong.wav" }, - { "rock_pushing", "pusch.wav" }, - { "bd_rock_pushing", "pusch.wav" }, - { "bomb_pushing", "pusch.wav" }, - { "dx_supabomb_pushing", "pusch.wav" }, - { "time_orb_empty_pushing", "pusch.wav" }, - { "spring_pushing", "pusch.wav" }, - { "sokoban_object_pushing", "pusch.wav" }, - { "satellite_pushing", "pusch.wav" }, - { "sp_disk_yellow_pushing", "pusch.wav" }, - { "diamond_smashing", "quirk.wav" }, - { "magic_wall_activating", "quirk.wav" }, - { "menu_info_screen", "rhythmloop.wav"}, - { "explosion", "roaaar.wav" }, - { "spaceship_moving", "roehr.wav" }, - { "firefly_moving", "roehr.wav" }, - { "robot_moving", "schlurf.wav" }, - { "sand_digging", "schlurf.wav" }, - { "sand_invisible_digging", "schlurf.wav" }, - { "trap_inactive_digging", "schlurf.wav" }, - { "balloon_moving", "schlurf.wav" }, - { "leveltime_bonus", "sirr.wav" }, - { "dynamite_burning", "zisch.wav" }, - { "sp_base_digging", "base.wav" }, - { "sp_buggy_base_digging", "base.wav" }, - { "sp_infotron_collecting", "infotron.wav" }, - { "sp_disk_red_collecting", "infotron.wav" }, - { "sp_zonk_impact", "zonkdown.wav" }, - { "sp_zonk_pushing", "zonkpush.wav" }, - { "sp_disk_orange_pushing", "zonkpush.wav" }, - { "sp_buggy_base_passing", "bug.wav" }, - { "sp_explosion", "booom.wav" }, - { "empty_space_digging", "empty.wav" }, - { "em_gate_passing", "gate.wav" }, - { "switchgate_passing", "gate.wav" }, - { "timegate_passing", "gate.wav" }, - { "sp_port_passing", "gate.wav" } + /* sounds for Boulder Dash style elements and actions */ + { "bd_empty_space.digging", "empty.wav" }, + { "bd_sand.digging", "schlurf.wav" }, + { "bd_diamond.collecting", "pong.wav" }, + { "bd_diamond.impact", "pling.wav" }, + { "bd_rock.pushing", "pusch.wav" }, + { "bd_rock.impact", "klopf.wav" }, + { "bd_magic_wall.activating", "quirk.wav" }, + { "bd_magic_wall.changing", "quirk.wav" }, + { "bd_magic_wall.running", "miep.wav" }, + { "bd_amoeba.growing", "amoebe.wav" }, + { "bd_amoeba.turning_to_gem", "pling.wav" }, + { "bd_amoeba.turning_to_rock","klopf.wav" }, + { "bd_butterfly.moving", "klapper.wav" }, + { "bd_firefly.moving", "roehr.wav" }, + { "bd_exit.entering", "buing.wav" }, + + /* sounds for Supaplex style elements and actions */ + { "sp_empty_space.digging", "empty.wav" }, + { "sp_base.digging", "base.wav" }, + { "sp_buggy_base.digging", "base.wav" }, + { "sp_buggy_base.passing", "bug.wav" }, + { "sp_infotron.collecting", "infotron.wav" }, + { "sp_infotron.impact", "pling.wav" }, + { "sp_zonk.pushing", "zonkpush.wav" }, + { "sp_zonk.impact", "zonkdown.wav" }, + { "sp_disk_red.collecting", "infotron.wav" }, + { "sp_disk_orange.pushing", "zonkpush.wav" }, + { "sp_disk_yellow.pushing", "pusch.wav" }, + { "sp_port.passing", "gate.wav" }, + { "sp_exit.entering", "buing.wav" }, + { "sp_element.exploding", "booom.wav" }, + + /* sounds for Sokoban style elements and actions */ + { "sokoban_object.pushing", "pusch.wav" }, + { "sokoban_field.filling", "deng.wav" }, + { "sokoban_game.solving", "buing.wav" }, + + /* sounds for Emerald Mine style elements and actions */ + { "empty_space.digging", "empty.wav" }, + { "sand.digging", "schlurf.wav" }, + { "emerald.collecting", "pong.wav" }, + { "emerald.impact", "pling.wav" }, + { "diamond.collecting", "pong.wav" }, + { "diamond.impact", "pling.wav" }, + { "diamond.smashing", "quirk.wav" }, + { "rock.pushing", "pusch.wav" }, + { "rock.impact", "klopf.wav" }, + { "bomb.pushing", "pusch.wav" }, + { "nut.pushing", "knurk.wav" }, + { "nut.cracking", "knack.wav" }, + { "nut.impact", "klumpf.wav" }, + { "dynamite.collecting", "pong.wav" }, + { "dynamite.placing", "deng.wav" }, + { "dynamite.burning", "zisch.wav" }, + { "key.collecting", "pong.wav" }, + { "gate.passing", "gate.wav" }, + { "bug.moving", "klapper.wav" }, + { "spaceship.moving", "roehr.wav" }, + { "yamyam.waiting", "njam.wav" }, + { "robot.moving", "schlurf.wav" }, + { "robot_wheel.activating", "deng.wav" }, + { "robot_wheel.running", "miep.wav" }, + { "magic_wall.activating", "quirk.wav" }, + { "magic_wall.changing", "quirk.wav" }, + { "magic_wall.running", "miep.wav" }, + { "amoeba.growing", "amoebe.wav" }, + { "acid.splashing", "blurb.wav" }, + { "exit.opening", "oeffnen.wav" }, + { "exit.entering", "buing.wav" }, + + /* sounds for Emerald Mine Club style elements and actions */ + { "balloon.moving", "schlurf.wav" }, + { "spring.pushing", "pusch.wav" }, + + /* sounds for Diamond Caves style elements and actions */ + { "pearl.collecting", "pong.wav" }, + { "pearl.breaking", "knack.wav" }, + { "crystal.collecting", "pong.wav" }, + { "envelope.collecting", "pong.wav" }, + { "sand_invisible.digging", "schlurf.wav" }, + { "shield_passive.collecting","pong.wav" }, + { "shield_active.collecting", "pong.wav" }, + { "extra_time.collecting", "gong.wav" }, + { "mole.eating_amoeba", "blurb.wav" }, + { "switchgate.opening", "oeffnen.wav" }, + { "switchgate.closing", "oeffnen.wav" }, + { "switchgate.passing", "gate.wav" }, + { "timegate.opening", "oeffnen.wav" }, + { "timegate.closing", "oeffnen.wav" }, + { "timegate.passing", "gate.wav" }, + { "timegate_wheel.activating","deng.wav" }, + { "timegate_wheel.running", "miep.wav" }, + + /* sounds for DX Boulderdash style elements and actions */ + { "dx_bomb.pushing", "pusch.wav" }, + { "trap_inactive.digging", "schlurf.wav" }, + + /* sounds for Rocks'n'Diamonds style elements and actions */ + { "amoeba.turning_to_gem", "pling.wav" }, + { "amoeba.turning_to_rock", "klopf.wav" }, + { "speed_pill.collecting", "pong.wav" }, + { "penguin.entering_exit", "buing.wav" }, + { "dynabomb_nr.collecting", "pong.wav" }, + { "dynabomb_sz.collecting", "pong.wav" }, + { "dynabomb_xl.collecting", "pong.wav" }, + { "satellite.pushing", "pusch.wav" }, + { "lamp.activating", "deng.wav" }, + { "time_orb_full.collecting", "gong.wav" }, + { "time_orb_full.impact", "deng.wav" }, + { "time_orb_empty.pushing", "pusch.wav" }, + { "time_orb_empty.impact", "deng.wav" }, + + /* sounds for generic elements and actions */ + { "player.screaming", "autsch.wav" }, + { "element.exploding", "roaaar.wav" }, + + /* sounds for other game actions */ + { "game.running_out_of_time", "gong.wav" }, + { "game.leveltime_bonus", "sirr.wav" }, + { "game.laughing_at_player", "lachen.wav" }, + + /* sounds for other non-game actions */ + { "menu.door_opening", "oeffnen.wav" }, + { "menu.door_closing", "oeffnen.wav" }, + { "menu.hall_of_fame", "halloffame.wav"}, + { "menu.info_screen", "rhythmloop.wav"}, #if 0 { "[not used]", "antigrav.wav" }, @@ -248,6 +282,7 @@ struct SoundEffectInfo sound_effects_NEW[] = { "[not used]", "holz.wav" }, { "[not used]", "hui.wav" }, { "[not used]", "kabumm.wav" }, + { "[not used]", "kink.wav" }, { "[not used]", "kling.wav" }, { "[not used]", "krach.wav" }, { "[not used]", "laser.wav" }, diff --git a/src/timestamp.h b/src/timestamp.h index b89c8546..cb6d3284 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-30 01:24]" +#define COMPILE_DATE_STRING "[2002-05-01 19:28]" -- 2.34.1