From 7b6d9e43fdb99e1923f4a2a401ae60e7b2975bd8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 30 Apr 2002 01:23:19 +0200 Subject: [PATCH] rnd-20020430-1-src --- src/init.c | 32 +------- src/libgame/setup.c | 24 ++---- src/libgame/setup.h | 2 +- src/libgame/sound.c | 186 ++++++++++++++++++++++++++++++++++++++----- src/libgame/sound.h | 19 ++--- src/libgame/system.c | 9 --- src/libgame/system.h | 4 - src/main.c | 131 ++++++++++++++++++++++++++++-- src/main.h | 99 +++++++++++++++++++++++ src/timestamp.h | 2 +- 10 files changed, 405 insertions(+), 103 deletions(-) diff --git a/src/init.c b/src/init.c index 232f37a4..04259035 100644 --- a/src/init.c +++ b/src/init.c @@ -153,40 +153,10 @@ void InitNetworkServer() #endif } -#if 0 -static void ReloadCustomSounds() -{ - int i; - -#if 1 - printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current); -#endif - - LoadSoundsInfo(); - - for(i=0; i= num_sounds) + return; /* if playlist is full, remove oldest sound */ if (playing_sounds == MAX_SOUNDS_PLAYING) @@ -1228,27 +1240,48 @@ static void LoadCustomSound(SoundInfo **snd_info, char *basename) return; } - if (*snd_info && strcmp(filename, (*snd_info)->source_filename) == 0) + if (*snd_info) { - /* 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. */ + char *filename_old = (*snd_info)->source_filename; - return; - } + 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 (*snd_info) - FreeSound(*snd_info); +#if 1 + printf("[sound '%s' already exists]\n", filename); +#endif + + return; + } + + if (--(*snd_info)->num_references <= 0) + { +#if 1 + printf("[deleting sound '%s']\n", filename_old); +#endif + + /* + FreeSound(*snd_info); + */ + deleteNodeFromList(&SoundFileList, filename_old, FreeSound); + } + } *snd_info = Load_WAV(filename); + (*snd_info)->num_references = 1; + + addNodeToList(&SoundFileList, (*snd_info)->source_filename, *snd_info); } -void InitSoundList(char *sound_name_list[], int num_list_entries) +void InitSoundList(struct SoundEffectInfo *sounds_list, int num_list_entries) { if (Sound == NULL) Sound = checked_calloc(num_list_entries * sizeof(SoundInfo *)); - sound_name = sound_name_list; + sound_effect = sounds_list; num_sounds = num_list_entries; } @@ -1257,7 +1290,13 @@ void LoadSoundToList(char *basename, int list_pos) if (Sound == NULL || list_pos >= num_sounds) return; + printf("loading sound '%s' ... [%d]\n", + basename, getNumNodes(SoundFileList)); + LoadCustomSound(&Sound[list_pos], basename); + + printf("loading sound '%s' done [%d]\n", + basename, getNumNodes(SoundFileList)); } static MusicInfo *Load_MOD(char *filename) @@ -1534,6 +1573,104 @@ void StopSoundExt(int nr, int method) #endif } +ListNode *newListNode() +{ + return checked_calloc(sizeof(ListNode)); +} + +void addNodeToList(ListNode **node_first, char *key, void *content) +{ + ListNode *node_new = newListNode(); + +#if 0 + printf("LIST: adding node with key '%s'\n", key); +#endif + + node_new->key = getStringCopy(key); + node_new->content = content; + node_new->next = *node_first; + *node_first = node_new; +} + +void deleteNodeFromList(ListNode **node_first, char *key, + void (*destructor_function)(void *)) +{ + if (node_first == NULL || *node_first == NULL) + return; + + printf("[CHECKING LIST KEY '%s' == '%s']\n", + (*node_first)->key, key); + + if (strcmp((*node_first)->key, key) == 0) + { + printf("[DELETING LIST ENTRY]\n"); + + free((*node_first)->key); + if (destructor_function) + destructor_function((*node_first)->content); + *node_first = (*node_first)->next; + } + else + deleteNodeFromList(&(*node_first)->next, key, destructor_function); +} + +ListNode *getNodeFromKey(ListNode *node_first, char *key) +{ + if (node_first == NULL) + return NULL; + + if (strcmp(node_first->key, key) == 0) + return node_first; + else + return getNodeFromKey(node_first->next, key); +} + +int getNumNodes(ListNode *node_first) +{ + return (node_first ? 1 + getNumNodes(node_first->next) : 0); +} + +void dumpList(ListNode *node_first) +{ + ListNode *node = node_first; + + while (node) + { + printf("['%s']\n", node->key); + node = node->next; + } + + printf("[%d nodes]\n", getNumNodes(node_first)); +} + +static void LoadSoundsInfo() +{ + char *filename = getCustomSoundConfigFilename(); + struct SetupFileList *setup_file_list; + int i; + + /* always start with reliable default values */ + for (i=0; i '%s'\n", sound_effect[i].text, sound_effect[i].filename); +#endif + } +} + static void ReloadCustomSounds() { int i; @@ -1545,7 +1682,17 @@ static void ReloadCustomSounds() LoadSoundsInfo(); for(i=0; isource_filename) + free(sound->source_filename); + free(sound); } diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 8f6b123b..8481f368 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -192,23 +192,18 @@ struct AudioFormatInfo int fragment_size; /* audio device fragment size in bytes */ }; -#if 0 -struct SoundsInfo +struct SoundEffectInfo { - int num_sounds; - char *sound_name; - -#if 0 - void (*func_reload_sounds)(void); - void (*func_reload_music)(void); -#endif -} -#endif + char *text; + char *default_filename; + char *filename; +}; struct SampleInfo { int type; char *source_filename; + int num_references; long data_len; void *data_ptr; @@ -268,7 +263,7 @@ void StopMusic(void); void StopSound(int); void StopSounds(void); void StopSoundExt(int, int); -void InitSoundList(char **, int); +void InitSoundList(struct SoundEffectInfo *, int); void InitReloadSounds(char *); void InitReloadMusic(char *); void FreeAllSounds(void); diff --git a/src/libgame/system.c b/src/libgame/system.c index 04991992..98b16c42 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -780,15 +780,6 @@ inline void SetAudioMode(boolean enabled) audio.sound_enabled = enabled; } -#if 0 -inline void SetAudioReloadFunctions(void (*func_reload_sounds)(void), - void (*func_reload_music)(void)) -{ - audio.func_reload_sounds = func_reload_sounds; - audio.func_reload_music = func_reload_music; -} -#endif - /* ========================================================================= */ /* event functions */ diff --git a/src/libgame/system.h b/src/libgame/system.h index 46d304bb..316de68e 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -477,10 +477,6 @@ void ReloadCustomImage(Bitmap *, char *); inline void OpenAudio(void); inline void CloseAudio(void); inline void SetAudioMode(boolean); -#if 0 -inline void SetAudioReloadFunctions(void (*func_reload_sounds)(void), - void (*func_reload_music)(void)); -#endif inline void InitEventFilter(EventFilter); inline boolean PendingEvent(void); diff --git a/src/main.c b/src/main.c index 335cee23..a3fb8061 100644 --- a/src/main.c +++ b/src/main.c @@ -137,16 +137,131 @@ char *sound_name[NUM_SOUNDS] = }; /* sound effects: setup file identifiers and corresponding default filenames */ -struct +struct SoundEffectInfo sound_effects[NUM_SOUND_EFFECTS] = { - char *identifier; - char *default_filename; -} -sound_effect[NUM_SOUND_EFFECTS] = + { "infotron_collecting", "infotron.wav" }, + { "zonk_falling", "zonkdown.wav" }, + { "zonk_pushing", "zonkpush.wav" } +}; + +struct SoundEffectInfo sound_effects_NEW[] = { - { "collecting_infotron", "infotron.wav" }, - { "falling_zonk", "zonkdown.wav" }, - { "pushing_zonk", "zonkpush.wav" } + { "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" } + +#if 0 + { "[not used]", "antigrav.wav" }, + { "[not used]", "bong.wav" }, + { "[not used]", "fuel.wav" }, + { "[not used]", "holz.wav" }, + { "[not used]", "hui.wav" }, + { "[not used]", "kabumm.wav" }, + { "[not used]", "kling.wav" }, + { "[not used]", "krach.wav" }, + { "[not used]", "laser.wav" }, + { "[not used]", "quiek.wav" }, + { "[not used]", "rumms.wav" }, + { "[not used]", "schlopp.wav" }, + { "[not used]", "schrff.wav" }, + { "[not used]", "schwirr.wav" }, + { "[not used]", "slurp.wav" }, + { "[not used]", "sproing.wav" }, + { "[not used]", "warnton.wav" }, + { "[not used]", "whoosh.wav" }, + { "[not used]", "boom.wav" }, + { "[not used]", "exit.wav" }, +#endif }; char *element_info[] = diff --git a/src/main.h b/src/main.h index 18d355d0..a820598a 100644 --- a/src/main.h +++ b/src/main.h @@ -397,6 +397,8 @@ extern struct TapeInfo tape; extern struct GameInfo game; extern struct GlobalInfo global; +extern struct SoundEffectInfo sound_effects[]; + extern char *sound_name[]; extern char *element_info[]; extern int num_element_info; @@ -1447,6 +1449,103 @@ extern int num_element_info; #define NUM_SOUND_EFFECTS 3 +#define SND_AMOEBA_GROWING 0 +#define SND_PLAYER_SCREAMING 0 +#define SND_ACID_SPLASHING 0 +#define SND_MOLE_EATING_AMOEBA 0 +#define SND_PENGUIN_ENTERING_EXIT 0 +#define SND_PLAYER_ENTERING_EXIT 0 +#define SND_PLAYER_SOLVING_SOKOBAN 0 +#define SND_TIME_ORB_FULL_IMPACT 0 +#define SND_TIME_ORB_EMPTY_IMPACT 0 +#define SND_ELECTRIC_BULB_LIGHT 0 +#define SND_SOKOBAN_FIELD_FILLING 0 +#define SND_LEVELTIME_RUNNING_OUT 0 +#define SND_EXTRA_TIME_COLLECTING 0 +#define SND_TIME_ORB_FULL_COLLECTING 0 +#define SND_MENU_HALL_OF_FAME 0 +#define SND_KEY_IMPACT 0 +#define SND_EM_KEY_IMPACT 0 +#define SND_BUG_MOVING 0 +#define SND_BUTTERFLY_MOVING 0 +#define SND_ROCK_IMPACT 0 +#define SND_BD_ROCK_IMPACT 0 +#define SND_AMOEBA_TURNS_TO_ROCK 0 +#define SND_NUT_IMPACT 0 +#define SND_PEARL_BREAKING 0 +#define SND_NUT_CRACKING 0 +#define SND_NUT_PUSHING 0 +#define SND_PLAYER_LAUGHING_AT 0 +#define SND_ROBOT_WHEEL_RUNNING 0 +#define SND_TIMEGATE_WHEEL_RUNNING 0 +#define SND_MAGIC_WALL_RUNNING 0 +#define SND_YAMYAM_WAITING 0 +#define SND_MENU_DOOR 0 +#define SND_SWITCHGATE_OPENING 0 +#define SND_SWITCHGATE_CLOSING 0 +#define SND_TIMEGATE_OPENING 0 +#define SND_TIMEGATE_CLOSING 0 +#define SND_EXIT_OPENING 0 +#define SND_EMERALD_IMPACT 0 +#define SND_BD_DIAMOND_IMPACT 0 +#define SND_DIAMOND_IMPACT 0 +#define SND_INFOTRON_IMPACT 0 +#define SND_AMOEBA_TURNS_TO_GEM 0 +#define SND_EMERALD_COLLECTING 0 +#define SND_BD_DIAMOND_COLLECTING 0 +#define SND_DIAMOND_COLLECTING 0 +#define SND_PEARL_COLLECTING 0 +#define SND_CRYSTAL_COLLECTING 0 +#define SND_SPEED_PILL_COLLECTING 0 +#define SND_ENVELOPE_COLLECTING 0 +#define SND_SHIELD_PASSIVE_COLLECTING 0 +#define SND_SHIELD_ACTIVE_COLLECTING 0 +#define SND_DYNAMITE_COLLECTING 0 +#define SND_DYNABOMB_NR_COLLECTING 0 +#define SND_DYNABOMB_SZ_COLLECTING 0 +#define SND_DYNABOMB_XL_COLLECTING 0 +#define SND_KEY_COLLECTING 0 +#define SND_EM_KEY_COLLECTING 0 +#define SND_ROCK_PUSHING 0 +#define SND_BD_ROCK_PUSHING 0 +#define SND_BOMB_PUSHING 0 +#define SND_DX_SUPABOMB_PUSHING 0 +#define SND_TIME_ORB_EMPTY_PUSHING 0 +#define SND_SPRING_PUSHING 0 +#define SND_SOKOBAN_OBJECT_PUSHING 0 +#define SND_SATELLITE_PUSHING 0 +#define SND_SP_DISK_YELLOW_PUSHING 0 +#define SND_DIAMOND_SMASHING 0 +#define SND_MAGIC_WALL_ACTIVATING 0 +#define SND_MENU_INFO_SCREEN 0 +#define SND_EXPLOSION 0 +#define SND_SPACESHIP_MOVING 0 +#define SND_FIREFLY_MOVING 0 +#define SND_ROBOT_MOVING 0 +#define SND_SAND_DIGGING 0 +#define SND_SAND_INVISIBLE_DIGGING 0 +#define SND_TRAP_INACTIVE_DIGGING 0 +#define SND_BALLOON_MOVING 0 +#define SND_LEVELTIME_BONUS 0 +#define SND_DYNAMITE_BURNING 0 +#define SND_SP_BASE_DIGGING 0 +#define SND_SP_BUGGY_BASE_DIGGING 0 +#define SND_SP_INFOTRON_COLLECTING 0 +#define SND_SP_DISK_RED_COLLECTING 0 +#define SND_SP_ZONK_IMPACT 0 +#define SND_SP_ZONK_PUSHING 0 +#define SND_SP_DISK_ORANGE_PUSHING 0 +#define SND_SP_BUGGY_BASE_PASSING 0 +#define SND_SP_EXPLOSION 0 +#define SND_EMPTY_SPACE_DIGGING 0 +#define SND_EM_GATE_PASSING 0 +#define SND_SWITCHGATE_PASSING 0 +#define SND_TIMEGATE_PASSING 0 +#define SND_SP_PORT_PASSING 0 + +#define NUM_SOUND_EFFECTS__NEW 0 + + /* values for game_status */ #define EXITGAME 0 #define MAINMENU 1 diff --git a/src/timestamp.h b/src/timestamp.h index 4abab11c..e0f52345 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-28 23:49]" +#define COMPILE_DATE_STRING "[2002-04-30 00:42]" -- 2.34.1