-#define COMPILE_DATE_STRING "[2003-07-31 20:49]"
+#define COMPILE_DATE_STRING "[2003-08-02 02:07]"
static void InitImages()
{
-#if 1
setLevelArtworkDir(artwork.gfx_first);
-#endif
#if 0
printf("::: InitImages for '%s' ['%s', '%s'] ['%s', '%s']\n",
ReinitializeGraphics();
}
-static void InitSound()
+static void InitSound(char *identifier)
{
+ if (identifier == NULL)
+ identifier = artwork.snd_current->identifier;
+
+ /* set artwork path to send it to the sound server process */
setLevelArtworkDir(artwork.snd_first);
- InitReloadCustomSounds(artwork.snd_current->identifier);
+ InitReloadCustomSounds(identifier);
ReinitializeSounds();
}
-static void InitMusic()
+static void InitMusic(char *identifier)
{
+ if (identifier == NULL)
+ identifier = artwork.mus_current->identifier;
+
+ /* set artwork path to send it to the sound server process */
setLevelArtworkDir(artwork.mus_first);
- InitReloadCustomMusic(artwork.mus_current->identifier);
+ InitReloadCustomMusic(identifier);
ReinitializeMusic();
}
#endif
}
-void ReloadCustomArtwork()
+static char *getNewArtworkIdentifier(int type)
{
- 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;
- static boolean last_own_level_graphics_set = FALSE;
- static boolean last_own_level_sounds_set = FALSE;
- static boolean last_own_level_music_set = FALSE;
- boolean level_graphics_set_changed = FALSE;
- boolean level_sounds_set_changed = FALSE;
- boolean level_music_set_changed = FALSE;
- /* identifier for new artwork; default: artwork configured in setup */
-#if 0
- char *gfx_new_identifier = artwork.gfx_current->identifier;
- char *snd_new_identifier = artwork.snd_current->identifier;
- char *mus_new_identifier = artwork.mus_current->identifier;
-#else
- char *gfx_new_identifier = artwork.gfx_current_identifier;
- char *snd_new_identifier = artwork.snd_current_identifier;
- char *mus_new_identifier = artwork.mus_current_identifier;
-#endif
- boolean redraw_screen = FALSE;
-
-#if 0
- if (leveldir_current_identifier == NULL)
- leveldir_current_identifier = leveldir_current->identifier;
-#endif
-
-#if 0
- printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
- leveldir_current->graphics_set);
- printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
- leveldir_current->identifier);
-#endif
-
-#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
+ static char *leveldir_current_identifier[3] = { NULL, NULL, NULL };
+ static boolean last_override_level_artwork[3] = { FALSE, FALSE, FALSE };
+ static boolean last_has_level_artwork_set[3] = { FALSE, FALSE, FALSE };
+ static boolean initialized[3] = { FALSE, FALSE, FALSE };
+ TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type);
+ boolean setup_override_artwork = SETUP_OVERRIDE_ARTWORK(setup, type);
+ char *setup_artwork_set = SETUP_ARTWORK_SET(setup, type);
+ char *leveldir_identifier = leveldir_current->identifier;
+ char *leveldir_artwork_set = LEVELDIR_ARTWORK_SET(leveldir_current, type);
+ boolean has_level_artwork_set = (leveldir_artwork_set != NULL);
+ char *artwork_current_identifier;
+ char *artwork_new_identifier = NULL; /* default: nothing has changed */
/* leveldir_current may be invalid (level group, parent link) */
if (!validLevelSeries(leveldir_current))
- return;
-
- /* when a new level series was selected, check if there was a change
- in custom artwork stored in level series directory */
- if (1 || leveldir_current_identifier != leveldir_current->identifier)
- {
-#if 0
- char *identifier_old = leveldir_current_identifier;
-#endif
- char *identifier_new = leveldir_current->identifier;
+ return NULL;
+
+
+ /* 1st step: determine artwork set to be activated in descending order:
+ --------------------------------------------------------------------
+ 1. setup artwork (when configured to override everything else)
+ 2. artwork set configured in "levelinfo.conf" of current level set
+ (artwork in level directory will have priority when loading later)
+ 3. artwork in level directory (stored in artwork sub-directory)
+ 4. setup artwork (currently configured in setup menu) */
+
+ if (setup_override_artwork)
+ artwork_current_identifier = setup_artwork_set;
+ else if (leveldir_artwork_set != NULL)
+ artwork_current_identifier = leveldir_artwork_set;
+ else if (getTreeInfoFromIdentifier(artwork_first_node, leveldir_identifier))
+ artwork_current_identifier = leveldir_identifier;
+ else
+ artwork_current_identifier = setup_artwork_set;
-#if 0
- printf("::: 1: ['%s'] '%s', '%s' [%lx, %lx]\n",
- gfx_new_identifier, identifier_old, identifier_new,
- getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old),
- getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new));
-#endif
-#if 0
- if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new) == NULL)
- gfx_new_identifier = GRAPHICS_SUBDIR;
- else if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
- getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
- gfx_new_identifier = identifier_new;
-#else
- if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
- gfx_new_identifier = identifier_new;
- else
- gfx_new_identifier = setup.graphics_set;
-#endif
+ /* 2nd step: check if it is really needed to reload artwork set
+ ------------------------------------------------------------ */
-#if 0
- if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_new) == NULL)
- snd_new_identifier = SOUNDS_SUBDIR;
- else if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
- getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
- snd_new_identifier = identifier_new;
-#else
- if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
- snd_new_identifier = identifier_new;
- else
- snd_new_identifier = setup.sounds_set;
-#endif
+ /* ---------- reload if level set and also artwork set has changed ------- */
+ if (leveldir_current_identifier[type] != leveldir_identifier &&
+ (last_has_level_artwork_set[type] || has_level_artwork_set))
+ artwork_new_identifier = artwork_current_identifier;
-#if 0
- if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) == NULL)
- mus_new_identifier = MUSIC_SUBDIR;
- else if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
- getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
- mus_new_identifier = identifier_new;
-#else
- if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
- mus_new_identifier = identifier_new;
- else
- mus_new_identifier = setup.music_set;
-#endif
+ leveldir_current_identifier[type] = leveldir_identifier;
+ last_has_level_artwork_set[type] = has_level_artwork_set;
-#if 0
- printf("::: 2: ['%s'] '%s', '%s'\n",
- gfx_new_identifier, identifier_old, identifier_new);
-#endif
+ /* ---------- reload if "override artwork" setting has changed ----------- */
+ if (last_override_level_artwork[type] != setup_override_artwork)
+ artwork_new_identifier = artwork_current_identifier;
-#if 0
- leveldir_current_identifier = leveldir_current->identifier;
-#endif
- }
+ last_override_level_artwork[type] = setup_override_artwork;
- /* custom level artwork configured in level series configuration file
- always overrides custom level artwork stored in level series directory
- and (level independent) custom artwork configured in setup menu */
- if (leveldir_current->graphics_set != NULL)
- gfx_new_identifier = leveldir_current->graphics_set;
- if (leveldir_current->sounds_set != NULL)
- snd_new_identifier = leveldir_current->sounds_set;
- if (leveldir_current->music_set != NULL)
- mus_new_identifier = leveldir_current->music_set;
+ /* ---------- reload if current artwork identifier has changed ----------- */
+ if (strcmp(ARTWORK_CURRENT_IDENTIFIER(artwork, type),
+ artwork_current_identifier) != 0)
+ artwork_new_identifier = artwork_current_identifier;
- if (leveldir_current_identifier != leveldir_current->identifier)
- {
- if (last_own_level_graphics_set || leveldir_current->graphics_set != NULL)
- level_graphics_set_changed = TRUE;
+ *(&(ARTWORK_CURRENT_IDENTIFIER(artwork, type))) = artwork_current_identifier;
- if (last_own_level_sounds_set || leveldir_current->sounds_set != NULL)
- level_sounds_set_changed = TRUE;
-
- if (last_own_level_music_set || leveldir_current->music_set != NULL)
- level_music_set_changed = TRUE;
-
- last_own_level_graphics_set = (leveldir_current->graphics_set != NULL);
- last_own_level_sounds_set = (leveldir_current->sounds_set != NULL);
- last_own_level_music_set = (leveldir_current->music_set != NULL);
- }
-
-#if 1
- leveldir_current_identifier = leveldir_current->identifier;
-#endif
-
- if (setup.override_level_graphics)
- gfx_new_identifier = artwork.gfx_current->identifier;
- if (setup.override_level_sounds)
- snd_new_identifier = artwork.snd_current->identifier;
- if (setup.override_level_music)
- mus_new_identifier = artwork.mus_current->identifier;
+ /* ---------- do not reload directly after starting ---------------------- */
+ if (!initialized[type])
+ artwork_new_identifier = NULL;
+ initialized[type] = TRUE;
#if 0
- printf("CHECKING OLD/NEW GFX:\n OLD: '%s'\n NEW: '%s' ['%s', '%s'] [%d]\n",
- artwork.gfx_current_identifier, gfx_new_identifier,
+ printf("CHECKING OLD/NEW GFX:\n- OLD: %s\n- NEW: %s ['%s', '%s'] ['%s']\n",
+ artwork.gfx_current_identifier, artwork_current_identifier,
artwork.gfx_current->identifier, leveldir_current->graphics_set,
- level_graphics_set_changed);
+ artwork_new_identifier);
#endif
- if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
- last_override_level_graphics != setup.override_level_graphics ||
- level_graphics_set_changed)
+ return artwork_new_identifier;
+}
+
+void ReloadCustomArtwork()
+{
+ char *gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS);
+ char *snd_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_SOUNDS);
+ char *mus_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_MUSIC);
+ boolean redraw_screen = FALSE;
+
+ if (gfx_new_identifier != NULL)
{
#if 0
printf("RELOADING GRAPHICS '%s' -> '%s' ['%s']\n",
artwork.gfx_current->identifier);
#endif
-#if 0
- artwork.gfx_current =
- getTreeInfoFromIdentifier(artwork.gfx_first, gfx_new_identifier);
-#endif
-#if 0
- artwork.gfx_current_identifier = gfx_new_identifier;
-#endif
-
-#if 0
- setLevelArtworkDir(artwork.gfx_first);
-#endif
-
ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
InitImages();
-#if 0
- printf("::: %d\n", menu.list_size[GAME_MODE_LEVELS]);
-#endif
-
FreeTileClipmasks();
InitTileClipmasks();
-#if 0
- artwork.gfx_current =
- getTreeInfoFromIdentifier(artwork.gfx_first, gfx_new_identifier);
-#endif
-#if 0
- printf("::: '%s', %lx\n", gfx_new_identifier, artwork.gfx_current);
-#endif
-
-#if 0
- artwork.gfx_current_identifier = artwork.gfx_current->identifier;
-#endif
- artwork.gfx_current_identifier = gfx_new_identifier;
- last_override_level_graphics = setup.override_level_graphics;
-
-#if 0
- printf("DONE RELOADING GFX: '%s' ['%s']\n",
- artwork.gfx_current_identifier, artwork.gfx_current->identifier);
-#endif
redraw_screen = TRUE;
}
- if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
- last_override_level_sounds != setup.override_level_sounds ||
- level_sounds_set_changed)
+ if (snd_new_identifier != NULL)
{
-#if 0
- printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
- artwork.snd_current_identifier,
- artwork.snd_current->identifier,
- snd_new_identifier);
-#endif
-
- /* set artwork path to send it to the sound server process */
- setLevelArtworkDir(artwork.snd_first);
-
ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
- InitReloadCustomSounds(snd_new_identifier);
- ReinitializeSounds();
-
-#if 0
- artwork.snd_current =
- getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
- artwork.snd_current_identifier = artwork.snd_current->identifier;
-#endif
- artwork.snd_current_identifier = snd_new_identifier;
- last_override_level_sounds = setup.override_level_sounds;
+ InitSound(snd_new_identifier);
redraw_screen = TRUE;
}
- if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
- last_override_level_music != setup.override_level_music ||
- level_music_set_changed)
+ if (mus_new_identifier != NULL)
{
- /* set artwork path to send it to the sound server process */
- setLevelArtworkDir(artwork.mus_first);
-
ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
- InitReloadCustomMusic(mus_new_identifier);
- ReinitializeMusic();
-
-#if 0
- artwork.mus_current =
- getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
- artwork.mus_current_identifier = artwork.mus_current->identifier;
-#endif
- artwork.mus_current_identifier = mus_new_identifier;
- last_override_level_music = setup.override_level_music;
+ InitMusic(mus_new_identifier);
redraw_screen = TRUE;
}
InitLevelArtworkInfo();
InitImages(); /* needs to know current level directory */
- InitSound(); /* needs to know current level directory */
- InitMusic(); /* needs to know current level directory */
+ InitSound(NULL); /* needs to know current level directory */
+ InitMusic(NULL); /* needs to know current level directory */
InitGfxBackground();
void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
{
-#if 0
- struct FileInfo *file_list = artwork_info->file_list;
- struct ConfigInfo *suffix_list = artwork_info->suffix_list;
- char **base_prefixes = artwork_info->base_prefixes;
- char **ext1_suffixes = artwork_info->ext1_suffixes;
- char **ext2_suffixes = artwork_info->ext2_suffixes;
- char **ext3_suffixes = artwork_info->ext3_suffixes;
- char **ignore_tokens = artwork_info->ignore_tokens;
- int num_file_list_entries = artwork_info->num_file_list_entries;
- int num_suffix_list_entries = artwork_info->num_suffix_list_entries;
- int num_base_prefixes = artwork_info->num_base_prefixes;
- int num_ext1_suffixes = artwork_info->num_ext1_suffixes;
- int num_ext2_suffixes = artwork_info->num_ext2_suffixes;
- int num_ext3_suffixes = artwork_info->num_ext3_suffixes;
- int num_ignore_tokens = artwork_info->num_ignore_tokens;
- char *filename = getCustomArtworkConfigFilename(artwork_info->type);
- SetupFileHash *setup_file_hash, *extra_file_hash;
- char *known_token_value = KNOWN_TOKEN_VALUE;
- int i, j, k, l;
-#else
struct FileInfo *file_list = artwork_info->file_list;
int num_file_list_entries = artwork_info->num_file_list_entries;
int num_suffix_list_entries = artwork_info->num_suffix_list_entries;
char *filename_base, *filename_local;
int i, j;
-#endif
#if 0
printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename);
artwork_info->num_property_mapping_entries = 0;
}
-#if 1
/* first look for special artwork configured in level series config */
filename_base = getCustomArtworkLevelConfigFilename(artwork_info->type);
if (fileExists(filename_base))
LoadArtworkConfigFromFilename(artwork_info, filename_base);
-#if 0
- for(i=0; i<num_file_list_entries; i++)
- if (strcmp(file_list[i].token, "background") == 0)
- printf("!!! base !!! -- '%s' -> '%s'\n",
- file_list[i].token, file_list[i].filename);
-#endif
-
-#if 1
filename_local = getCustomArtworkConfigFilename(artwork_info->type);
if (filename_local != NULL && strcmp(filename_base, filename_local) != 0)
LoadArtworkConfigFromFilename(artwork_info, filename_local);
-
-#if 0
- for(i=0; i<num_file_list_entries; i++)
- if (strcmp(file_list[i].token, "background") == 0)
- printf("!!! local !!! -- '%s' -> '%s'\n",
- file_list[i].token, file_list[i].filename);
-#endif
-
-#endif
-#endif
-
-#if 0
-
- if (filename == NULL)
- return;
-
- if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
- return;
-
- /* read parameters for all known config file tokens */
- for (i=0; i<num_file_list_entries; i++)
- read_token_parameters(setup_file_hash, suffix_list, &file_list[i]);
-
- /* set all tokens that can be ignored here to "known" keyword */
- for (i=0; i < num_ignore_tokens; i++)
- setHashEntry(setup_file_hash, ignore_tokens[i], known_token_value);
-
- /* copy all unknown config file tokens to extra config list */
- extra_file_hash = newSetupFileHash();
- BEGIN_HASH_ITERATION(setup_file_hash, itr)
- {
- if (strcmp(HASH_ITERATION_VALUE(itr), known_token_value) != 0)
- setHashEntry(extra_file_hash,
- HASH_ITERATION_TOKEN(itr), HASH_ITERATION_VALUE(itr));
- }
- END_HASH_ITERATION(setup_file_hash, itr)
-
- /* at this point, we do not need the config file hash anymore -- free it */
- freeSetupFileHash(setup_file_hash);
-
- /* now try to determine valid, dynamically defined config tokens */
-
- BEGIN_HASH_ITERATION(extra_file_hash, itr)
- {
- struct FileInfo **dynamic_file_list =
- &artwork_info->dynamic_file_list;
- int *num_dynamic_file_list_entries =
- &artwork_info->num_dynamic_file_list_entries;
- struct PropertyMapping **property_mapping =
- &artwork_info->property_mapping;
- int *num_property_mapping_entries =
- &artwork_info->num_property_mapping_entries;
- int current_summarized_file_list_entry =
- artwork_info->num_file_list_entries +
- artwork_info->num_dynamic_file_list_entries;
- char *token = HASH_ITERATION_TOKEN(itr);
- int len_token = strlen(token);
- int start_pos;
- boolean base_prefix_found = FALSE;
- boolean parameter_suffix_found = FALSE;
-
- /* skip all parameter definitions (handled by read_token_parameters()) */
- for (i=0; i < num_suffix_list_entries && !parameter_suffix_found; i++)
- {
- int len_suffix = strlen(suffix_list[i].token);
-
- if (token_suffix_match(token, suffix_list[i].token, -len_suffix))
- parameter_suffix_found = TRUE;
- }
-
-#if 0
- if (IS_PARENT_PROCESS())
- {
- if (parameter_suffix_found)
- printf("---> skipping token '%s' (parameter token)\n", token);
- else
- printf("---> examining token '%s': search prefix ...\n", token);
- }
-#endif
-
- if (parameter_suffix_found)
- continue;
-
- /* ---------- step 0: search for matching base prefix ---------- */
-
- start_pos = 0;
- for (i=0; i<num_base_prefixes && !base_prefix_found; i++)
- {
- char *base_prefix = base_prefixes[i];
- int len_base_prefix = strlen(base_prefix);
- boolean ext1_suffix_found = FALSE;
- boolean ext2_suffix_found = FALSE;
- boolean ext3_suffix_found = FALSE;
- boolean exact_match = FALSE;
- int base_index = -1;
- int ext1_index = -1;
- int ext2_index = -1;
- int ext3_index = -1;
-
- base_prefix_found = token_suffix_match(token, base_prefix, start_pos);
-
- if (!base_prefix_found)
- continue;
-
- base_index = i;
-
- if (start_pos + len_base_prefix == len_token) /* exact match */
- {
- exact_match = TRUE;
-
- add_dynamic_file_list_entry(dynamic_file_list,
- num_dynamic_file_list_entries,
- extra_file_hash,
- suffix_list,
- num_suffix_list_entries,
- token);
- add_property_mapping(property_mapping,
- num_property_mapping_entries,
- base_index, -1, -1, -1,
- current_summarized_file_list_entry);
- continue;
- }
-
-#if 0
- if (IS_PARENT_PROCESS())
- printf("---> examining token '%s': search 1st suffix ...\n", token);
-#endif
-
- /* ---------- step 1: search for matching first suffix ---------- */
-
- start_pos += len_base_prefix;
- for (j=0; j<num_ext1_suffixes && !ext1_suffix_found; j++)
- {
- char *ext1_suffix = ext1_suffixes[j];
- int len_ext1_suffix = strlen(ext1_suffix);
-
- ext1_suffix_found = token_suffix_match(token, ext1_suffix, start_pos);
-
- if (!ext1_suffix_found)
- continue;
-
- ext1_index = j;
-
- if (start_pos + len_ext1_suffix == len_token) /* exact match */
- {
- exact_match = TRUE;
-
- add_dynamic_file_list_entry(dynamic_file_list,
- num_dynamic_file_list_entries,
- extra_file_hash,
- suffix_list,
- num_suffix_list_entries,
- token);
- add_property_mapping(property_mapping,
- num_property_mapping_entries,
- base_index, ext1_index, -1, -1,
- current_summarized_file_list_entry);
- continue;
- }
-
- start_pos += len_ext1_suffix;
- }
-
- if (exact_match)
- break;
-
-#if 0
- if (IS_PARENT_PROCESS())
- printf("---> examining token '%s': search 2nd suffix ...\n", token);
-#endif
-
- /* ---------- step 2: search for matching second suffix ---------- */
-
- for (k=0; k<num_ext2_suffixes && !ext2_suffix_found; k++)
- {
- char *ext2_suffix = ext2_suffixes[k];
- int len_ext2_suffix = strlen(ext2_suffix);
-
- ext2_suffix_found = token_suffix_match(token, ext2_suffix,start_pos);
-
- if (!ext2_suffix_found)
- continue;
-
- ext2_index = k;
-
- if (start_pos + len_ext2_suffix == len_token) /* exact match */
- {
- exact_match = TRUE;
-
- add_dynamic_file_list_entry(dynamic_file_list,
- num_dynamic_file_list_entries,
- extra_file_hash,
- suffix_list,
- num_suffix_list_entries,
- token);
- add_property_mapping(property_mapping,
- num_property_mapping_entries,
- base_index, ext1_index, ext2_index, -1,
- current_summarized_file_list_entry);
- continue;
- }
-
- start_pos += len_ext2_suffix;
- }
-
- if (exact_match)
- break;
-
-#if 0
- if (IS_PARENT_PROCESS())
- printf("---> examining token '%s': search 3rd suffix ...\n",token);
-#endif
-
- /* ---------- step 3: search for matching third suffix ---------- */
-
- for (l=0; l<num_ext3_suffixes && !ext3_suffix_found; l++)
- {
- char *ext3_suffix = ext3_suffixes[l];
- int len_ext3_suffix = strlen(ext3_suffix);
-
- ext3_suffix_found =token_suffix_match(token,ext3_suffix,start_pos);
-
- if (!ext3_suffix_found)
- continue;
-
- ext3_index = l;
-
- if (start_pos + len_ext3_suffix == len_token) /* exact match */
- {
- exact_match = TRUE;
-
- add_dynamic_file_list_entry(dynamic_file_list,
- num_dynamic_file_list_entries,
- extra_file_hash,
- suffix_list,
- num_suffix_list_entries,
- token);
- add_property_mapping(property_mapping,
- num_property_mapping_entries,
- base_index, ext1_index, ext2_index, ext3_index,
- current_summarized_file_list_entry);
- continue;
- }
- }
- }
- }
- END_HASH_ITERATION(extra_file_hash, itr)
-
- if (artwork_info->num_dynamic_file_list_entries > 0)
- {
- artwork_info->dynamic_artwork_list =
- checked_calloc(artwork_info->num_dynamic_file_list_entries *
- artwork_info->sizeof_artwork_list_entry);
- }
-
- if (extra_file_hash != NULL && options.verbose && IS_PARENT_PROCESS())
- {
- SetupFileList *setup_file_list, *list;
- boolean dynamic_tokens_found = FALSE;
- boolean unknown_tokens_found = FALSE;
-
- if ((setup_file_list = loadSetupFileList(filename)) == NULL)
- Error(ERR_EXIT, "loadSetupFileHash works, but loadSetupFileList fails");
-
- BEGIN_HASH_ITERATION(extra_file_hash, itr)
- {
- if (strcmp(HASH_ITERATION_VALUE(itr), known_token_value) == 0)
- dynamic_tokens_found = TRUE;
- else
- unknown_tokens_found = TRUE;
- }
- END_HASH_ITERATION(extra_file_hash, itr)
-
-#if DEBUG
- if (dynamic_tokens_found)
- {
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "dynamic token(s) found:");
-
- for (list = setup_file_list; list != NULL; list = list->next)
- {
- char *value = getHashEntry(extra_file_hash, list->token);
-
- if (value != NULL && strcmp(value, known_token_value) == 0)
- Error(ERR_RETURN, "- dynamic token: '%s'", list->token);
- }
-
- Error(ERR_RETURN_LINE, "-");
- }
-#endif
-
- if (unknown_tokens_found)
- {
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "warning: unknown token(s) found in config file:");
- Error(ERR_RETURN, "- config file: '%s'", filename);
-
- for (list = setup_file_list; list != NULL; list = list->next)
- {
- char *value = getHashEntry(extra_file_hash, list->token);
-
- if (value != NULL && strcmp(value, known_token_value) != 0)
- Error(ERR_RETURN, "- dynamic token: '%s'", list->token);
- }
-
- Error(ERR_RETURN_LINE, "-");
- }
-
- freeSetupFileList(setup_file_list);
- }
-
- freeSetupFileHash(extra_file_hash);
-
-#if 0
- for (i=0; i<num_file_list_entries; i++)
- {
- printf("'%s' ", file_list[i].token);
- if (file_list[i].filename)
- printf("-> '%s'\n", file_list[i].filename);
- else
- printf("-> UNDEFINED [-> '%s']\n", file_list[i].default_filename);
- }
-#endif
-
-#endif
}
static void deleteArtworkListEntry(struct ArtworkListInfo *artwork_info,
char *basename)
{
char *init_text[] =
- { "",
+ {
"Loading graphics:",
"Loading sounds:",
"Loading music:"
return;
}
+#if 0
+ printf("::: %s: '%s'\n", init_text[artwork_info->type], basename);
+#endif
+
DrawInitText(init_text[artwork_info->type], 120, FC_GREEN);
DrawInitText(basename, 150, FC_YELLOW);
#define MAX_COOKIE_LEN 256
-#define ARTWORKINFO_FILENAME(type) ((type) == TREE_TYPE_GRAPHICS_DIR ? \
- GRAPHICSINFO_FILENAME : \
- (type) == TREE_TYPE_SOUNDS_DIR ? \
- SOUNDSINFO_FILENAME : \
- (type) == TREE_TYPE_MUSIC_DIR ? \
+#define ARTWORKINFO_FILENAME(type) ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ GRAPHICSINFO_FILENAME : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ SOUNDSINFO_FILENAME : \
+ (type) == ARTWORK_TYPE_MUSIC ? \
MUSICINFO_FILENAME : "")
-#define ARTWORK_DIRECTORY(type) ((type) == TREE_TYPE_GRAPHICS_DIR ? \
- GRAPHICS_DIRECTORY : \
- (type) == TREE_TYPE_SOUNDS_DIR ? \
- SOUNDS_DIRECTORY : \
- (type) == TREE_TYPE_MUSIC_DIR ? \
+#define ARTWORK_DIRECTORY(type) ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ GRAPHICS_DIRECTORY : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ SOUNDS_DIRECTORY : \
+ (type) == ARTWORK_TYPE_MUSIC ? \
MUSIC_DIRECTORY : "")
-#define OPTIONS_ARTWORK_DIRECTORY(type) ((type) == TREE_TYPE_GRAPHICS_DIR ? \
- options.graphics_directory : \
- (type) == TREE_TYPE_SOUNDS_DIR ? \
- options.sounds_directory : \
- (type) == TREE_TYPE_MUSIC_DIR ? \
+#define OPTIONS_ARTWORK_DIRECTORY(type) ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ options.graphics_directory : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ options.sounds_directory : \
+ (type) == ARTWORK_TYPE_MUSIC ? \
options.music_directory : "")
return music_dir;
}
+static char *getDefaultArtworkSet(int type)
+{
+ return (type == TREE_TYPE_GRAPHICS_DIR ? GRAPHICS_SUBDIR :
+ type == TREE_TYPE_SOUNDS_DIR ? SOUNDS_SUBDIR :
+ type == TREE_TYPE_MUSIC_DIR ? MUSIC_SUBDIR : "");
+}
+
static char *getDefaultArtworkDir(int type)
{
return (type == TREE_TYPE_GRAPHICS_DIR ?
void setLevelArtworkDir(TreeInfo *ti)
{
- char **artwork_path_ptr, *artwork_set;
+ char **artwork_path_ptr, **artwork_set_ptr;
TreeInfo *level_artwork;
if (ti == NULL || leveldir_current == NULL)
return;
- artwork_path_ptr =
- (ti->type == TREE_TYPE_GRAPHICS_DIR ? &leveldir_current->graphics_path :
- ti->type == TREE_TYPE_SOUNDS_DIR ? &leveldir_current->sounds_path :
- &leveldir_current->music_path);
-
- artwork_set =
- (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_set :
- ti->type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_set :
- leveldir_current->music_set);
+ artwork_path_ptr = &(LEVELDIR_ARTWORK_PATH(leveldir_current, ti->type));
+ artwork_set_ptr = &(LEVELDIR_ARTWORK_SET( leveldir_current, ti->type));
if (*artwork_path_ptr != NULL)
free(*artwork_path_ptr);
- if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set)))
+ if ((level_artwork = getTreeInfoFromIdentifier(ti, *artwork_set_ptr)))
*artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork));
else
{
char *dir = getPath2(getCurrentLevelDir(), ARTWORK_DIRECTORY(ti->type));
+ if (*artwork_set_ptr != NULL)
+ free(*artwork_set_ptr);
+
if (fileExists(dir))
+ {
*artwork_path_ptr = getStringCopy(getDefaultArtworkDir(ti->type));
+ *artwork_set_ptr = getStringCopy(getDefaultArtworkSet(ti->type));
+ }
else
+ {
*artwork_path_ptr = getStringCopy(UNDEFINED_FILENAME);
+ *artwork_set_ptr = NULL;
+ }
free(dir);
}
}
-static char *getLevelArtworkDir(int type)
+inline static char *getLevelArtworkSet(int type)
{
- char *artwork_path;
+ if (leveldir_current == NULL)
+ return NULL;
+ return LEVELDIR_ARTWORK_SET(leveldir_current, type);
+}
+
+inline static char *getLevelArtworkDir(int type)
+{
if (leveldir_current == NULL)
return UNDEFINED_FILENAME;
- artwork_path =
- (type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_path :
- type == TREE_TYPE_SOUNDS_DIR ? leveldir_current->sounds_path :
- type == TREE_TYPE_MUSIC_DIR ? leveldir_current->music_path :
- UNDEFINED_FILENAME);
-
- return artwork_path;
+ return LEVELDIR_ARTWORK_PATH(leveldir_current, type);
}
char *getLevelFilename(int nr)
char *getCustomImageFilename(char *basename)
{
static char *filename = NULL;
+ boolean skip_setup_artwork = FALSE;
if (filename != NULL)
free(filename);
if (!setup.override_level_graphics)
{
-#if 0
- /* 1st try: look for special artwork configured in level series config */
- filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename);
-#if 0
- if (strcmp(basename, "RocksScreen.pcx") == 0)
- printf("::: trying 1 '%s' ...\n", filename);
-#endif
+ /* 1st try: look for special artwork in current level series directory */
+ filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
if (fileExists(filename))
return filename;
free(filename);
-#endif
- /* 2nd try: look for special artwork in current level series directory */
- filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
-#if 0
- /*
- if (strcmp(basename, "RocksScreen.pcx") == 0)
- */
- printf("::: trying 2 '%s' ...\n", filename);
-#endif
- if (fileExists(filename))
- return filename;
+ /* check if there is special artwork configured in level series config */
+ if (getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) != NULL)
+ {
+ /* 2nd try: look for special artwork configured in level series config */
+ filename = getPath2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename);
+ if (fileExists(filename))
+ return filename;
- free(filename);
+ free(filename);
-#if 1
- /* 1st try: look for special artwork configured in level series config */
- filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename);
-#if 0
- /*
- if (strcmp(basename, "RocksScreen.pcx") == 0)
- */
- printf("::: trying 2.1 '%s' ...\n", filename);
-#endif
+ /* take missing artwork configured in level set config from default */
+ skip_setup_artwork = TRUE;
+ }
+ }
+
+ if (!skip_setup_artwork)
+ {
+ /* 3rd try: look for special artwork in configured artwork directory */
+ filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
if (fileExists(filename))
return filename;
free(filename);
-#endif
}
- /* 3rd try: look for special artwork in configured artwork directory */
- filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
-#if 0
- /*
- if (strcmp(basename, "RocksScreen.pcx") == 0)
- */
- printf("::: trying 3 '%s' ...\n", filename);
-#endif
- if (fileExists(filename))
- return filename;
-
- free(filename);
-
/* 4th try: look for default artwork in new default artwork directory */
filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename);
-#if 0
- if (strcmp(basename, "RocksScreen.pcx") == 0)
- printf("::: trying 4 '%s' ...\n", filename);
-#endif
if (fileExists(filename))
return filename;
/* 5th try: look for default artwork in old default artwork directory */
filename = getPath2(options.graphics_directory, basename);
-#if 0
- if (strcmp(basename, "RocksScreen.pcx") == 0)
- printf("::: trying 5 '%s' ...\n", filename);
-#endif
if (fileExists(filename))
return filename;
char *getCustomSoundFilename(char *basename)
{
static char *filename = NULL;
+ boolean skip_setup_artwork = FALSE;
if (filename != NULL)
free(filename);
if (!setup.override_level_sounds)
{
-#if 0
- /* 1st try: look for special artwork configured in level series config */
- filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
+ /* 1st try: look for special artwork in current level series directory */
+ filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
if (fileExists(filename))
return filename;
free(filename);
-#endif
- /* 2nd try: look for special artwork in current level series directory */
- filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
- if (fileExists(filename))
- return filename;
+ /* check if there is special artwork configured in level series config */
+ if (getLevelArtworkSet(ARTWORK_TYPE_SOUNDS) != NULL)
+ {
+ /* 2nd try: look for special artwork configured in level series config */
+ filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
+ if (fileExists(filename))
+ return filename;
- free(filename);
+ free(filename);
+
+ /* take missing artwork configured in level set config from default */
+ skip_setup_artwork = TRUE;
+ }
+ }
-#if 1
- /* 1st try: look for special artwork configured in level series config */
- filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
+ if (!skip_setup_artwork)
+ {
+ /* 3rd try: look for special artwork in configured artwork directory */
+ filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
if (fileExists(filename))
return filename;
free(filename);
-#endif
}
- /* 3rd try: look for special artwork in configured artwork directory */
- filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
- if (fileExists(filename))
- return filename;
-
- free(filename);
-
/* 4th try: look for default artwork in new default artwork directory */
filename = getPath2(getDefaultSoundsDir(SOUNDS_SUBDIR), basename);
if (fileExists(filename))
char *getCustomMusicDirectory(void)
{
static char *directory = NULL;
+ boolean skip_setup_artwork = FALSE;
if (directory != NULL)
free(directory);
if (!setup.override_level_music)
{
-#if 0
- /* 1st try: look for special artwork configured in level series config */
- directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+ /* 1st try: look for special artwork in current level series directory */
+ directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
if (fileExists(directory))
return directory;
free(directory);
-#endif
- /* 2nd try: look for special artwork in current level series directory */
- directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
- if (fileExists(directory))
- return directory;
+ /* check if there is special artwork configured in level series config */
+ if (getLevelArtworkSet(ARTWORK_TYPE_MUSIC) != NULL)
+ {
+ /* 2nd try: look for special artwork configured in level series config */
+ directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+ if (fileExists(directory))
+ return directory;
- free(directory);
+ free(directory);
-#if 1
- /* 1st try: look for special artwork configured in level series config */
- directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+ /* take missing artwork configured in level set config from default */
+ skip_setup_artwork = TRUE;
+ }
+ }
+
+ if (!skip_setup_artwork)
+ {
+ /* 3rd try: look for special artwork in configured artwork directory */
+ directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
if (fileExists(directory))
return directory;
free(directory);
-#endif
}
- /* 3rd try: look for special artwork in configured artwork directory */
- directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
- if (fileExists(directory))
- return directory;
-
- free(directory);
-
/* 4th try: look for default artwork in new default artwork directory */
directory = getStringCopy(getDefaultMusicDir(MUSIC_SUBDIR));
if (fileExists(directory))
{
Error(ERR_WARN, "setTreeInfoToDefaultsFromParent(): parent == NULL");
- setTreeInfoToDefaults(ldi, TREE_TYPE_GENERIC);
+ setTreeInfoToDefaults(ldi, TREE_TYPE_UNDEFINED);
+
return;
}
#define MUSIC_SUBDIR "mus_orig"
#endif
+
/* areas in bitmap PIX_DOOR */
/* meaning in PIX_DB_DOOR: (3 PAGEs)
PAGEX1: 1. buffer for DOOR_1
#define DOOR_GFX_PAGEY1 (0)
#define DOOR_GFX_PAGEY2 (gfx.dysize)
-/* functions for version handling */
+
+/* macros for version handling */
#define VERSION_IDENT(x,y,z) ((x) * 1000000 + (y) * 10000 + (z) * 100)
#define RELEASE_IDENT(x,y,z,r) (VERSION_IDENT(x,y,z) + (r))
#define VERSION_MAJOR(x) ((x) / 1000000)
#define VERSION_PATCH(x) (((x) % 10000) / 100)
#define VERSION_RELEASE(x) ((x) % 100)
-/* functions for parent/child process identification */
+
+/* macros for parent/child process identification */
#if defined(PLATFORM_UNIX)
#define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
#define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
#define HAS_CHILD_PROCESS() FALSE
#endif
+
+/* values for artwork type */
+#define ARTWORK_TYPE_GRAPHICS 0
+#define ARTWORK_TYPE_SOUNDS 1
+#define ARTWORK_TYPE_MUSIC 2
+
+#define NUM_ARTWORK_TYPES 3
+
+
+/* values for tree type (chosen to match artwork type) */
+#define TREE_TYPE_UNDEFINED -1
+#define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
+#define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
+#define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
+#define TREE_TYPE_LEVEL_DIR 3
+
+#define NUM_TREE_TYPES 4
+
+
+/* values for artwork handling */
+#define LEVELDIR_ARTWORK_SET(leveldir, type) \
+ ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ (leveldir)->graphics_set : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ (leveldir)->sounds_set : \
+ (leveldir)->music_set)
+
+#define LEVELDIR_ARTWORK_PATH(leveldir, type) \
+ ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ (leveldir)->graphics_path : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ (leveldir)->sounds_path : \
+ (leveldir)->music_path)
+
+#define SETUP_ARTWORK_SET(setup, type) \
+ ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ (setup).graphics_set : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ (setup).sounds_set : \
+ (setup).music_set)
+
+#define SETUP_OVERRIDE_ARTWORK(setup, type) \
+ ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ (setup).override_level_graphics : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ (setup).override_level_sounds : \
+ (setup).override_level_music)
+
+#define ARTWORK_FIRST_NODE(artwork, type) \
+ ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ (artwork).gfx_first : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ (artwork).snd_first : \
+ (artwork).mus_first)
+
+#define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
+ ((type) == ARTWORK_TYPE_GRAPHICS ? \
+ (artwork).gfx_current_identifier : \
+ (type) == ARTWORK_TYPE_SOUNDS ? \
+ (artwork).snd_current_identifier : \
+ (artwork).mus_current_identifier)
+
+
/* type definitions */
typedef int (*EventFilter)(const Event *);
struct OptionInfo options;
};
-#define TREE_TYPE_GENERIC 0
-#define TREE_TYPE_GRAPHICS_DIR 1
-#define TREE_TYPE_SOUNDS_DIR 2
-#define TREE_TYPE_MUSIC_DIR 3
-#define TREE_TYPE_LEVEL_DIR 4
-
-#define ARTWORK_TYPE_GRAPHICS TREE_TYPE_GRAPHICS_DIR
-#define ARTWORK_TYPE_SOUNDS TREE_TYPE_SOUNDS_DIR
-#define ARTWORK_TYPE_MUSIC TREE_TYPE_MUSIC_DIR
-
struct TreeInfo
{
struct TreeInfo **node_top; /* topmost node in tree */