-#define COMPILE_DATE_STRING "[2002-08-24 13:38]"
+#define COMPILE_DATE_STRING "[2002-08-24 22:54]"
static boolean last_override_level_sounds = FALSE;
static boolean last_override_level_music = FALSE;
+ /* 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);
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)
{
char *identifier_old = leveldir_current_identifier;
char *identifier_new = leveldir_current->identifier;
- /* force reload of custom artwork after new level series was selected,
- but reload only that part of the artwork that really has changed */
if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
- artwork.gfx_current_identifier = NULL;
+ gfx_new_identifier = identifier_new;
if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
- artwork.snd_current_identifier = NULL;
+ 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;
}
- if (artwork.gfx_current_identifier != artwork.gfx_current->identifier ||
+ /* 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 (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
last_override_level_graphics != setup.override_level_graphics)
{
int i;
SetDoorState(DOOR_OPEN_ALL);
CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
- artwork.gfx_current_identifier = artwork.gfx_current->identifier;
+ artwork.gfx_current_identifier = gfx_new_identifier;
last_override_level_graphics = setup.override_level_graphics;
}
- if (artwork.snd_current_identifier != artwork.snd_current->identifier ||
+ if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
last_override_level_sounds != setup.override_level_sounds)
{
- InitReloadSounds(artwork.snd_current->identifier);
+ InitReloadSounds(snd_new_identifier);
- artwork.snd_current_identifier = artwork.snd_current->identifier;
+ artwork.snd_current_identifier = snd_new_identifier;
last_override_level_sounds = setup.override_level_sounds;
}
- if (artwork.mus_current_identifier != artwork.mus_current->identifier ||
+ if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
last_override_level_music != setup.override_level_music)
{
- InitReloadMusic(artwork.mus_current->identifier);
+ InitReloadMusic(mus_new_identifier);
- artwork.mus_current_identifier = artwork.mus_current->identifier;
+ 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()
return usermusic_dir;
}
+static char *getSetupArtworkDir(TreeInfo *ti)
+{
+ static char *artwork_dir = NULL;
+
+ if (artwork_dir != NULL)
+ free(artwork_dir);
+
+ artwork_dir = getPath2(ti->basepath, ti->fullpath);
+
+ return artwork_dir;
+}
+
+char *getLevelArtworkDir(TreeInfo *ti)
+{
+ char *artwork_path, *artwork_set;
+
+ if (ti == NULL || leveldir_current == NULL)
+ return NOT_AVAILABLE;
+
+ artwork_path =
+ (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_path :
+ ti->type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_path :
+ ti->type == TREE_TYPE_MUSIC_DIR ? leveldir_current->music_path : NULL);
+
+ if (artwork_path != NULL)
+ return artwork_path;
+
+ artwork_set =
+ (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_set :
+ ti->type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_set :
+ ti->type == TREE_TYPE_MUSIC_DIR ? leveldir_current->music_set : NULL);
+
+ if (artwork_set != NULL)
+ {
+ TreeInfo *level_artwork = getTreeInfoFromIdentifier(ti, artwork_set);
+
+ if (level_artwork != NULL)
+ return getSetupArtworkDir(level_artwork);
+ }
+
+ return NOT_AVAILABLE;
+}
+
char *getLevelFilename(int nr)
{
static char *filename = NULL;
return filename;
}
-static char *getSetupArtworkDir(TreeInfo *ti)
-{
- static char *artwork_dir = NULL;
-
- if (artwork_dir != NULL)
- free(artwork_dir);
-
- artwork_dir = getPath2(ti->basepath, ti->fullpath);
-
- return artwork_dir;
-}
-
static char *getCorrectedImageBasename(char *basename)
{
char *result = basename;
if (!setup.override_level_graphics)
{
- /* 1st try: look for special artwork in current level series directory */
+ /* 1st try: look for special artwork configured in level series config */
+ filename = getPath2(getLevelArtworkDir(artwork.gfx_first), basename);
+ if (fileExists(filename))
+ return filename;
+
+ /* 2nd try: look for special artwork in current level series directory */
filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
if (fileExists(filename))
return filename;
}
- /* 2nd try: look for special artwork in configured artwork directory */
+ /* 3rd try: look for special artwork in configured artwork directory */
filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
if (fileExists(filename))
return filename;
- /* 3rd try: look for default artwork in new default artwork directory */
+ /* 4th try: look for default artwork in new default artwork directory */
filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename);
if (fileExists(filename))
return filename;
- /* 4th try: look for default artwork in old default artwork directory */
+ /* 5th try: look for default artwork in old default artwork directory */
filename = getPath2(options.graphics_directory, basename);
if (fileExists(filename))
return filename;
if (!setup.override_level_sounds)
{
- /* 1st try: look for special artwork in current level series directory */
+#if 1
+ /* 1st try: look for special artwork configured in level series config */
+ filename = getPath2(getLevelArtworkDir(artwork.snd_first), basename);
+ if (fileExists(filename))
+ return filename;
+#endif
+
+ /* 2nd try: look for special artwork in current level series directory */
filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
if (fileExists(filename))
return filename;
}
- /* 2nd try: look for special artwork in configured artwork directory */
+ /* 3rd try: look for special artwork in configured artwork directory */
filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
if (fileExists(filename))
return filename;
- /* 3rd try: look for default artwork in new default artwork directory */
+ /* 4th try: look for default artwork in new default artwork directory */
filename = getPath2(getDefaultSoundsDir(SOUNDS_SUBDIR), basename);
if (fileExists(filename))
return filename;
- /* 4th try: look for default artwork in old default artwork directory */
+ /* 5th try: look for default artwork in old default artwork directory */
filename = getPath2(options.sounds_directory, basename);
if (fileExists(filename))
return filename;
if (!setup.override_level_music)
{
- /* 1st try: look for special artwork in current level series directory */
+#if 1
+ /* 1st try: look for special artwork configured in level series config */
+ directory = getStringCopy(getLevelArtworkDir(artwork.mus_first));
+ if (fileExists(directory))
+ return directory;
+#endif
+
+ /* 2nd try: look for special artwork in current level series directory */
directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
if (fileExists(directory))
return directory;
}
- /* 2nd try: look for special artwork in configured artwork directory */
+ /* 3rd try: look for special artwork in configured artwork directory */
directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
+
+#if 1
+ printf("DEBUG: checking directory '%s' ...\n", directory);
+#endif
+
if (fileExists(directory))
return directory;
- /* 3rd try: look for default artwork in new default artwork directory */
+ /* 4th try: look for default artwork in new default artwork directory */
directory = getStringCopy(getDefaultMusicDir(MUSIC_SUBDIR));
if (fileExists(directory))
return directory;
- /* 4th try: look for default artwork in old default artwork directory */
+ /* 5th try: look for default artwork in old default artwork directory */
directory = getStringCopy(options.music_directory);
if (fileExists(directory))
return directory;
#define LEVELINFO_TOKEN_SORT_PRIORITY 7
#define LEVELINFO_TOKEN_LEVEL_GROUP 8
#define LEVELINFO_TOKEN_READONLY 9
+#define LEVELINFO_TOKEN_GRAPHICS_SET 10
+#define LEVELINFO_TOKEN_SOUNDS_SET 11
+#define LEVELINFO_TOKEN_MUSIC_SET 12
-#define NUM_LEVELINFO_TOKENS 10
+#define NUM_LEVELINFO_TOKENS 13
static LevelDirTree ldi;
{ TYPE_INTEGER, &ldi.first_level, "first_level" },
{ TYPE_INTEGER, &ldi.sort_priority, "sort_priority" },
{ TYPE_BOOLEAN, &ldi.level_group, "level_group" },
- { TYPE_BOOLEAN, &ldi.readonly, "readonly" }
+ { TYPE_BOOLEAN, &ldi.readonly, "readonly" },
+ { TYPE_STRING, &ldi.graphics_set, "graphics_set" },
+ { TYPE_STRING, &ldi.sounds_set, "sounds_set" },
+ { TYPE_STRING, &ldi.music_set, "music_set" }
};
static void setTreeInfoToDefaults(TreeInfo *ldi, int type)
if (ldi->type == TREE_TYPE_LEVEL_DIR)
{
ldi->imported_from = NULL;
+ ldi->graphics_set = NULL;
+ ldi->sounds_set = NULL;
+ ldi->music_set = NULL;
+ ldi->graphics_path = getStringCopy(NOT_AVAILABLE);
+ ldi->sounds_path = getStringCopy(NOT_AVAILABLE);
+ ldi->music_path = getStringCopy(NOT_AVAILABLE);
ldi->levels = 0;
ldi->first_level = 0;
ldi->last_level = 0;
ARTWORKCLASS_UNDEFINED)
+char *getLevelArtworkDir(TreeInfo *);
char *getLevelFilename(int);
char *getTapeFilename(int);
char *getScoreFilename(int);
return FALSE;
}
+#if 0
+ printf("PID: %d [%s]\n", getpid(),
+ (IS_CHILD_PROCESS(audio.mixer_pid) ? "child" : "parent"));
+ Delay(10000 * 0);
+#endif
+
if (IS_CHILD_PROCESS(audio.mixer_pid))
Mixer_Main(); /* this function never returns */
else
TreeInfo *ti = (type == SND_CTRL_RELOAD_SOUNDS ? artwork.snd_current :
artwork.mus_current);
unsigned long str_size1 = strlen(leveldir_current->fullpath) + 1;
- unsigned long str_size2 = strlen(ti->basepath) + 1;
- unsigned long str_size3 = strlen(ti->fullpath) + 1;
+ unsigned long str_size2 = strlen(leveldir_current->sounds_path) + 1;
+ unsigned long str_size3 = strlen(leveldir_current->music_path) + 1;
+ unsigned long str_size4 = strlen(ti->basepath) + 1;
+ unsigned long str_size5 = strlen(ti->fullpath) + 1;
boolean override_level_artwork = (type == SND_CTRL_RELOAD_SOUNDS ?
setup.override_level_sounds :
setup.override_level_music);
sizeof(unsigned long)) < 0 ||
write(audio.mixer_pipe[1], &str_size3,
sizeof(unsigned long)) < 0 ||
+ write(audio.mixer_pipe[1], &str_size4,
+ sizeof(unsigned long)) < 0 ||
+ write(audio.mixer_pipe[1], &str_size5,
+ sizeof(unsigned long)) < 0 ||
write(audio.mixer_pipe[1], leveldir_current->fullpath,
str_size1) < 0 ||
- write(audio.mixer_pipe[1], ti->basepath,
+ write(audio.mixer_pipe[1], leveldir_current->sounds_path,
str_size2) < 0 ||
+ write(audio.mixer_pipe[1], leveldir_current->music_path,
+ str_size3) < 0 ||
+ write(audio.mixer_pipe[1], ti->basepath,
+ str_size4) < 0 ||
write(audio.mixer_pipe[1], ti->fullpath,
- str_size3) < 0)
+ str_size5) < 0)
{
Error(ERR_WARN, "cannot pipe to child process -- no sounds");
audio.sound_available = audio.sound_enabled = FALSE;
TreeInfo **ti_ptr = ((snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS) ?
&artwork.snd_current : &artwork.mus_current);
TreeInfo *ti = *ti_ptr;
- unsigned long str_size1, str_size2, str_size3;
+ unsigned long str_size1, str_size2, str_size3, str_size4, str_size5;
static char *set_identifier = NULL;
boolean *override_level_artwork = (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS ?
&setup.override_level_sounds :
if (leveldir_current == NULL)
leveldir_current = checked_calloc(sizeof(TreeInfo));
+
if (ti == NULL)
ti = *ti_ptr = checked_calloc(sizeof(TreeInfo));
if (leveldir_current->fullpath != NULL)
free(leveldir_current->fullpath);
+ if (leveldir_current->sounds_path != NULL)
+ free(leveldir_current->sounds_path);
+ if (leveldir_current->music_path != NULL)
+ free(leveldir_current->music_path);
if (ti->basepath != NULL)
free(ti->basepath);
if (ti->fullpath != NULL)
read(audio.mixer_pipe[0], &str_size2,
sizeof(unsigned long)) != sizeof(unsigned long) ||
read(audio.mixer_pipe[0], &str_size3,
+ sizeof(unsigned long)) != sizeof(unsigned long) ||
+ read(audio.mixer_pipe[0], &str_size4,
+ sizeof(unsigned long)) != sizeof(unsigned long) ||
+ read(audio.mixer_pipe[0], &str_size5,
sizeof(unsigned long)) != sizeof(unsigned long))
Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
leveldir_current->fullpath = checked_calloc(str_size1);
- ti->basepath = checked_calloc(str_size2);
- ti->fullpath = checked_calloc(str_size3);
+ leveldir_current->sounds_path = checked_calloc(str_size2);
+ leveldir_current->music_path = checked_calloc(str_size3);
+ ti->basepath = checked_calloc(str_size4);
+ ti->fullpath = checked_calloc(str_size5);
if (read(audio.mixer_pipe[0], leveldir_current->fullpath,
str_size1) != str_size1 ||
- read(audio.mixer_pipe[0], ti->basepath,
+ read(audio.mixer_pipe[0], leveldir_current->sounds_path,
str_size2) != str_size2 ||
+ read(audio.mixer_pipe[0], leveldir_current->music_path,
+ str_size3) != str_size3 ||
+ read(audio.mixer_pipe[0], ti->basepath,
+ str_size4) != str_size4 ||
read(audio.mixer_pipe[0], ti->fullpath,
- str_size3) != str_size3)
+ str_size5) != str_size5)
Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
if (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS)
strcmp(last_music_directory, music_directory) == 0)
return; /* old and new music directory are the same */
- last_music_directory = music_directory;
+ if (last_music_directory != NULL)
+ free(last_music_directory);
+ last_music_directory = getStringCopy(music_directory);
FreeAllMusic();
char *filename = getPath2(music_directory, basename);
MusicInfo *mus_info = NULL;
+#if 0
+ printf("DEBUG: loading music '%s' ...\n", basename);
+#endif
+
if (draw_init_text)
DrawInitText(basename, 150, FC_YELLOW);
int i;
#if 0
- printf("DEBUG: reloading sounds '%s' ...\n",artwork.sounds_set_current_name);
+ printf("DEBUG: reloading sounds '%s' ...\n",artwork.snd_current_identifier);
#endif
LoadSoundsInfo();
static void ReloadCustomMusic()
{
#if 0
- printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current_name);
+ printf("DEBUG: reloading music '%s' ...\n", artwork.mus_current_identifier);
#endif
#if 0
char *author; /* level or artwork author name */
char *imported_from; /* optional comment for imported levels or artwork */
+ char *graphics_set; /* optional custom graphics set (level tree only) */
+ char *sounds_set; /* optional custom sounds set (level tree only) */
+ char *music_set; /* optional custom music set (level tree only) */
+ char *graphics_path; /* path to optional custom graphics set (level only) */
+ char *sounds_path; /* path to optional custom sounds set (level only) */
+ char *music_path; /* path to optional custom music set (level only) */
+
int levels; /* number of levels in level series */
int first_level; /* first level number (to allow start with 0 or 1) */
int last_level; /* last level number (automatically calculated) */