X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=38aec9ae656aab1e178dc3bd8fb376a431eb44ca;hb=87f531efe267aa3d6a27cc3a68c68c1a4df7b18b;hp=f89f107d8eefb2b59b8081af3bf195dafd3cb2db;hpb=350a8b1817f6696d4ba926e6d55ddd157e45b836;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index f89f107d..38aec9ae 100644 --- a/src/init.c +++ b/src/init.c @@ -1,7 +1,7 @@ /*********************************************************** * Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-2001 Artsoft Entertainment * +* (c) 1995-2002 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -179,8 +179,8 @@ static void InitMixer() static void InitSound() { /* load custom sounds and music */ - InitReloadSounds(artwork.snd_current->name); - InitReloadMusic(artwork.mus_current->name); + InitReloadSounds(artwork.snd_current->identifier); + InitReloadMusic(artwork.mus_current->identifier); /* initialize sound effect lookup table for element actions */ InitGameSound(); @@ -411,22 +411,86 @@ void InitGfxBackground() void ReloadCustomArtwork() { - static char *leveldir_current_name = NULL; + static char *leveldir_current_identifier = NULL; static boolean last_override_level_graphics = FALSE; static boolean last_override_level_sounds = FALSE; static boolean last_override_level_music = FALSE; - if (leveldir_current_name != leveldir_current->name) + /* identifier for new artwork; default: artwork configured in setup */ + char *gfx_new_identifier = artwork.gfx_current->identifier; + char *snd_new_identifier = artwork.snd_current->identifier; + char *mus_new_identifier = artwork.mus_current->identifier; + +#if 0 + printf("graphics --> '%s' ('%s')\n", + artwork.gfx_current_identifier, artwork.gfx_current->filename); + printf("sounds --> '%s' ('%s')\n", + artwork.snd_current_identifier, artwork.snd_current->filename); + printf("music --> '%s' ('%s')\n", + artwork.mus_current_identifier, artwork.mus_current->filename); +#endif + + /* leveldir_current may be invalid (level group, parent link) */ + if (!validLevelSeries(leveldir_current)) + return; + +#if 0 + printf("--> '%s'\n", artwork.gfx_current_identifier); +#endif + + /* when a new level series was selected, check if there was a change + in custom artwork stored in level series directory */ + if (leveldir_current_identifier != leveldir_current->identifier) { - /* force reload of custom artwork after new level series was selected */ - artwork.graphics_set_current_name = NULL; - artwork.sounds_set_current_name = NULL; - artwork.music_set_current_name = NULL; + char *identifier_old = leveldir_current_identifier; + char *identifier_new = leveldir_current->identifier; + + if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) != + getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new)) + gfx_new_identifier = identifier_new; + if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) != + getTreeInfoFromIdentifier(artwork.snd_first, identifier_new)) + snd_new_identifier = identifier_new; + if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) != + getTreeInfoFromIdentifier(artwork.mus_first, identifier_new)) + artwork.mus_current_identifier = NULL; + + leveldir_current_identifier = leveldir_current->identifier; + } - leveldir_current_name = leveldir_current->name; + /* custom level artwork configured in level series configuration file + always overrides custom level artwork stored in level series directory + and (level independant) custom artwork configured in setup menue + (the path entry is needed to send it to the sound child process) */ + if (leveldir_current->graphics_set != NULL) + { + if (leveldir_current->graphics_path) + free(leveldir_current->graphics_path); + leveldir_current->graphics_path = NULL; + leveldir_current->graphics_path = + getStringCopy(getLevelArtworkDir(artwork.gfx_first)); + gfx_new_identifier = leveldir_current->graphics_set; + } + if (leveldir_current->sounds_set != NULL) + { + if (leveldir_current->sounds_path) + free(leveldir_current->sounds_path); + leveldir_current->sounds_path = NULL; + leveldir_current->sounds_path = + getStringCopy(getLevelArtworkDir(artwork.snd_first)); + snd_new_identifier = leveldir_current->sounds_set; + } + if (leveldir_current->music_set != NULL) + { + if (leveldir_current->music_path) + free(leveldir_current->music_path); + leveldir_current->music_path = NULL; + leveldir_current->music_path = + getStringCopy(getLevelArtworkDir(artwork.mus_first)); + mus_new_identifier = leveldir_current->music_set; } - if (artwork.graphics_set_current_name != artwork.gfx_current->name || + if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 || last_override_level_graphics != setup.override_level_graphics) { int i; @@ -443,29 +507,35 @@ void ReloadCustomArtwork() InitTileClipmasks(); InitGfxBackground(); - SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2); + /* force redraw of (open or closed) door graphics */ + SetDoorState(DOOR_OPEN_ALL); + CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); - artwork.graphics_set_current_name = artwork.gfx_current->name; + artwork.gfx_current_identifier = gfx_new_identifier; last_override_level_graphics = setup.override_level_graphics; } - if (artwork.sounds_set_current_name != artwork.snd_current->name || + if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 || last_override_level_sounds != setup.override_level_sounds) { - InitReloadSounds(artwork.snd_current->name); + InitReloadSounds(snd_new_identifier); - artwork.sounds_set_current_name = artwork.snd_current->name; + artwork.snd_current_identifier = snd_new_identifier; last_override_level_sounds = setup.override_level_sounds; } - if (artwork.music_set_current_name != artwork.mus_current->name || + if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 || last_override_level_music != setup.override_level_music) { - InitReloadMusic(artwork.mus_current->name); + InitReloadMusic(mus_new_identifier); - artwork.music_set_current_name = artwork.mus_current->name; + artwork.mus_current_identifier = mus_new_identifier; last_override_level_music = setup.override_level_music; } + +#if 0 + printf("<-- '%s'\n", artwork.gfx_current_identifier); +#endif } void InitGadgets() @@ -1666,19 +1736,39 @@ void InitElementProperties() void Execute_Debug_Command(char *command) { - if (strcmp(command, "create soundinfo.conf") == 0) + if (strcmp(command, "create graphicsinfo.conf") == 0) + { + printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n"); + printf("\n"); + printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics")); + printf("\n"); + printf("%s\n", getFormattedSetupEntry("sort_priority", "100")); + } + else if (strcmp(command, "create soundsinfo.conf") == 0) { int i; printf("# You can configure additional/alternative sound effects here\n"); printf("# (The sounds below are default and therefore commented out.)\n"); printf("\n"); + printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds")); + printf("\n"); + printf("%s\n", getFormattedSetupEntry("sort_priority", "100")); + printf("\n"); for (i=0; i